How can I make my character jump?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: How can I make my character jump?
You don't need to write "require 'conf'", because LOVE automatically requires it before requiring main.lua
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Re: How can I make my character jump?
To me it said it was programmed for an earlier version of LOVE?
Re: How can I make my character jump?
In conf.lua you should have t.version = .You should have that as "0.8.0" with the quotations so like this
If so that should get rid of that screen.
Code: Select all
function love.conf(t)
t.version = "0.8.0" -- The LÖVE version this game was made for (string)
end
Re: How can I make my character jump?
Besides the problems and good suggestions that robin pointed (hovering bug/colliding_plataform) notice that since you are not drawing a real floor you don't see an eventual problem. When you comparing "player.y > 400" you checking the top of your head with something. So unless that 400 value is the same as "floor - player.heigth" actually you should being compare something like "player.y + player.height > 400" that in this case player.height should be 40.Puzzlem00n wrote:STOP THE PRESSES! I think I have a better fix for this.
That way you don't have to mess with booleans, which I prefer to avoid.Code: Select all
function love.load() player = { x = 280, y = 380, ySpeed = 0, -- the Speed we'll add to the Y movement gravSecond = 1.5 -- gravity amount } end function love.update(dt) frame = dt * 30 -- I do this just because I think better this way player.ySpeed = player.ySpeed + player.gravSecond * frame -- We add gravity to the ySpeed player.y = player.y + player.ySpeed * frame -- We add ySpeed to the player's y position if player.y > 400 then -- Are we on the ground? player.y = player.y - player.ySpeed * frame -- If we are, We undo that moving down player.ySpeed = 0 -- The ySpeed is reset end if love.keyboard.isDown("up") and player.ySpeed == 0 then -- Should we be jumping, and can we? --This works because the ySpeed is only zero when we aren't already jumping. player.ySpeed = -20 -- Make us add a negative, to move up end end function love.draw() love.graphics.rectangle("fill", player.x, player.y, 40, 40) -- Draw it! end
and BEANSFTW remember that robin "player.y = 400" fix unfortunately will only work then if ground is all flat.
- Puzzlem00n
- Party member
- Posts: 171
- Joined: Fri Apr 06, 2012 8:49 pm
- Contact:
Re: How can I make my character jump?
Yeah, I know... I figured that was sort of obvious. (no offense. ) It's just, you know, not necessary until there's actual ground. I have in fact made a full platform engine from this, and I myself didn't add it until then.coffee wrote:Besides the problems and good suggestions that robin pointed (hovering bug/colliding_plataform) notice that since you are not drawing a real floor you don't see an eventual problem. When you comparing "player.y > 400" you checking the top of your head with something. So unless that 400 value is the same as "floor - player.heigth" actually you should being compare something like "player.y + player.height > 400" that in this case player.height should be 40.Puzzlem00n wrote:STOP THE PRESSES! I think I have a better fix for this.
That way you don't have to mess with booleans, which I prefer to avoid.Code: Select all
function love.load() player = { x = 280, y = 380, ySpeed = 0, -- the Speed we'll add to the Y movement gravSecond = 1.5 -- gravity amount } end function love.update(dt) frame = dt * 30 -- I do this just because I think better this way player.ySpeed = player.ySpeed + player.gravSecond * frame -- We add gravity to the ySpeed player.y = player.y + player.ySpeed * frame -- We add ySpeed to the player's y position if player.y > 400 then -- Are we on the ground? player.y = player.y - player.ySpeed * frame -- If we are, We undo that moving down player.ySpeed = 0 -- The ySpeed is reset end if love.keyboard.isDown("up") and player.ySpeed == 0 then -- Should we be jumping, and can we? --This works because the ySpeed is only zero when we aren't already jumping. player.ySpeed = -20 -- Make us add a negative, to move up end end function love.draw() love.graphics.rectangle("fill", player.x, player.y, 40, 40) -- Draw it! end
P.S. Is Beans is still even on this thread???
I LÖVE, therefore I am.
Re: How can I make my character jump?
It's not actually a question if is obvious for you but that BEANSFTW undestand all things to how correctly make his char jump. Don't worry I know your let's say "full" platform engine (viewtopic.php?f=4&t=8740) from what you keep copy/past pieces of it in various threads. However I'm afraid it don't erase some problems on it like your "boolean" fear and worst have serious problems in bound detection/movement. So, sometimes either fails not touching correctly sideways or ends stuck in walls jumping. I think would be nice you refine and fix it first before help people (that is always good you want it to do) with pieces of it. No offense I hope.Puzzlem00n wrote: Yeah, I know... I figured that was sort of obvious. (no offense. ) It's just, you know, not necessary until there's actual ground. I have in fact made a full platform engine from this, and I myself didn't add it until then.
P.S. Is Beans is still even on this thread???
- Puzzlem00n
- Party member
- Posts: 171
- Joined: Fri Apr 06, 2012 8:49 pm
- Contact:
Re: How can I make my character jump?
Oh, wow, I do use it in a lot of places, don't I? Yes, I suppose I shouldn't call it full, and it could use some improvements. I never really polished it, because, you know, I hadn't planned on using it to help people, it just turned out that way. I've never gotten stuck in a wall, though, so what kind of serious problems are you getting?
That's the one thing I don't completely see the error of. How does doing it the way I do make a problem? As far as I can tell, it's not really much of an issue unless you make the ySpeed possibly equal to zero in the air.coffee wrote:However I'm afraid it don't erase some problems on it like your "boolean" fear...
I LÖVE, therefore I am.
Re: How can I make my character jump?
A quick warning. Besides your help here, you for example post a "full" platform code (but a stripped edition of your engine whitout lava and exit) here (viewtopic.php?f=4&t=8922) that you didn't tested first for sure. With the lack of declaration of a value in player.y you get obvious error screen when operating it in update. Since no one noticed, protested or posted after you can still get there and correct it witouth an "edited" mark.Puzzlem00n wrote:Oh, wow, I do use it in a lot of places, don't I? Yes, I suppose I shouldn't call it full, and it could use some improvements. I never really polished it, because, you know, I hadn't planned on using it to help people, it just turned out that way.
Already told you but here some shots illustratting the problems:coffee wrote:I've never gotten stuck in a wall, though, so what kind of serious problems are you getting?
1 - You can't go more close to a wall sometimes.
2- So that way you cant also fall sometimes.
3 - Sometimes when jumping you can end stuck in a wall for an undetermined piece of time.
Notice: I did the screenshots with the "corrected" code of your davidbot/banoticus post but It's ends to be the same because I had already notice those problems in "full" engine. Also tested your problems with 0.7/0.8. Same. (OSX here).
You right it's not an "error" itself of course, but a style (or lack of it) that leads to problems or complicates our code. But you can bet that a lot of serious coders should see our/theirs own bad code as human "errors"!Puzzlem00n wrote:That's the one thing I don't completely see the error of. How does doing it the way I do make a problem? As far as I can tell, it's not really much of an issue unless you make the ySpeed possibly equal to zero in the air.
Another "not-an-error" in you platform engine is bad labeling use. For example in your "BoundingChecks" function you actually end moving stuff there so you not only checking but doing lot more import things.
But with some booleans as Robin suggest and I already saw in a lot of other platforms you can do a proper way of separate checking from movement. I confess I already had some difficulties at start with embrace boolean use but ends to be a better efficient and correct way of coding.
With some work in your little engine doing a little code reorganization (and fix the problems on it of course) could end to be a good simple platform base/template. But I remember for example when YellowAfterLife presented his small platform engine he needed to end to fix a lot more that he was expecting at start.
Well let's not end this more off-topic even that related. I hope that this help and you didn't get mad with my remarks but you will see that there are bugs there and that you can also optimize a bit things there. Have fun remodeling you platform puzzlemoon. Anything you need for testing later just ask, I gadly help
- Puzzlem00n
- Party member
- Posts: 171
- Joined: Fri Apr 06, 2012 8:49 pm
- Contact:
Re: How can I make my character jump?
Thanks for everything, coffee. I had never expected to get help without even asking for it!
I honestly cannot be angry with you, as everything you say is true, and at least that even in it's premature stages, it's still been helping some people learn around here. As I said, I never planned to develop the engine too much further, but I might as well.
I honestly cannot be angry with you, as everything you say is true, and at least that even in it's premature stages, it's still been helping some people learn around here. As I said, I never planned to develop the engine too much further, but I might as well.
I LÖVE, therefore I am.
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 4 guests