Game Development Community

Best way to emulate a "Contra" movement style?

by Adam Johnston · in Torque Game Builder · 10/04/2005 (4:30 pm) · 3 replies

Hi everyone, this is part of my questions in the way to do a platform game
Mario + Contra like :) Hope somebody could give me tips...

1) I want that my player would be able to walk in the first half of the screen
he can't go back, but he can go ahead, whenever he touch the invisible limit
of the half screen the tilemap must to move, showing more of the scenery,
if he goes back the tilemap doesn't move with he and the player can only reach
the other side of the screen and can't go back, I don't know if this is clear...
If you have played Contra you could understand me.
-------------------------------------------------



   space to move
<------------------------>


    O
    |
    A                          
-------------------------------------------------
Actually I have mounted the camera to the player
but it doesn't work like I wanted

sceneWindow2D.mount ($player, "0 0", 0);

I don't want the camera moving when the player jumps
and that the player would be always in the center or
in a fix position in the screen....

Sure you guys with more experience in T2D could
enlight me.

#1
10/04/2005 (5:55 pm)
You could keep an invisible point that is always at the same 'Y' coordinate, but the 'X' coordinate can be updated from wherever the player is currently at. Then, when you update this value, you can only update it if the new value is larger than the old value (so that you can't scroll backward). Then you can mount the camera to this point.

There may be cleaner ways in T2D (I'm still new with the engine), but this sounds fairly resonable/straightforward.
#2
10/04/2005 (7:09 pm)
Hmm, you could run a scheduled event that adjusts the camera and character limits based on where the character currently is in the world.

First mount the camera to the player
Then call 'setViewLimit' with the proper perameters to keep the camera within the world boundries


Call a function like this about once every 60th of a second

function adjustWorldLimits()
{
  %characterPos = playerSprite.getPositionX();    // Check the player's X postion
 
  %newXMin = %characterPos - ($GlobalCameraWidth / 2);  //subtract half of your screen width from the players x position
 
  if (%newXMin > $GlobalXMin)  //check to see if the new x minimum is greater than the old x minimum
  {
    $GlobalXMin = %newXMin;

    t2dScene.setViewLimit( $GlobalXMin SPC $GlobalYMin SPC $GlobalXMax SPC $GlobalYMax );  // reset the camera limits
    playerSprite.setWorldLimit( clamp, $GlobalXMin SPC $GlobalYMin SPC $GlobalXMax SPC $GlobalYMax );  // reset the player limits
  }
}
At least I think that should work... I haven't messed with T2D in awhile, due to time constraints and other projects.

*edited to make a bit more sense, I hope*
#3
10/18/2005 (11:51 am)
@Joshua: I couldn't test your idea but thank you!

@Joe: your idea was my first attempt and it worked fine, thank you very much.