Results 1 to 10 of 10

Thread: Popped

  1. #1

    Popped

    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

  2. #2
    PGDCE Developer Carver413's Avatar
    Join Date
    Jun 2010
    Location
    Spokane,WA,Usa
    Posts
    206
    sound's like a fun game Paul

  3. #3
    Thanks
    I have done bugger all so far, so we will see! haha

  4. #4
    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:

    Code:
    |\       __
    |_\      \ |
              \|
    ___
    | /       /|
    |/       /_|
    Here is a screenshot (includes gravity vector when tilting world) which shows the sloped tiles as well as the square tiles:



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

    Code:
    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

  5. #5
    You should do line to circle colision detection for this. http://stackoverflow.com/a/1079478

  6. #6
    Quote Originally Posted by SilverWarior View Post
    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

  7. #7
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25
    Nifty! This one should turn out interesting.
    Jason McMillen
    Pascal Game Development
    Co-Founder





  8. #8
    Quote Originally Posted by WILL View Post
    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

  9. #9
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25
    Quote Originally Posted by paul_nicholls View Post
    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?
    Jason McMillen
    Pascal Game Development
    Co-Founder





  10. #10
    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...

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •