PDA

View Full Version : Popped

paul_nicholls
07-09-2013, 11:37 PM
I know it's a very last minute thing, but I've started my entry for the compo...it's called "Popped". It's going to be a tilt the world game to guide a bubble around the world past hazards and stuff trying not to get popped.

cheers,
Paul

Carver413
08-09-2013, 05:23 AM
sound's like a fun game Paul

paul_nicholls
08-09-2013, 06:17 AM
Thanks :)
I have done bugger all so far, so we will see! haha

paul_nicholls
11-09-2013, 09:14 AM
I have a collision question for in my game if anyone can help?

I want to stop the circle (bubble) when it hits a sloped tile (45 degrees) moving either up / down / left / right. I can do square tiles, but not sure how to do sloped:

|\ __
|_\ \ |
\|
___
| / /|
|/ /_|

Here is a screenshot (includes gravity vector when tilting world) which shows the sloped tiles as well as the square tiles:

http://img23.imageshack.us/img23/1883/gseu.png (http://imageshack.us/photo/my-images/23/gseu.png/)

This is my collision code for square tiles which I hope to add sloped tiles to:

var
Corners: SpriteCorners := new SpriteCorners;

method PoppedApp.GetBubbleCorners(aOfsX,aOfsY: Single): SpriteCorners;
begin
// calculate tile index for each object corner
Corners.Left := FLevel.getTileX(FBubble.pos.x - FBubble.radius + aOfsX);
Corners.Right := FLevel.getTileX(FBubble.pos.x + FBubble.radius - 0.001 + aOfsX);
Corners.Up := FLevel.getTileY(FBubble.pos.y - FBubble.radius + aOfsY);
Corners.Down := FLevel.getTileY(FBubble.pos.y + FBubble.radius - 0.001 + aOfsY);

// if true then there is a wall there
Corners.WallUL := FLevel.wallAt(Corners.Left ,Corners.Up);
Corners.WallUR := FLevel.wallAt(Corners.Right ,Corners.Up);
Corners.WallDL := FLevel.wallAt(Corners.Left ,Corners.Down);
Corners.WallDR := FLevel.wallAt(Corners.Right ,Corners.Down);

Result := Corners;
end;

method PoppedApp.MoveBubble(aTimeSlice: Single);
var
cnr: SpriteCorners;
begin
cnr := GetBubbleCorners(0,FBubble.vel.y*aTimeSlice);

if FBubble.vel.y < 0 then
// moving up
begin
if not cnr.WallUL and not cnr.WallUR then
// not obstructed so move normally
FBubble.pos.y := FBubble.pos.y + FBubble.vel.y * aTimeSlice
else
// hit tile so move to edge of tile and stop
begin
FBubble.vel.y := 0;
FBubble.pos.y := cnr.Up * cTileSize + cTileSize + FBubble.radius;
end;
end
else
if FBubble.vel.y > 0 then
// moving down
begin
if not cnr.WallDL and not cnr.WallDR then
// not obstructed so move normally
FBubble.pos.y := FBubble.pos.y + FBubble.vel.y * aTimeSlice
else
// hit tile so move to edge of tile and stop
begin
FBubble.vel.y := 0;
FBubble.pos.y := cnr.Down * cTileSize - FBubble.radius;
end;
end;

cnr := GetBubbleCorners(FBubble.vel.x*aTimeSlice,0);

if FBubble.vel.x < 0 then
// moving left
begin
if not cnr.WallUL and not cnr.WallDL then
// not obstructed so move normally
FBubble.pos.x := FBubble.pos.x + FBubble.vel.x * aTimeSlice
else
// hit tile so move to edge of tile and stop
begin
FBubble.vel.x := 0;
FBubble.pos.x := cnr.Left * cTileSize + cTileSize + FBubble.radius;
end;
end
else
if FBubble.vel.x > 0 then
// moving right
begin
if not cnr.WallUR and not cnr.WallDR then
// not obstructed so move normally
FBubble.pos.x := FBubble.pos.x + FBubble.vel.x * aTimeSlice
else
// hit tile so move to edge of tile and stop
begin
FBubble.vel.x := 0;
FBubble.pos.x := cnr.Right * cTileSize - FBubble.radius;
end;
end;

// apply gravity
FBubble.vel.x := FBubble.vel.x + FGravityX * aTimeSlice;
FBubble.vel.y := FBubble.vel.y + FGravityY * aTimeSlice;

// don't allow bubble to move faster than maximum velocity
if FBubble.vel.VecLen > cMaxVel then
begin
var m : Single := FBubble.vel.VecLen;
FBubble.vel.SetValue(FBubble.vel.x * cMaxVel / m,FBubble.vel.y * cMaxVel / m);
end;
end;

cheers,
Paul

SilverWarior
11-09-2013, 11:31 AM
You should do line to circle colision detection for this. http://stackoverflow.com/a/1079478

paul_nicholls
11-09-2013, 12:14 PM
You should do line to circle colision detection for this. http://stackoverflow.com/a/1079478

Thanks mate, I will take a look at it :)

cheers,
Paul

WILL
12-09-2013, 10:32 AM
Nifty! This one should turn out interesting.

paul_nicholls
12-09-2013, 11:10 AM
Nifty! This one should turn out interesting.

Unfortunately it looks like I definitely won't make the deadline...it is already the 12th here in Tasmania, and I just started 4 night shifts tonight, so I won't be doing anymore programming it seems till the 16th :(

WILL
15-09-2013, 08:52 PM
Unfortunately it looks like I definitely won't make the deadline...it is already the 12th here in Tasmania, and I just started 4 night shifts tonight, so I won't be doing anymore programming it seems till the 16th :(

Really? Wow, that "16th" looks a lot like a "15" wow, I'm having a hard time seeing numbers for some reason. Geez. I sure hope I don't have this problem tomorrow when I go to shut down the FTP server. I'm just not sure if I'll remember to shut down the server after the 15th... I dunno strange stuff always seems to happen at the end of these things. Just might have to see huh? :P

paul_nicholls
01-10-2013, 12:50 PM
Hi all, just so you know I did upload my entry to the FTP site, but all it does is allow you to tilt the world using the left/right cursor keys to guide your bubble as it falls due to gravity.
The sloped tiles don't work yet (hidden edges), and nothing else is added.

You have to run the Popped.jar file after extracting it from the zip file (create a folder first)...

At least I figured out how to tilt the world and do the gravity bit lol!

I might work on it later on though...