So im learning lua - love2D and i have a problem, so i dont know how to make collision, and another thing, when i use key, i need to move the player or the map ?
ps: all my sprites are in a list !
Thanks for answer !
Mario like col problem
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Mario like col problem
There is no built-in collision solution for LOVE, but there are plenty community libraries that work perfectly.
I recommend you take time to learn bump.lua. It's a really useful AABB (rectangular) collision library and is more than enough to have "Mario-like" game play.
I recommend you take time to learn bump.lua. It's a really useful AABB (rectangular) collision library and is more than enough to have "Mario-like" game play.
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
personal page and a raycaster
Re: Mario like col problem
THANKS BROTHER im going to test it !
Re: Mario like col problem
If someone have other idea tell me, more i know, more i traine !
Re: Mario like col problem
Slipeg,
There's an article on Mozilla Developer Network that explains the math behind the simple (Axis Aligned Bounding Box) collision: https://developer.mozilla.org/en-US/doc ... _detection. It also presents some alternatives (circle collision, as well as a way to detect a collision between any polygons), but you're going to want to start with AABB, since it's the simplest and is good enough for most games.
I would second the vote for learning to use the bump library, as it is quite good and has some images that help explain the different ways you might want to respond to a collision. For a mario-like game, you'll mostly want to use the "slide" response to a collision. For a pong-like game, you'll want to use a "bounce" response.
One important thing to keep in mind is that your code is called multiple times a second, but it is not called at every conceivable point in time, so it is unlikely that you will detect the collision at the moment the two objects start touching. Much more likely, the objects will not be touching one time that your code is called and then the next time your code is called they will be slightly overlapping. That's why you have to handle that overlap and decide how to "undo" it so that the objects are no longer overlapping via (slide, bounce, etc). The player won't see the overlap because your code will undo it before it is displayed on the screen.
There's an article on Mozilla Developer Network that explains the math behind the simple (Axis Aligned Bounding Box) collision: https://developer.mozilla.org/en-US/doc ... _detection. It also presents some alternatives (circle collision, as well as a way to detect a collision between any polygons), but you're going to want to start with AABB, since it's the simplest and is good enough for most games.
I would second the vote for learning to use the bump library, as it is quite good and has some images that help explain the different ways you might want to respond to a collision. For a mario-like game, you'll mostly want to use the "slide" response to a collision. For a pong-like game, you'll want to use a "bounce" response.
One important thing to keep in mind is that your code is called multiple times a second, but it is not called at every conceivable point in time, so it is unlikely that you will detect the collision at the moment the two objects start touching. Much more likely, the objects will not be touching one time that your code is called and then the next time your code is called they will be slightly overlapping. That's why you have to handle that overlap and decide how to "undo" it so that the objects are no longer overlapping via (slide, bounce, etc). The player won't see the overlap because your code will undo it before it is displayed on the screen.
Re: Mario like col problem
Slipeg, I'm not sure if you've seen it yet, but this tutorial might be helpful if you want to get started quickly: http://osmstudios.com/tutorials/your-fi ... art-1-of-3. If you're looking for a way to animate your sprite, you may want to look at: https://github.com/kikito/anim8.
> when i use key, i need to move the player or the map ?
Typically, the player object will have x and y properties and you'll want to change these to move the player. However, if your map is larger than the screen, things get more complicated when the player gets near the edge of a map and you want the map to appear to move -- but a better way of thinking about it is that the map is staying in the same place and there is a "camera" that has begun to move and is tracking with the player. There is a nice library, gamera, that does this for you -- you can read about it and how to use it here: https://github.com/kikito/gamera
> when i use key, i need to move the player or the map ?
Typically, the player object will have x and y properties and you'll want to change these to move the player. However, if your map is larger than the screen, things get more complicated when the player gets near the edge of a map and you want the map to appear to move -- but a better way of thinking about it is that the map is staying in the same place and there is a "camera" that has begun to move and is tracking with the player. There is a nice library, gamera, that does this for you -- you can read about it and how to use it here: https://github.com/kikito/gamera
Re: Mario like col problem
Thanks for the awesome answer, im new in the beautiful world of coding ! thanks for this, this is really helpful !
- Jasoco
- Inner party member
- Posts: 3726
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Mario like col problem
Bump will really help with getting you started. It can be used for anything. From a side-scroller to a top-down Zelda or RPG to a Breakout or Pong clone. The way it makes it super simple to detect and deal with collisions makes it perfect for most projects.
It can't do slopes though. Which shouldn't be a big deal for most projects.
It can't do slopes though. Which shouldn't be a big deal for most projects.
Re: Mario like col problem
Just leaving this link here: http://hc.readthedocs.io/en/latest/
It lets you create your own collision manager very easily. Needless to say that bump does more work for you, resolving overlaps automatically.
That being said, I find it very usefull if you need to make triggers for events
Good luck!
It lets you create your own collision manager very easily. Needless to say that bump does more work for you, resolving overlaps automatically.
That being said, I find it very usefull if you need to make triggers for events
Good luck!
- ken.athomos
- Citizen
- Posts: 77
- Joined: Fri Aug 05, 2016 10:13 am
- Location: Philippines
Re: Mario like col problem
If you don't mind, I would like to give some input on this as well
I'll try to segregate and enumerate stuff so that you could have a basis and all that fun stuff
If you are aiming for doing a Mario-like game, you should try your best to understand the following:
Or I be a sellout and do a shameless plug by suggesting you to also read my Baseline 2D Tutorial.
Hope all of these helps
I'll try to segregate and enumerate stuff so that you could have a basis and all that fun stuff
If you are aiming for doing a Mario-like game, you should try your best to understand the following:
- Basic Entity Elements - When I say entity I'm talking about any character within the game. For example your player character or the enemies on the screen. The elements are the characteristics of your character. I suggest focusing on basic stuff like how high can he/she jump, how fast he/she can walk, how much damage he can take, all that fun stuff.
- Character Movement - This includes how to make a character move left and right, and jump using key presses.
- Basic 2D Physics - Please don't be intimidated. I'm really pertaining to super basic stuff. For example, when a character jumps, he obviously falls down due to gravity. Those stuff. (Not those solve the angle of the object, get it's possible travel speed - save those for the more advance projects).
Or I be a sellout and do a shameless plug by suggesting you to also read my Baseline 2D Tutorial.
- 2D Collisions Concept -This is about when stuff overlaps or "touches" each other. As Davidobot said, sadly, LOVE has no built-in 2D Collision Solution. You either [1]have to do implement it yourself. As many of them suggested, AABB (Axis-Aligned Bounding Box) is a good way to start. [2]Or as all of them suggested, have a look at Bump. This uses AABB Collisions.
- 2D Collision Detection and Response - Now that you know the concept of 2D Collisions, it's time to learn detection and response. A detection is what it sounds like. It detection if two objects are colliding. A response tells what the game should do if those objects are colliding. You either [1]implement this yourself or [2]look at Bump.lua.
- Camera - As far as I know, by default, LOVE2D does not have a built-in Camera Solution. This means that by default, there is no "camera" (someone please correct me on this) and that by default, the only visible thing in the game, is the initial starting screen and all the stuff you've put there. So again, you have to either [1] do it yourself or [2]have a look at either Gamera or Hump.
Hope all of these helps
Who is online
Users browsing this forum: No registered users and 2 guests