Page 3 of 3

Re: How can I make my character jump?

Posted: Sun Apr 22, 2012 5:12 pm
by Nixola
You don't need to write "require 'conf'", because LOVE automatically requires it before requiring main.lua

Re: How can I make my character jump?

Posted: Tue May 08, 2012 12:49 pm
by Kasperelo
To me it said it was programmed for an earlier version of LOVE?

Re: How can I make my character jump?

Posted: Wed May 09, 2012 7:27 pm
by Qcode
In conf.lua you should have t.version = .You should have that as "0.8.0" with the quotations so like this

Code: Select all

function love.conf(t)
    t.version = "0.8.0"         -- The LÖVE version this game was made for (string)
end
If so that should get rid of that screen.

Re: How can I make my character jump?

Posted: Thu May 10, 2012 6:02 am
by Kasperelo
Thanks

Re: How can I make my character jump?

Posted: Thu May 10, 2012 11:01 am
by coffee
Puzzlem00n wrote:STOP THE PRESSES! I think I have a better fix for this.

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
That way you don't have to mess with booleans, which I prefer to avoid.
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.

and BEANSFTW remember that robin "player.y = 400" fix unfortunately will only work then if ground is all flat.

Re: How can I make my character jump?

Posted: Thu May 10, 2012 10:04 pm
by Puzzlem00n
coffee wrote:
Puzzlem00n wrote:STOP THE PRESSES! I think I have a better fix for this.

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
That way you don't have to mess with booleans, which I prefer to avoid.
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.
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???

Re: How can I make my character jump?

Posted: Fri May 11, 2012 8:48 am
by coffee
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???
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.

Re: How can I make my character jump?

Posted: Sat May 12, 2012 1:48 am
by Puzzlem00n
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?
coffee wrote:However I'm afraid it don't erase some problems on it like your "boolean" fear...
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.

Re: How can I make my character jump?

Posted: Sat May 12, 2012 8:45 am
by coffee
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.
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. :)
coffee wrote:I've never gotten stuck in a wall, though, so what kind of serious problems are you getting?
Already told you but here some shots illustratting the problems:
cantgomoretoleft.png
1 - You can't go more close to a wall sometimes.
cantfall.png
2- So that way you cant also fall sometimes.
stuck.png
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).
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.
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"! :D

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 :)

Re: How can I make my character jump?

Posted: Sat May 12, 2012 8:38 pm
by Puzzlem00n
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. :D As I said, I never planned to develop the engine too much further, but I might as well.