I need help with collision

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Bikings
Prole
Posts: 3
Joined: Wed May 31, 2017 3:03 am

I need help with collision

Post by Bikings » Wed May 31, 2017 3:15 am

I'm making a little basic test game with a player and an enemy. I want the game to function so that when the enemy collides with the player, the player gets a GAME OVER screen. Does anyone know how to help?

User avatar
Jasoco
Inner party member
Posts: 3622
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: I need help with collision

Post by Jasoco » Wed May 31, 2017 4:13 am

Welcome! How good are you currently with coding? Do you know Lua or any languages?

You might want to look into some helper libraries like Bump (Which does collision and resolution with simple AABB rectangular boxes (No angled boxes or odd shapes) or HardonCollider. (Which does collision, but not resolution, between objects of many shapes including polygons and rotated shapes.

Resolution is what happens when something, say the player, collides with something else solid, say a wall. What happens in that case is the player is not able to overlap with the wall. Bump's resolution can make it so this happens and will do it for you automatically if used correctly. HardonCollider wouldn't perform any resolution so you can't have shapes automatically prevent overlapping like you can with Bump.

Then there's Löve's built-in Box2D which is more complicated to learn but can be powerful depending on the game. But it can take a lot of trial and error and variable tweaking to get it to work just the way you want.

In simple terms, you'd check for a collision between the player and the enemy every frame in the update, and when one happens, change the state of the game to a Game Over failure state.

User avatar
Bikings
Prole
Posts: 3
Joined: Wed May 31, 2017 3:03 am

Re: I need help with collision

Post by Bikings » Wed May 31, 2017 10:47 am

I know a little bit about lua

User avatar
OnACoffeeBreak
Prole
Posts: 28
Joined: Tue Apr 11, 2017 11:19 am

Re: I need help with collision

Post by OnACoffeeBreak » Wed May 31, 2017 10:55 am

Try going through some tutorials. I started with this one (http://sheepolution.com/learn/book/contents). It has a good gentle introduction to Lua and Löve.

User avatar
Bikings
Prole
Posts: 3
Joined: Wed May 31, 2017 3:03 am

Re: I need help with collision

Post by Bikings » Wed May 31, 2017 4:02 pm

Nevermind. I changed the circles to the rectangles so the collision was easier. Thanks for the help anyways

Post Reply

Who is online

Users browsing this forum: No registered users and 18 guests