Jump to content

epsilonion

Members
  • Posts

    80
  • Joined

  • Last visited

Posts posted by epsilonion

  1. Hi guys,

     

    I made a menu, loaded in a background file for test purposes and assigned a few menu items

     

    Start

    Settings

    Exit

     

    When the program first starts a flag is set to 1 so the menu appears when the program has loaded

    up.

     

    Then it goes into a while loop, while the flag is = 1, then theirs a if block for the menu items.

     

    this is where it gets funny.. I have assigned keys to the menu as well as mouse positions, if the mouse is in location and left button is pressed or the T key is pressed then re size the screen to full screen.

     

    It works when you press the T key but when you click it, it re-sizes the screen but does not call the menu draw function again to re-size the menu background and text.

     

    its wierd because it works if I don't put the menu draw in its own function but then it will not re-size the background or the menu text because it can not be called from the if bock..

     

    I have attached the lua file.

    App.rar

  2. I am not getting error on the import("Scripts/functions.lua") now but its not doing it really..

     

    this is the contents of the functions.lua

     

    I get errors with the self. so i deleted it then errors on the context trying to index self. (nill value)

    when I deleted the self I got the same but error trying to index contect (nill value)

     

    I have googled it etc but not got much help there, I looked at some examples on the site and they work if you are using them in the editor on a asset but I want to call it from the App.lua file to tidy up the coding.. :D

     

    function SplashScreen()

     

    splash = Texture:Load("Materials/splash.tex")

     

    if startUp >= 1 then

     

    self.context:SetColor(0,0,0)

    self.context:Clear() -- Clear the context

    self.context:SetColor(1,1,1)

    self.context:DrawImage(splash,0,0) --Draw the splash screen

    self.context:Sync(true) -- Sync so it loads the screen

     

    Time:Delay(10000) -- Time delay of 10 sec's while the splash is displayed

    startUp = 0 -- set the startUp flag to 0 so the splash screen does not

    -- display on the next pass in the loop.

     

    end -- end the if statement

     

    return startUp --return the startup flag value so the splash screen only runs on startup of the application

     

    end

  3. This is basic stuff really and a noob question.

     

     

    Is it possible in lua to place functions in a seperate file and to call them from lua.app

     

     

    What I am wanting to do is put the code for my main menu in a function or method in another file and have it loaded in to be called in the app.lua file.

     

    something like

     

    require_once ('scripts/functions.lua')

     

    then call a function to display a menu

     

    menu();

     

     

     

    and in the functions file have all my functions like savegame, respawn, inventury etc.

     

    I like to do things like this as it keeps everything nice and tidy, also easy to find things when problems arise...

  4. Yup i am new to this. and wow I only placed 15 lights on this level it looks like some of them are duplicated.. I have noticed this on some of the walls when I drag a wall out (create A wall) that 2 have been created so I have to delete one of them..

     

    Thought I was doing something wrong so downloaded unity and tried it on there and it only created one wall so I dont know..

     

    Anyhow, its a good job I backed the scene up before adding lights.

     

    I have added the lights again but made sure no duplicates where there, changed the doors from glass to concrete and gave the doors room to move without collision and it run smooth as a babies bottom..

     

    I was wanting to make some higher resolution textures for the walls etc because they look very basic and plain at the moment but I am afraid that this would introduce lag as well.....

    biggrin.png

     

     

    Thank you for your help guy's its a learning curve since I last programmed over 15 years ago and then I was doing applications such as accounting software, so its a big step.. biggrin.png

     

    I have attached the backup file with the lights placed in without the duplicates.

     

    Its a test map that I am using to see how things go with the assets I am creating..

    meetingroom.rar

  5. OK got it.... Menu with mouse position and click on the word Start game or press the S key:

     

     

    function App:Start()

     

    --Set menu flag so the menu comes up when game is first loaded

    self.menuFlag = 1

     

     

    --Load a texture

    self.texture = Texture:Load("Images/menuBG.tex")

     

    --set the font and text size for the menu

    local font = Font:Load("Fonts/Arial.ttf",24)

    self.context:SetFont(font)

    font:Release()

     

    function App:Loop()

     

    ---If the escape key is pressed then display the menu

    if self.window:KeyDown(Key.Escape) or self.menuFlag >= 1 then

    self.menuFlag = 1

     

    --pause the game??

    Time:Pause()

     

    --display the texture file for the background image

    self.context:SetColor(0,0,0)

    self.context:Clear()

    self.context:SetColor(1,1,1)

    --self.context:DrawImage(self.texture,0,0)

     

    --reset the context colour to black and clear the contect

    self.context:SetColor(0,0,0)

    -- self.context:Clear()

     

    --Draw some centered text on the screen

    local text = "Press S -> Start"

    local text1 = "Press T -> Settings"

    local text2 = "Press X -> Exit"

     

    --get the font that was set above

    local font = self.context:GetFont()

     

    --get the window height and width to find where you want the text

    local x = self.window:GetWidth() /3

    local y = self.window:GetHeight() /4

     

    --get the text width, height and devide it by 2

    tx = x - font:GetTextWidth(text)/2

    ty = y - font:GetHeight()

     

    self.context:SetBlendMode(Blend.Alpha)

    self.context:SetColor(1,1,1)

    self.context:DrawText(text,tx,ty)

    self.context:DrawText(text1,tx,ty +40)

    self.context:DrawText(text2,tx,ty + 80)

     

    --reset blend mode

    self.context:SetBlendMode(Blend.Solid)

     

    self.context:Sync(true)

     

    --while loop for the menu selection

    while self.menuFlag >= 1 do

     

    -- returns teh x y position of the mouse cursor

    local mousePos = App.window:GetMousePosition()

     

    -- Show the mouse cursor

    self.window:ShowMouse()

     

    if mousePos.x > tx and mousePos.x < (tx + ty / 2) and mousePos.y > ty and mousePos.y < y and self.window:MouseDown(Key.LButton) or self.window:KeyDown(Key.S) then

     

    self.menuFlag = 0

    self.window:HideMouse()

    Time:Resume()

    Time:Update()

     

     

    elseif mousePos.x > tx and mousePos.x < (tx + ty +40 / 2) and mousePos.y > (ty + 40) and mousePos.y < (y + 40) and self.window:MouseDown(Key.LButton) or self.window:KeyDown(Key.T) then

     

    --Maximize the window

    self.window:Maximize()

     

     

    elseif mousePos.x > tx and mousePos.x < (tx + ty +80 / 2) and mousePos.y > (ty + 80) and mousePos.y < (y + 80) and self.window:MouseDown(Key.LButton) or self.window:KeyDown(Key.X) then

     

    return false

     

    end

     

    end

     

     

    end

     

    Hope this helps some of you... :D

    • Upvote 2
  6. I was working on my level last night and I noticed a slight fps drop, booted up today and I am getting lots of lag.

     

    I have created a small level thats like only 2 small is rooms and a corridor and I am struggling to get over 30 FPS today where as yesterday was above 100 FPS , there are only 16000 polygons so it is not like there are a lot of them any idea's on whats going on?

     

     

    Any ideas would be great

    meetingroom _02.rar

  7. Have you tried setting the root gravety to 0 and the player mass to 0?

    and then use the space (jump key to go up) and the crouch key to go down,

     

    I have seen a modified fps script with crouch enabled on it here somewhere...

    as of 3rd person, I have not tried that yet but I want to and a top down ....

     

    Hope this helps...

  8. This is my start up including splash screen:

     

    When the game first loads it goes straight into a splash screen with a disclaimer of pre alpha development and a a little advert saying powered by LEADWERKS Game Engine.

     

    The menu is just a basic menu for now until I code for the mouse to interact with the menu, you just use the keyboard to select a menu item.

     

    It is not finished and gives me basic function of a menu etc, I have to tidy it up but it was 4am when I did this.. biggrin.png

     

     

    Splash Screen:

     

    Under the App:start Function

     

    --Load a spash screen texture

    self.splash = Texture:Load("Images/splash.tex")

     

    --Set a flag so it does not run the splash screen everytime it loops

    StartUp = 1

     

    Under the function App:Loop()

     

    -- load a splash screen before starting the game

    -- If the startUp flag is grater or equal to 1 then load the splash screen

    -- so if it is not greater or equal to 1 then skip past it

     

    if startUp >= 1 then

    self.context:SetColor(0,0,0)

    self.context:Clear() -- Clear the context

    self.context:SetColor(1,1,1)

    self.context:DrawImage(self.splash,0,0) --Draw the splash screen

    self.context:Sync(true) -- Sync so it loads the screen

     

    Time:Delay(10000) -- Time delay of 10 sec's while the splash is displayed

    -- startUp = 0 -- set the startUp flag to 0 so the splash screen does not

    -- display on the next pass in the loop.

     

    end -- end the if statement

     

     

    Next I put the basic's in for the main menu

     

    Basic Menu:

     

     

     

    function App:Start()

     

    --Set menu flag so the menu comes up when game is first loaded
    self.menuFlag = 1
    
    
    --Load a texture
    self.texture = Texture:Load("Images/menuBG.tex")
    
    --set the font and text size for the menu
    local font = Font:Load("Fonts/Arial.ttf",24)
    self.context:SetFont(font)
    font:Release()

     

     

     

    function App:Loop()

     

    if self.window:Closed() then return false end --If window has been closed, end the program
    
    
    if self.window:KeyDown(Key.Escape) or self.menuFlag >= 1 then --If the escape key is pressed then display the menu
    self.menuFlag = 1
    
    Time:Pause() --pause the game
    
    self.context:SetColor(0,0,0) --display the texture file for the background image
    self.context:Clear()
    self.context:SetColor(1,1,1)
    self.context:DrawImage(self.texture,0,0)
    
    self.context:SetColor(0,0,0) --reset the context colour to black and clear the contect
    -- self.context:Clear()
    
    --Draw some on the screen
    local text = "Press S -> Start"
    local text1 = "Press T -> Settings"
    local text2 = "Press X -> Exit"
    
    local font = self.context:GetFont() --get the font that was set above
    
    
    local x = self.window:GetWidth()/4 --get the window height and width
    local y = self.window:GetHeight()/3 -- and set it up for drawing the text
    
    x = x - font:GetTextWidth(text)/2 -- get the text width, height and divide
    y = y - font:GetHeight()/2 -- it by 2
    
    self.context:SetBlendMode(Blend.Alpha)
    self.context:SetColor(1,1,1)
    self.context:DrawText(text,x,y)
    self.context:DrawText(text1,x,y +40)
    self.context:DrawText(text2,x,y + 80)
    self.context:SetBlendMode(Blend.Solid) -- reset blend -- mode
    
    self.context:Sync(true)
    
    self.window:ShowMouse() --show mouse
    
    
    while self.menuFlag >= 1 do --while loop for the menu selection
    
    if self.window:KeyDown(Key.S) then
    self.menuFlag = 0
    self.window:HideMouse()
    
    Time:Resume()
    Time:Update()
    end
    
    if self.window:KeyDown(Key.T) then
    self.window:Maximize() --Maximize the window
    
    end
    
    if self.window:KeyDown(Key.X) then
    
    return false
    end
    
    
    end
    
    
    end
    

    • Upvote 4
  9. This is what I did in LUA to display a splash screen and pause for 10 seconds.

     

    I am trying to implement this in C++ but it is not doing it for some reason.

     

     

    Under the App:start Function

     

    --Load a spash screen texture
    self.splash = Texture:Load("Materials/splash.tex")
    
    --Set a flag so it does not run the splash screen everytime it loops
    StartUp = 1

     

     

    Under the function App:Loop()

     

    --load a splash screen before starting the game
    -- If the startUp flag is grater or equal to 1 then load the splash screen
    -- It did not like it if it was just equal to 1 and it bugged out until I put the greater than in
    
    if startUp >= 1 then
    
    self.context:SetColor(0,0,0)
    self.context:Clear() -- Clear the context
    self.context:SetColor(1,1,1)
    self.context:DrawImage(self.splash,0,0) --Draw the splash screen
    self.context:Sync(true) -- Sync so it loads the screen
    
    Time:Delay(10000) -- Time delay of 10 sec's while the splash is displayed
    startUp = 0 -- set the startUp flag to 0 so the splash screen does not
    -- display on the next pass in the loop.
    
    end -- end the if statement

    • Upvote 1
  10. Think I have figured it out....

     

    You would have to use the Window::GetHeight command (gets the outer height of the current window in pixels, and Window::GetWidth gets the width of the current window outer width in pixels, then you would have to drawImage to fit the screen, usefull if you have a settings options for windowed and full screen...

     

     

     

  11. I am wondering if there is a way to re-size a image that is displayed with the drawImage function?

     

    Basically the image for the background of my menu should re-size if the screen is windows or in full-screen.

     

    the picture should be able to be resized to the resolution of the monitor etc etc..

     

    it just looks more professional if someones got a very high resolution and your in full screen and your background image only covers half the background..

     

    any help would be great.. :D

     

     

    thank you in advance..

  12. Hi,

     

    I am interested in doing a cockpit for a space type game.

     

    I will create a model in 3DS max or blender, I am just wondering how to attach it to the first person camera in LUA, would it be a similar process as adding a HUD but not with the Draw command.

     

    What I want to do is have clickable objects in the cockpit etc etc as well but that looks like it is the easy part lol...

     

    I would use C++ but I am not comfortable enough with it yet so I would prefer to use LUA...

     

    any help, I would be thank full for it..

  13. a few things to help you debug;

    • Did you infact start a new C++ project?[/quote]

    Yes and opened the solution in Vis studio

    • Are you editing the correct map? ( just opening a new project in the editor wont change the map for reasons unkown )

    Yes I am opening the start.map.

    • Are you using the FPS prefab? ( in this case you need to remove the camera in the C++ code or it wont work )

    Ahhhh did not know this did not see it in any documentation...

    so this would be why the FPS prefab camera in LE editor when run and in the Vis studio editor are at different locations..

    • Have you compiled BOTH the debug and release version of the source?

    I have now thank you for this.. where did you get this information from? its not in the documentation I have read it all twice..

    • As for the map needing to be called start.map - look for theese line in the App.cpp file;

    std::string mapname = System::GetProperty("map","Maps/start.map");
    Map::Load(mapname);
    

     

    I realized this one as I have changed/loaded levels in lua before coming across to the standard edition but getting it all set up has been a pain TBH..

     

     

     

    Thankyou for these notes they are helping a lot, I think some starting out in standard edition notes or documentation is needed because its not plug in and play like the LUA edition...

     

    thank you again

×
×
  • Create New...