Squario: A squary survival horror

Show off your games, demos and other (playable) creations.
User avatar
ZenX2
Citizen
Posts: 89
Joined: Wed Nov 17, 2010 5:35 am

Re: Squario: The squariest platformer in LOVE.

Post by ZenX2 »

Argh, so close.
Anyways, passing self as the first argument doesn't work :|
User avatar
Mud
Citizen
Posts: 98
Joined: Fri Nov 05, 2010 4:54 am

Re: Squario: The squariest platformer in LOVE.

Post by Mud »

ZenX2 wrote:Argh, so close.
Anyways, passing self as the first argument doesn't work :|
Erm, you can have the version I played with last night. The only change was to drop in my class library (because I didn't feel like debugging the one you had) and fixing the superclass method calls. This got Mr. Squario to fall, at least.

Full diff (old => new):

Code: Select all

self.super:__init(p, 32, 32, 0, 0)   => self.super.__init(self, p, 32, 32, 0, 0)  
self.super:__init(p, 32, 32, 50, 0)  => self.super.__init(self, p, 32, 32, 50, 0) 
self.super:Think()                   => self.super.Think(self)                    
class.Color()                        => Color = class()                           
class.Ent()                          => Ent = class()                             
class.Ground()                       => Ground = class()                          
class.GroundPiece(Ent)               => GroundPiece = class(Ent)                  
class.Image()                        => Image = class()                           
class.Player(Ent)                    => Player = class(Ent)                       
class.Stack()                        => Stack = class()                           
class.Vec2()                         => Vec2 = class()                            
class.Vector()                       => Vector = class()                          
class.World()                        => World = class()                           
Attachments
squario.love
(11.37 KiB) Downloaded 92 times
User avatar
ZenX2
Citizen
Posts: 89
Joined: Wed Nov 17, 2010 5:35 am

Re: Squario: The squariest platformer in LOVE.

Post by ZenX2 »

Oh, cool. Now I'll have to frankenstine my library.
User avatar
ZenX2
Citizen
Posts: 89
Joined: Wed Nov 17, 2010 5:35 am

Re: Squario: The squariest platformer in LOVE.

Post by ZenX2 »

Uploaded a version where Squario will fall, but he doesn't collide with the ground...
And new graphics :3
The round thing's pending name is rolly, for obvious reasons. When I implement AI, he'll roll at you and kill you.
User avatar
zac352
Party member
Posts: 496
Joined: Sat Aug 28, 2010 8:13 pm
Location: In your head.
Contact:

Re: Squario: The squariest platformer in LOVE.

Post by zac352 »

Image
*stare*
Hello, I am not dead.
User avatar
ZenX2
Citizen
Posts: 89
Joined: Wed Nov 17, 2010 5:35 am

Re: Squario: The squariest platformer in LOVE.

Post by ZenX2 »

I've messed with the ground code, and it turns out the graphics are offset and the ground has holes.
User avatar
Mud
Citizen
Posts: 98
Joined: Fri Nov 05, 2010 4:54 am

Re: Squario: The squariest platformer in LOVE.

Post by Mud »

ZenX2 wrote:I've messed with the ground code, and it turns out the graphics are offset and the ground has holes.
Well, since you were feeling so discouraged, I took a look at it (while waiting for Ubunto to download).

Biggest problem:

self.body = love.physics.newBody(GetWorld(), p.x, p.y, m, i)
self.shape = love.physics.newRectangleShape(self.body, p.x, p.x, w, h, i )

The x,y parameters in the Shape constructor are offsets from the Body position, so you were offsetting the Shape from the Body by large amounts. Since (1) the Shape is used for collision detection, (2) your ground and player Shapes were offset into the boonies, (3) you were drawing the sprites at the Body position and not the Shape position -- it looked like squario was falling through the ground (in reality the ground, for collisions purposes, was quite a ways off screen).

Shape:getBoundingBox() would have shown you this. I added a DrawBoundingBox function to your Ent class for future debugging.

Other issues:
  • You use the Body x,y for drawing your sprite, which is fine, but graphics.draw is going to put the top-left corner of your sprite there, so you need to manually offset the sprite to center it on the body position. Alternatively, you could use shape:getBoundingBox to get the top left corner of the Shape and pass that to graphics.draw (I did the former).
  • applyForce is appropriate for use on every tick, applyImpulse is not. I left the applyForce calls in your Ent:Think function, but moved the applyImpulse calls into an OnKeyPressed handler which I added to the Player class. I kinda guessed at your intent here, and used applyImpulse only for jumping.
I also removed squario's friction so he can walk along the ground more naturally.

A remaining issue is that you create your ground out of 20 separate Shapes, and although they theoretically should create a perfectly smooth surface (given that they're all squares and positioned at exactly the same y coordinate), squario occasionally catches on the corner of one when he's sliding along. I'm guessing that's something you'll just have to work around by creating a large rectangle Shape for the ground independent of the sprites you use to draw it.
Attachments
squario.love
(10.76 KiB) Downloaded 108 times
User avatar
ZenX2
Citizen
Posts: 89
Joined: Wed Nov 17, 2010 5:35 am

Re: Squario: A squary survival horror

Post by ZenX2 »

I feel enlightened. I knew that the sprite's position needed to be offset, but I was unaware about the x and y of the shape being an offset. Hopefully, this might help people in the future so they don't need to deal with love.physics directly.
User avatar
ZenX2
Citizen
Posts: 89
Joined: Wed Nov 17, 2010 5:35 am

Re: Squario: A squary survival horror

Post by ZenX2 »

Alright, I got bored and decided to work a bit on this. I figured out most of the problems, fixed the ground code, and threw in a bit of code that lets you create/destroy pieces of ground, just for fun :awesome:

If you create lots of entities, it hits your fps a bit, but the drawing code is already as optimized as I know how to make it.
Attachments
squario.love
(11.76 KiB) Downloaded 101 times
Post Reply

Who is online

Users browsing this forum: Hydrogen Maniac and 151 guests