Page 1 of 14

jumping tutorial?

Posted: Sun Nov 07, 2010 8:11 pm
by toaster468
Ive been looking around and i cannot seem to find an example for some simple jumping! Can someone please tell me a place where i can find some simple code?

Re: jumping tutorial?

Posted: Sun Nov 07, 2010 8:28 pm
by nevon
There's really no way to write such a tutorial, since it all depends entirely on what the rest of your code looks like.

Re: jumping tutorial?

Posted: Sun Nov 07, 2010 8:37 pm
by toaster468
I would write a game around it so if you could please write up some simple code, I would be grateful or at least point me to a simple physics example.

Re: jumping tutorial?

Posted: Sun Nov 07, 2010 9:44 pm
by Robin
If you like to see a simple platformer, you could take a look at Jump Game (you can get it here: http://love2d.org/forums/viewtopic.php? ... 053#p21042), which is a garbled mess, but it could probably serve as a quick introduction.

Re: jumping tutorial?

Posted: Sun Nov 07, 2010 10:37 pm
by toaster468
that is very messy code, I cannot really understand it, i will post my code to see if anyone can help me

Code: Select all

-- Office Man Stan --



function love.load()

	love.graphics.setMode(320, 320)
	love.graphics.setCaption( "Office Man Stan" )



end


function love.update(dt)

end

function love.draw()



end
i deleted all the stuff that i tried so feel free to add jumping if you will, i can do the rest and i will include you in the credits

Re: jumping tutorial?

Posted: Sun Nov 07, 2010 10:43 pm
by Robin
I'm sorry, but this is not how programming works. ;)

I can give you code, but that will not help you. It seems you need to start at the beginning.

Re: jumping tutorial?

Posted: Sun Nov 07, 2010 10:45 pm
by TechnoCat
These are both really bad, very old examples of things I have done. But they can probably help you get started.

without love.physics https://bitbucket.org/dannyfritz/jumpbu ... .lua#cl-40
with love.physics https://bitbucket.org/dannyfritz/megama ... .lua#cl-21

Re: jumping tutorial?

Posted: Sun Nov 07, 2010 10:48 pm
by toaster468
well im not new to programming i know how this works and i like to read up about things work before i try it, but i could not find anything on the wiki about jumping. I know now that i should use impulse but i dont know how to save a picture to a table like in the physics example. would this work?:

Code: Select all


bodies = {}

bodies[0] = love.graphics.newImage("picturelocationhere.PNG")
...
--later on in the code

bodies[0]:applyImpulse( 0, -1000)

I did this in the physics example but the thing is that i need to use a picture instead of a circle

Re: jumping tutorial?

Posted: Sun Nov 07, 2010 10:53 pm
by kikito
It seems that you are under the impression that making a jumping character takes 10 or 20 lines.

I'm afraid it takes a bit more than that.

I can help you, but I will not create the code for you. Sorry.

What I can do is help you gradually transform your code into a jumping one. Step by step.

First, I want you to create an image for your 'jumping man' and another one for the ground.

You will have to load the images inside love.load (with love.graphics.newImage) and draw them inside love.draw, using love.graphics.draw. Try not to make the ground image too big.

Draw the two images so the character seems to be on top of the ground.

When you finish with that, we'll go to the next step.

Re: jumping tutorial?

Posted: Sun Nov 07, 2010 11:01 pm
by toaster468
ok, i get this error alot but i have all my images in my folder and they are the right names but i keep getting an error that they arent there. I am running a 64bit OS so could that be the problem?