I just need help with basic platformer jumping for my game (newbie lua coder in general)
Code: http://pastebin.com/8FcwvMYJ
Beaver.png(Yes it's jsut a square): https://love2d.org/imgmirrur/pR1mzNo.png
[Solved] Help with basic platformer jumping
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
[Solved] Help with basic platformer jumping
Last edited by Fang86 on Sun Sep 27, 2015 9:32 pm, edited 1 time in total.
Re: Help with basic platformer jumping
It'd help more if you attached the .love
Re: Help with basic platformer jumping
Okay, and I have updated it a bit but here it is.redsled wrote:It'd help more if you attached the .love
- Attachments
-
- BeaverBallRevenge.love
- (145.12 KiB) Downloaded 180 times
-
- Party member
- Posts: 730
- Joined: Sat Apr 26, 2014 7:46 pm
Re: Help with basic platformer jumping
That .love shows nothing for me, but the menu. I looked at the code and well it shows that your new to lua. First thing i would say is don't use loveframes for your GUIs. I saw you had another thread where you had an issue with them. I recommend just coding your own until you become more experienced. making a simple button is easy. Also you seem to set fullscreen every frame iirc. That isn't the best way to do things.
this bit:
can become this:
The way that works is that it just toggles the value of fullscreen. not returns the opposite of the value. Also your conditions were a little messed up after a removed the windowed variable so i just had to add parenthesis.
To make a character jump you need y velocity, the jump impulse amount i guess(idk what to call it) and gravity
once you have those you need to update your physics every frame
then you to get the key input
That is very basic example of how to make something jump. I left some of it for you to have fun and discover lol. There is a few issues with that very basic example but im sure you will find them and fix them.
this bit:
Code: Select all
elseif love.keyboard.isDown("f3") and windowed == true and gamestate == "paused" or gamestate == "startmenu" then
fullscreen = true
windowed = false
elseif love.keyboard.isDown("f3") and fullscreen == true and gamestate == "paused" or gamestate == "startmenu" then
windowed = true
fullscreen = false
end
Code: Select all
elseif love.keyboard.isDown("f3") and (gamestate == "paused" or gamestate == "startmenu") then
fullscreen = not fullscreen
love.window.setFullscreen(fullscreen)
end
To make a character jump you need y velocity, the jump impulse amount i guess(idk what to call it) and gravity
Code: Select all
local velY = 0
local y = 300
local ground = 0
local jumpImpulse = 50
local gravity = 9.8
Code: Select all
y = y + velY*dt
velY = velY - gravity*dt
if y < ground then
y = ground
end
Code: Select all
function love.keypressed(key)
if key == " " then
velY = velY + jumpImpluse
end
end
Re: Help with basic platformer jumping
Thank you so much! Also when I put the .love there I forgot to remove the start menu, I added a fully functional gui nowbobbyjones wrote:-Snip-
Who is online
Users browsing this forum: Ahrefs [Bot], Amazon [Bot], Google [Bot] and 4 guests