Jump to content

All Activity

This stream auto-updates

  1. Past hour
  2. Today
  3. Only TEXT_LEFT is in view for me. Anything else doesn't show. I have self.window = ActiveWindow(), is there something else I'm missing?
  4. Yesterday
  5. Thank you Josh
  6. I watching now
  7. I must go to sleep, but I will remain with you in the videos. I think the Lua programming series will help you.
  8. Maybe start here. This explains from the beginning how the script editor works: https://www.leadwerks.com/learn/Programming?lang=lua
  9. Really? What are you confused about?
  10. Oh boy, that just opened up a whole new chapter of confusion for me. I don't know how to decipher what I'm looking at.
  11. I think you will have a very difficult time without it!: https://www.leadwerks.com/learn/Debugging?lang=lua&nocpp=1
  12. Sorry, I'm not using visual studio. I actually didn't know how to do breakpoints in the leadwerks script editor.
  13. I don't understand this statement?
  14. I'm use the integrated code editor, does it work in that? The code runs fine if I comment out the CreateTile() line
  15. Run in debug or fast debug mode. If there is still no error, set a breakpoint to figure out where the problem is.
  16. I'll read on tables, but when I run this code, the game opens and closes immediately. No errors given.
  17. I would use table fields instead of global variables: -- create start timer self.gracetimer = CreateTimer(3000) ListenEvent(EVENT_TIMERTICK,self.gracetimer,OnGraceTimer) --create gui local font = LoadFont("Fonts/arial.ttf") self.scoretile = CreateTile(world, font, "Score: 0", 32, TEXT_LEFT) Other than that, what is the problem with this code?
  18. myPlayer = { name = player } myPlayer.name = "myPlayer" myPlayer.speed = 10 myPlayer.jumpforce = 5 myPlayer.maxheight = 10 function myPlayer:Start() self.window = ActiveWindow() self.maxdist = 0 -- create start timer gracetimer = CreateTimer(3000) ListenEvent(EVENT_TIMERTICK,gracetimer,OnGraceTimer) --create gui local font = LoadFont("Fonts/arial.ttf") scoretile = CreateTile(world, font, "Score: 0", 32, TEXT_LEFT) -- Enable physics self:SetPhysicsMode(PHYSICS_RIGIDBODY) self:SetCollisionType(COLLISION_PLAYER) self:SetMass(1) self:SetGravity(0) -- Create camera self.camera = CreateCamera(self.world) self.camera:SetPosition(self.entity:GetPosition()) --we need to save the position of the entity so that we can reset to it self.startpos = self:GetPosition() end --timer callbacks function OnGraceTimer() Print("timer Worked") gracetimer:Stop() gamestarted = true gravity = -10 end --I set up sound in this funciton, I'm not entirely sure if it needs it own function or not function myPlayer:Sound() hit = LoadSound("Sound/Music/hit.mp3") end -- collision function myPlayer:Collide(entity) if entity:GetCollisionType() == COLLISION_SCENE then hit = LoadSound("Sound/Music/hit.mp3") hit:Play() Print("Game Over!") isgameover = true end end --player movement function myPlayer:Update() local pos = self:GetPosition() local vel = self:GetVelocity() --keep track of distance traveled --local dist = pos.z - self.startpos.z --if the game is started, we apply movement and gravity if gamestarted == true then self:SetGravity(-10) vel.z = self.speed end vel.x = 0 self.entity:SetRotation(0,0,0) -- Set a max jump height so that the player can't cheat if pos.y > self.maxheight then pos.y = self.maxheight self:SetPosition(pos) end --added jumping using the spacebar if self.window:KeyDown(KEY_SPACE) and gamestarted == true then vel.y = self.jumpforce end Current code, attempting to set up gui to show total distanced traveled by the player. self:SetVelocity(vel) -- Game is over, so lets reset the player back to the starting position and resume after 3 seconds if isgameover == true then self:SetPosition(self.startpos) isgameover = false end -- Update camera self.camera:SetPosition(self.entity:GetPosition()) self.camera:Move(0,1,-3) end
  19. I'm attempting to set up a gui item for distance traveled. I'm not sure what I'm doing wrong here. When I run the game, it just crashed immediately without any errors. Any ideas?
  20. Last week
  21. Probably? You could create a Lua project, then copy the C++ code files from another project into it to make your game EXE. This is what I plan to do in our SCP game, but I have not put it into practice yet.
  22. A few years ago I used the Torque 3D game engine heavily. I could develop a gameplay logic in Torque Script, and perform high-performance calculations in C++. In Leadwerks 5 I see that I can create two separate project types: Lua and C++. But don't they overlap?
  23. Ok, working code bellow. I have my 3 second delayed start, with the gravity issue solved. I also implemented a max jump height to prevent the player from just going over top of the game objects. This code works, but if anyone would care to look over it and tell me if things are wrong, or if I should have done something else, I'd really appreciate it. I don't want to create bad habits from the start. myPlayer = { name = player } myPlayer.name = "myPlayer" myPlayer.speed = 10 myPlayer.jumpforce = 5 myPlayer.maxheight = 10 function myPlayer:Start() self.window = ActiveWindow() -- create start timer gracetimer = CreateTimer(3000) ListenEvent(EVENT_TIMERTICK,gracetimer,OnGraceTimer) -- Enable physics self:SetPhysicsMode(PHYSICS_RIGIDBODY) self:SetCollisionType(COLLISION_PLAYER) self:SetMass(1) self:SetGravity(0) -- Create camera self.camera = CreateCamera(self.world) self.camera:SetPosition(self.entity:GetPosition()) --we need to save the position of the entity so that we can reset to it startpos = self:GetPosition() end --timer callbacks function OnGraceTimer() Print("timer Worked") gracetimer:Stop() gamestarted = true gravity = -10 end function myPlayer:Sound() hit = LoadSound("Sound/Music/hit.mp3") end -- collision function myPlayer:Collide(entity) if entity:GetCollisionType() == COLLISION_SCENE then hit = LoadSound("Sound/Music/hit.mp3") hit:Play() Print("Game Over!") isgameover = true end end --player movement function myPlayer:Update() local pos = self:GetPosition() local vel = self:GetVelocity() if gamestarted == true then self:SetGravity(-10) vel.z = self.speed end vel.x = 0 self.entity:SetRotation(0,0,0) if pos.y > self.maxheight then pos.y = self.maxheight self:SetPosition(pos) end if self.window:KeyDown(KEY_SPACE) then vel.y = self.jumpforce end self:SetVelocity(vel) -- Game is over, so lets reset the player back to the starting position and resume after 3 seconds if isgameover == true then self:SetPosition(startpos) isgameover = false end -- Update camera self.camera:SetPosition(self.entity:GetPosition()) self.camera:Move(0,1,-3) end
  24. I'm a little confused. I thought I should use the Ultra Engine beta. Now everything is working correct.
  25. You are using Ultra Engine. Use Leadwerks and opt into the beta branch.
  26. I'm convinced that I'm using Self:SetGravity() incorrectly. With gravity disabled in the editor, I thought that self:SetGravity(-10) would add the gravity to the player, but it doesn't. Scratch that, SetGravity doesn't seem to enable gravity, it modifies its value.
  27. I have updated my project but everything is the same. You can see this error in the image number one. Then I try to execute your code statement: result is nil (look picture number two). If I write: local p = CreatePivot(nil) Notify(type(p.GetEnabled)) if true then return end The label in the message box is: "function" like you said in the previous post.
  28. When creating a new C++ project, the Classes and Components folder is still referenced. The classes folder still points to files that have been moved to "Game". <ItemGroup> <Filter Include="Source Files"> <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> </Filter> <Filter Include="Header Files"> <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> <Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions> </Filter> <Filter Include="Resource Files"> <UniqueIdentifier>{54f0adeb-8b31-4c2f-979f-e4ee6840b918}</UniqueIdentifier> </Filter> <Filter Include="Source Files\Steamworks"> <UniqueIdentifier>{6db9dbd5-6d5c-4f70-94e5-523fbcf69c75}</UniqueIdentifier> </Filter> <Filter Include="Header Files\Components"> <UniqueIdentifier>{315863a5-a94a-4237-91aa-7ebc5f7b7c57}</UniqueIdentifier> </Filter> <Filter Include="Header Files\Classes"> <UniqueIdentifier>{fffb3907-599d-4991-8eb4-0b47570890c1}</UniqueIdentifier> </Filter> <Filter Include="Source Files\Game"> <UniqueIdentifier>{1a430258-2bc8-4d33-b6f1-84a974bba2c0}</UniqueIdentifier> </Filter> </ItemGroup>
  29. I think your project needs to be updated. I just created a new project and ran this code, and it says the type is "function": local p = CreatePivot(nil) Notify(type(p.GetVisible)) if true then return end https://www.leadwerks.com/learn/projectmanager
  1. Load more activity
×
×
  • Create New...