Jump to content

Andy90

Members
  • Posts

    189
  • Joined

  • Last visited

Everything posted by Andy90

  1. Hello, Since the vegetation hasn't been completed yet, it might be a great addition to have the option to exclude it from different paint layers. For example, I'm currently working on painting roads, and it would be beneficial if the grass, doesn't appear where these textures are applied. You can observe this in the screenshot. Im not sure how difficult this would be.
  2. New sunday new dev diary
  3. This looks like a fun game
  4. Hello, after some development, my game has been growing quite well. With the expansion of the game, the number of UI "windows" has also increased. To effectively manage all these windows or widgets, I've decided to create a simple script that will handle them. The script includes a table with the information about each "window" and several functions: HideAll(): This function hides all managed windows. AddWindow(widget, show_callback, hide_callback): This function adds a window to the table. The parameters are straightforward. widget refers to the created widget, show_callback is a function that is called whenever the manager opens this window, and hide_callback is called whenever the manager closes the window. It will also return the window ID for the added widget. Show(id): This function displays the window with the specified window ID (which you received from the AddWindow function). Hide(id): It hides the window with the given ID (which you received from the AddWindow function). IsAnyWindowOpen(): This function checks if any window is open. WindowManager.lua WindowManager = {} function WindowManager:AddWindow(window, show_callback, hide_callback) table.insert(self, { Widget = window, OnShow = show_callback, OnHide = hide_callback }) return #self end function WindowManager:HideAll() for _, item in ipairs(self) do if not item.Widget:Hidden() then item.Widget:Hide() item.OnHide() end end end function WindowManager:Show(index) self:HideAll() self[index].Widget:Show() self[index].OnShow() end function WindowManager:Hide(index) if self[index] ~= nil then if not self[index].Widget:Hidden() then self[index].Widget:Hide() self[index].OnHide() end end end function WindowManager:IsAnyWindowOpen() for _, item in ipairs(self) do if not item.Widget:Hidden() then return true end end return false end Implementation the Script Just include the script file within your main lua. For example import("Scripts/Own/WindowManager.lua") Adding a widget self.panel = Widget:Panel(10, 10, 600, 500, base) self.windowID = WindowManager:AddWindow( self.panel, function() self:ShowUI() end, function() self:HideUI() end ) I hope this can help someone maybe @Josh can create a new forum category for source codes which other users can use.
  5. Well Leadwerks is still a good engine. You still can make good games with it.
  6. Ah, okay, this makes sense. I'm relatively new to shaders. It's a fascinating aspect of game development, so I'm trying to grasp what's happening rather than just copying and pasting. I believe that being able to create your own shaders is a significant skill that opens up a world of possibilities. Thanks all again for your help.
  7. Wow, this looks perfect. Thank you so much. Do you happen to know why there were artifacts? Was it due to the texture?
  8. sure here he is. RainShader.zip
  9. Seems to work now...at least a bit. But there are some artifacts wich looking not that good at all Do someone knows why ?
  10. Okey i miss the noise texture. So in this case i need to create the shader itself and a lua post effect wich loads the noise texture in the shader itself right? But how can i set the texture? I searched within the documentation but there is nothing to set a texture.
  11. I made this tutorial but my shader ist just black Fragment Shader #version 400 out vec4 fragData0; uniform vec2 buffersize; uniform float currenttime; uniform sampler2D texture0; void main() { vec2 q = gl_FragCoord.xy/buffersize.xy; vec2 p = -1.0+2.0*q; p.x *= gl_FragCoord.x/buffersize.y; vec3 col = vec3(0.0, 0.0, 0.0); // Rain vec2 st = p * vec2(.5, .01)+vec2(currenttime*.3-q.y*.6*-0.0, currenttime*.3); float f = floor(mod(currenttime/9., 2.0)); f = texture(texture0, st).y * texture(texture0, st*.773).x * 1.55; f = clamp(pow(abs(f), 23.0) * 13.0, 0.0, q.y*.14); col += f; fragData0=vec4(col, 1.0 ); } Vertex Shader #version 400 uniform mat4 projectionmatrix; uniform mat4 drawmatrix; uniform vec2 offset; uniform vec2 position[4]; in vec3 vertex_position; void main(void) { gl_Position = projectionmatrix * (drawmatrix * vec4(position[gl_VertexID]+offset, 0.0, 1.0)); } and here is the source Simple rain (shadertoy.com)
  12. I think a context menu widget is an realy helpfull widget for gui's. I created a script to create one. I will post it in case some needs it 1. Context Menu Script Script.itemHeight = 22 --Height of the menu entry Script.hovered = false --Is hovered variable Script.menuItems = {} --The menu items as table Script.padding = 2 --The padding between the menu entrys --Shows the context menu function Script:ShowContextMenu(x, y) self:HideContextMenu() local sz = self.widget:GetSize(true) local height = self:CalculateHeight() self.widget:SetLayout(x, y, sz.width, height) self.widget:Show() self.widget:Redraw() end --Hides the context menu function Script:HideContextMenu() self.widget:Hide() self.widget:GetParent():Redraw() end --Sets new context menu items function Script:SetContextMenuItems(contextMenuItems) self.menuItems = contextMenuItems self.widget:Redraw() end --Calculates the height of the context menu function Script:CalculateHeight() return (#self.menuItems * self.itemHeight) + (#self.menuItems * self.padding) + self.padding end --Renders the context menu function Script:Draw(x, y, width, height) local gui = self.widget:GetGUI() local pos = self.widget:GetPosition(true) local sz = self.widget:GetSize(true) local fontHeight = gui:GetFontHeight() local height = self:CalculateHeight() local iX = pos.x + self.padding local iY = pos.y + self.padding local iWidth = sz.width - (self.padding * 2) gui:SetColor(0.145, 0.145, 0.145) gui:DrawRect(pos.x, pos.y, sz.width, height, 0) gui:SetColor(0, 0, 0) gui:DrawRect(pos.x, pos.y, sz.width, height, 1) for _, item in ipairs(self.menuItems) do local centerX = (iX + sz.width) / 2 local textX = centerX - (gui:GetTextWidth(item.Text) / 2) local textY = (iY + (self.itemHeight / 2)) - ((gui:GetFontHeight() / 2) - self.padding) if self:IsItemHovered(iX, iY, iWidth, self.itemHeight) then gui:SetColor(0.075, 0.075, 0.075) item.Hovered = true else gui:SetColor(0.175, 0.175, 0.175) item.Hovered = false end gui:DrawRect(iX, iY, iWidth, self.itemHeight, 0) gui:SetColor(1, 1, 1) gui:DrawText(item.Text, iX + self.padding, textY, iWidth, self.itemHeight) iY = iY + self.itemHeight + self.padding end end --Returns the hovered item function Script:GetHoveredItem() for _, item in ipairs(self.menuItems) do if item.Hovered then return item end end return nil end --On mouse enter event function Script:MouseEnter(x, y) self.hovered = true self.widget:Redraw() end --On mouse leave event function Script:MouseLeave(x, y) self.hovered = false self.widget:Redraw() end --On mouse down event function Script:MouseDown(button, x, y) if button == Mouse.Left then self.widget:Redraw() end end --On mouse up event function Script:MouseUp(button, x, y) if button == Mouse.Left then if self.hovered then EventQueue:Emit(Event.WidgetAction, self.widget) local selectedItem = self:GetHoveredItem() if selectedItem ~= nil then selectedItem.OnClick(selectedItem) end self:HideContextMenu() end self.widget:Redraw() end end --On mouse move event function Script:MouseMove(x, y) self.widget:Redraw() end --Check if a item is hovered function Script:IsItemHovered(x, y, width, height) if self.hovered then local mousePos = Window:GetCurrent():GetMousePosition() if mousePos.x > x and mousePos.y > y and mousePos.x < x + width and mousePos.y < y + height then return true end end return false end 2. Intial the widget self.contextMenu = Widget:Create("", 15, 15, 150, 64, base, "Scripts/Own/GUI/ContextMenu.lua") local menuItems = { { Text = "Unequip", OnClick = function() System:Print("Unequip Item") self.ivEquipItem3.script:ClearItem() self.Tool = nil end }, { Text = "Repair Item", OnClick = function() System:Print("Repair Item") end } } self.contextMenu.script:SetContextMenuItems(menuItems) self.contextMenu.script:HideContextMenu() 3. Open the context menu widget function IvEquipItem3Click(event, parent) local mousePos = window:GetMousePosition() parent.contextMenu.script:ShowContextMenu(mousePos.x,mousePos.y) end
  13. New Dev Diary is online: Its including the following things: Items in the inventory can now stack Implementet Tree Spawner and Harvesting System Implementet Object Spawner Implementet Stone Spawns Implementet Bushs Spawns Implementet the player crafting menu Implementet the building menu Changes to the Terrain height and the level design POI: Abandoned Summercamp
  14. Sure, I unchecked the option to include only used files in the zip. Now it's working. By the way, it's an encrypted zip, correct? This is important to me because I use some TurboSquid models, and they require that the model itself isn't accessible as a file.
  15. Hello i made todays a first test with a standalone version. For some reason the game is crashing while the world get loaded. Is there some error log?
  16. nono i dont want collapse a prefabs this is the point. Im bad in explaining its more to create a simple model from a collection.
  17. Yes sure but is it possible to collapse the prefab to one entity ?
  18. Yes I know and I find this tool great. I mean the create model function a little differently. Let's say we have a house. In this house we add other entities like a table, sofa etc and set the house as parent for these entities and the function should now make a model out of this collection. With the house and its content.
  19. I mean within the editor. So you select a node and have a context menu entry. Like the "Create Prefab" function in Leadwerks.
  20. I like the function that allows you to collapse objects from the model into a single entity. It would be a great feature within the ultra engine to save a parent with its children as a single model, enabling you to collapse, for example, 10 entities into one. Like the "Create Prefab" function.
  21. ok its night but the trees are grayish okey its because of the fog
  22. Hello i want ask what is the best way to create a day night cycle with the leadwerks engine. I know it from unity that you create a pivot in the middle of the scene and attach the directionlight (sun) to this. So you can rotate this pivot and the light will turn arround the terrain. But if i do this it works not realy well. I think its because the ambient lightning from the skybox.
  23. Yeah i know. Maybe "lookAt" is the wrong name for the function. Is more the Vec3 at the point where the entity (camera) is looking at
×
×
  • Create New...