Hello LÖVE-users!
I need help with some shooting in a zombie game me and a friend of mine made (with alot of help from LÖVE user schme16)
Basically we just need help with the shooting in the game!
I've made the graphics and my friend the music.
We've both been coding but we just cant seem to get the shooting to work!
We want so that when you shoot 2-3 bullets on the zombie it dies and you get +1 score or something.
So if anyone can help us without changing the code too much, we would love you long time!
Here is how the game looks:
We need help ASAP.
Thank you!
regards, alecal
Shooting collision help needed!
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Shooting collision help needed!
- Attachments
-
- coal4.love
- The game
- (4.15 MiB) Downloaded 100 times
- nevon
- Commander of the Circuloids
- Posts: 938
- Joined: Thu Feb 14, 2008 8:25 pm
- Location: Stockholm, Sweden
- Contact:
Re: Shooting collision help needed!
If I were you, I'd move all the health pickups, the enemy management (this might be its own class, even) and the bullet handling into the level class. That way you don't have to clutter up love.update.
Basically for each frame you'll need to get the bullet's X, Y and Z position and compare it to each zombie's hit-cube. If it's a hit, have the level or the enemy management class subtract N hp, and remove an enemy when their HP is <=0.
Basically for each frame you'll need to get the bullet's X, Y and Z position and compare it to each zombie's hit-cube. If it's a hit, have the level or the enemy management class subtract N hp, and remove an enemy when their HP is <=0.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: Shooting collision help needed!
I think you might be getting a bit confused by your perspective & (very nice!) graphics.
The first thing you need to realize is that your game is actually a 2d game; "depth" and "width" are relevant to gameplay, but "height" is only there for aesthetic purposes. (At least on the screenshot you showed)
What I'm trying to say is that your game can be imagined as happening "on the ground".
Let me illustrate. I'm going to highlight the depth and width of every character and item on the scene you showed (I'm also adding a bullet). Notice how everything has a "footprint" on the ground, with its depth and width.
Those "footprints" are really the only important pieces of your game (collision-wise). In other words, you can imagine your game space like this:
Now it should be simpler to understand how the collision detection might work: You just have to check that the yellow footprint intersects with any green footprints. Incidentally, this can also be used for health pickup detection (player footprint intersects with a mauve footprint) or enemy hitting the player (enemy footprint intersects with player footprint).
This snippet will help you check that two rectangles intersect easily.
If I were you, I'd activate a "debug key" that showed all footprints, at least while developing the game.
Finally, a minor thing: notice that your two zombie footprints are intersecting. This should not happen, it's a perspective error.
The first thing you need to realize is that your game is actually a 2d game; "depth" and "width" are relevant to gameplay, but "height" is only there for aesthetic purposes. (At least on the screenshot you showed)
What I'm trying to say is that your game can be imagined as happening "on the ground".
Let me illustrate. I'm going to highlight the depth and width of every character and item on the scene you showed (I'm also adding a bullet). Notice how everything has a "footprint" on the ground, with its depth and width.
Those "footprints" are really the only important pieces of your game (collision-wise). In other words, you can imagine your game space like this:
Now it should be simpler to understand how the collision detection might work: You just have to check that the yellow footprint intersects with any green footprints. Incidentally, this can also be used for health pickup detection (player footprint intersects with a mauve footprint) or enemy hitting the player (enemy footprint intersects with player footprint).
This snippet will help you check that two rectangles intersect easily.
If I were you, I'd activate a "debug key" that showed all footprints, at least while developing the game.
Finally, a minor thing: notice that your two zombie footprints are intersecting. This should not happen, it's a perspective error.
When I write def I mean function.
Re: Shooting collision help needed!
I like the graphics (maybe because I can't do such nice drawing myself, I am just a programmer). Have you got any help yet? If not, here is my version. Note, I have changed the code (still hope it was not "too much"). Press "d" for debug. Otherwise it works as the original (except some improvements).Alecal wrote:We want so that when you shoot 2-3 bullets on the zombie it dies and you get +1 score or something.
So if anyone can help us without changing the code too much, we would love you long time!
If you need more help, please use english in comments, as I am not able to read scandinavian languages (I don't know which one it was). You may use the code as you wish.
- Attachments
-
- coal4_new.love
- (4.15 MiB) Downloaded 108 times
My lovely code lives at GitHub: http://github.com/miko/Love2d-samples
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot], Semrush [Bot] and 8 guests