Tank Game - Tech Demo

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Ensayia
Party member
Posts: 399
Joined: Sat Jun 12, 2010 7:57 pm

Tank Game - Tech Demo

Post by Ensayia »

Here's a game I'm recreating from an old Game Maker project. I was heavily into Game Maker before I learned how wonderful and easy both Lua and LOVE are. I spent hours tweaking and refining code to make sure all of the collision, physics, and grapple features are working properly.

My request of you: Do everything you can to get yourself stuck, break the grappling, fall out of the level, or anything else that seems you should not be able to do it. I can't find any issues myself after much testing so hopefully you guys will try something I did not think of. I want to make sure these core mechanics are solid before I move on.

Have fun!

Controls:
- WADS or Arrows to move
- Left click to shoot
- Right click to grapple (a total of 3 clicks)
- E to open the editor (instructions in game)

UPDATE 9:
- Physics and collision tweaks.
- Level editor! Press E to invoke.
- Platform graphics now drawn with a spritebatch.

Previous Updates:

Code: Select all

UPDATE 8:
          - Collision and physics completely reworked. Issues now are minimal to 
            non-existant. A super big thanks to TechnoCat for some 1 on 1 testing and 
            debugging.
          - Player movement and physics now correctly and fully framerate independent.
          - New level to play around in. Climb all the way to the top (it's not that hard)!
          - Press R to reload the game at any time.

UPDATE 7:
          - Collision detection is better than it has ever been.
          - Movement is now correctly based on dt. Maximum dt is capped to prevent 
            oddities.
          - Changed the shape of the arena. 
          - New color scheme, just for the hell of it.

UPDATE 6:
          - Physics and collision tweaked yet again.
          - Player can once again grapple everywhere. I changed it back because more
            people prefer it.
          - Camera movement now implemented, camera tracks player by default. Thanks
            to Taehl for the help.
          - Bullets now fire properly from the end of the gun instead of the player coods.
            Thanks slime73 and SoggyWaffles!
          - A proof of concept enemy has been added (I'm aware that it can be killed 
            before it pops up).
          - Commented code! It might help people who look at my code...

UPDATE 5:
          - Fixed the collision yet again. I think I have it fixed once and for all.
          - Player now has a limited grappling distance. An indicator is shown when you begin 
            grappling.
          - Player can now only grapple to specific grapple points.
          - Physics are less bouncy when colliding with the side of a platform.

UPDATE 4:
          - I foolishly took something out at the last moment which broke velocity based 
            movement and made platforms sticky on rare occasion. Fixed now.

UPDATE 3:
          - Reworked collision detection, I have not managed to get stuck once in this newer
            version. Big thanks to Kraftman for giving me a few ideas.
          - Game now operates on dt, instead of relying on vsync. Slightly better physics due to 
            this, I tweaked them a lot.

UPDATE 2:
          - Momentum is now preserved when driving off a cliff. This has a better feel than
            falling straight down.
          - Player can no longer move after the grappling sequence has started.

UPDATE 1:
          - Fixed odd bullet issues by using a few conditional checks before the normal is 
            calculated for direction.
          - Fixed an issue where the player could possibly get stuck in a wall.
Attachments
tank.love
UPDATE 9
(46.8 KiB) Downloaded 606 times
Last edited by Ensayia on Thu Aug 04, 2011 3:22 am, edited 12 times in total.
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Milwaukee, WI
Contact:

Re: Tank Game - Tech Demo

Post by TechnoCat »

Go into the bottom-left corner, right click on the ceiling as fast as you can. You'll bounce up as expected, but then shoot downward mid-air.

EDIT: Actually, it is just mid-air collisions with any wall that bounces you down like that.

EDIT2: move the cursor left and right of the tank so the turret whips out instantly. If it is changing directions while shooting the bullets move very slow. Actually, just having the cursor near the center of the tank shoots almost stopped bullets.
Last edited by TechnoCat on Sat Jul 16, 2011 9:51 pm, edited 1 time in total.
User avatar
Ensayia
Party member
Posts: 399
Joined: Sat Jun 12, 2010 7:57 pm

Re: Tank Game - Tech Demo

Post by Ensayia »

I see what happened. You are shooting down because of some collision code trickery that I did. When you collide with the side of a platform it gives the player a little bit of downward velocity to keep the player from bumping the platform in rapid succession and staying in the air. Now that I changed it so you can no longer move in the air I will probably remove that bit of code, thus fixing the issue.

Thanks for the feedback! It's things like this that I don't catch.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Tank Game - Tech Demo

Post by Robin »

I managed to get stuck in the right wall by using the grappling hook on the left wall and the ceiling. The tank bounced against the platform and penetrated the wall. I got out by driving to the right for a while, curiously enough.
Help us help you: attach a .love.
User avatar
Ensayia
Party member
Posts: 399
Joined: Sat Jun 12, 2010 7:57 pm

Re: Tank Game - Tech Demo

Post by Ensayia »

TechnoCat wrote: EDIT2: move the cursor left and right of the tank so the turret whips out instantly. If it is changing directions while shooting the bullets move very slow. Actually, just having the cursor near the center of the tank shoots almost stopped bullets.
This has been fixed. It was an issue with how I calculated normals for direction, I added in some checks to the mouse coordinates before I calculate now.

Robin wrote:I managed to get stuck in the right wall by using the grappling hook on the left wall and the ceiling. The tank bounced against the platform and penetrated the wall. I got out by driving to the right for a while, curiously enough.
I believe I have fixed this as well. I encountered the issue a while back so I know what causes it and tweaked the collision code to fix it.
User avatar
Lafolie
Inner party member
Posts: 809
Joined: Tue Apr 05, 2011 2:59 pm
Location: SR388
Contact:

Re: Tank Game - Tech Demo

Post by Lafolie »

I would add a check to prevent clicking on the same spot twice so that the grapple hooks are attached to the same point. I played around just doing that which has got to take some fun/point out of the grapple mechanic. Basically, I didn't move the mouse after setting the first one, just 3 clicks send you flying in the specific direction which seems to me against the idea of the slingshot system thing you have going.
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Tank Game - Tech Demo

Post by Jasoco »

I notice when you fall off the cliff, the momentum stops pretty quickly and you fall straight down shortly after leaving the cliff. Wouldn't it be better to have the momentum fall more gradually so you continue moving forward only slightly slower? So when you hit the ground, you can continue moving at the same speed you were moving through the air horizontally instead of coming to a halt? Or is this more for realism as if the tank really is heavy and thus will have much quicker slowdown and harder start from stop? The other way would be more "game like".
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Milwaukee, WI
Contact:

Re: Tank Game - Tech Demo

Post by TechnoCat »

Jasoco wrote:I notice when you fall off the cliff, the momentum stops pretty quickly and you fall straight down shortly after leaving the cliff. Wouldn't it be better to have the momentum fall more gradually so you continue moving forward only slightly slower?
I'm pretty sure this is a fault of assuming the tank never left the ground and friction being applied mid-air.
Grassi
Prole
Posts: 8
Joined: Wed Jul 13, 2011 2:23 am

Re: Tank Game - Tech Demo

Post by Grassi »

When you grapple yourself into a wall you lose momentum and bounce back into the exact same spot as you started from, if you kept the momentum but changed the angle to represent a bounce it might add more realism and also if the bullets stopped when they hit one of the walls instead of continuing through them, giving the impression of solidity.
User avatar
Ensayia
Party member
Posts: 399
Joined: Sat Jun 12, 2010 7:57 pm

Re: Tank Game - Tech Demo

Post by Ensayia »

Jasoco wrote:I notice when you fall off the cliff, the momentum stops pretty quickly and you fall straight down shortly after leaving the cliff. Wouldn't it be better to have the momentum fall more gradually so you continue moving forward only slightly slower? So when you hit the ground, you can continue moving at the same speed you were moving through the air horizontally instead of coming to a halt? Or is this more for realism as if the tank really is heavy and thus will have much quicker slowdown and harder start from stop? The other way would be more "game like".
I tried a few things, and I ended up tweaking it so momentum is preserved when you drive off of a platform. Give it a try now.
Also, you can use the arrow keys ! :crazy:
TechnoCat wrote:I'm pretty sure this is a fault of assuming the tank never left the ground and friction being applied mid-air.
You were absolutely right. That's exactly what I tweaked.
Grassi wrote:When you grapple yourself into a wall you lose momentum and bounce back into the exact same spot as you started from, if you kept the momentum but changed the angle to represent a bounce it might add more realism and also if the bullets stopped when they hit one of the walls instead of continuing through them, giving the impression of solidity.
I'm not 100% sure what you are trying to say. Perhaps you or someone else can clarify?
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 2 guests