How can i make a simple platformer with a character and two types of floors?
One which is a normal floor and one that hurts you?
Do i need some kind of physics knowledge or something?
Please help.
A template .love file would be great!
Platformer
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- Taehl
- Dreaming in associative arrays
- Posts: 1025
- Joined: Mon Jan 11, 2010 5:07 am
- Location: CA, USA
- Contact:
Re: Platformer
An understanding of the most simple physics would be very helpful, yes. But to make it easier for you, I'd recommend looking up HardonCollider or Fizz, which were made to help out with simple physics. I'm not sure if there's a platformer demo for HC, but I made one for Fizz.
As for a floor hurting you, all you'd have to do is check if you're touching that floor, and if so, decrease the variable you use to store health. Tip: Remember how in old NES games, if you got hurt your character would flash and be invulnerable for a short time? This is a great anti-frustration mechanic that too many game devs overlook. I'd highly suggest using it.
As for a floor hurting you, all you'd have to do is check if you're touching that floor, and if so, decrease the variable you use to store health. Tip: Remember how in old NES games, if you got hurt your character would flash and be invulnerable for a short time? This is a great anti-frustration mechanic that too many game devs overlook. I'd highly suggest using it.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
- baconhawka7x
- Party member
- Posts: 491
- Joined: Mon Nov 21, 2011 7:05 am
- Location: Oregon, USA
- Contact:
Re: Platformer
I suggest reading this, if you are thinking about using tiles. https://github.com/kikito/love-tile-tutorial/wiki
Re: Platformer
If you want to use AABBs (axis aligned bounding boxes) instead of tiles then you can use this snippet from the wiki:
http://love2d.org/wiki/BoundingBox.lua
it checks wether two rectangles that are axis aligned (=defined by x,y,width,height) collide with eachother.
The second part is collision resolution/response (what happens if things collide). For that you would need two different chunks of code: one for your 'outch' object and one for your 'solid' object.
the ouch one is pretty easy since it would not matter from where/how you collide. So your collision response is something like this:
A collision response with a 'solid' AABB is something different. After you checked for the collision you will have to know from which side you collide, since you will have to move the movable object outside of the solid object. If you have the same response for every side then your movable object would teleport through the solid one in 3/4 cases.
in my learning project here:http://love2d.org/forums/viewtopic.php?f=5&t=5903
I have to use exactly what I described above. Just don't think this is how it's done!!! The code is insanely messy, ugly and full of bad habbits and I'am revising it atm.
http://love2d.org/wiki/BoundingBox.lua
it checks wether two rectangles that are axis aligned (=defined by x,y,width,height) collide with eachother.
The second part is collision resolution/response (what happens if things collide). For that you would need two different chunks of code: one for your 'outch' object and one for your 'solid' object.
the ouch one is pretty easy since it would not matter from where/how you collide. So your collision response is something like this:
Code: Select all
if checkCollision(...arguments) then
player.state='dead'
end
--or
if checkCollision(...arguments) then
player.health=player.health-20
end
in my learning project here:http://love2d.org/forums/viewtopic.php?f=5&t=5903
I have to use exactly what I described above. Just don't think this is how it's done!!! The code is insanely messy, ugly and full of bad habbits and I'am revising it atm.
Sry about my english.
-
- Prole
- Posts: 43
- Joined: Sun Dec 25, 2011 5:13 pm
Re: Platformer
So lets say I have my character:
How do I make gravity physics for him?
Sorry i'm new and i don't know anything about physics in Lua.
I'll set it out and then i'll wait until somebody tells me how to do gravity physics...
Code: Select all
char=love.graphics.rectangle("fill",50, 100, 20, 20)
Sorry i'm new and i don't know anything about physics in Lua.
I'll set it out and then i'll wait until somebody tells me how to do gravity physics...
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Platformer
love.graphics.rectangle draws a rectangle, it doesn't create any objects.
Physics is always a bit hard to explain, and it's easier if you have more experience with programming in general.
Physics is always a bit hard to explain, and it's easier if you have more experience with programming in general.
Help us help you: attach a .love.
-
- Prole
- Posts: 43
- Joined: Sun Dec 25, 2011 5:13 pm
Re: Platformer
can i make that rectangle an object?
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Platformer
That rectangle? No.
You can use love.physics.newWorld, love.physics.newBody and [wiki]love.physics.newRectangleShape[wiki]. If you're using love.physics, you need to do all drawing yourself.
You can use love.physics.newWorld, love.physics.newBody and [wiki]love.physics.newRectangleShape[wiki]. If you're using love.physics, you need to do all drawing yourself.
Help us help you: attach a .love.
Re: Platformer
if you compute the movement like this:
hspeed would be the horizontal speed. you would do the same for player.y and verticlal speed (player.vspeed).
then you can implement some kind of pseudo gravity:
Don't forget to check out the tutorials on the wiki!
Code: Select all
player.x=player.x+player.hspeed
then you can implement some kind of pseudo gravity:
this is basicly acceleration. Change the constant value (2) to something that works well with your game. I don't recommend you to use the physics stuff for a basic (beginner level) plattformer. This is way I'am doing it too.player.vspeed=player.vspeed+2
Don't forget to check out the tutorials on the wiki!
Sry about my english.
Who is online
Users browsing this forum: Google [Bot] and 80 guests