Points accrued while crossing obstaclesĪt the end of the game (after both the players either die or reach other ‘END’), the players are respawned to their starting position.Your aim is to make players reach the other end of the river. Only one player is playing at a given point of time. As player crosses moving obstacle successfully, accrues 10 points and for crossing fixed obstacles 5 points. Player dies once he/she touches any obstacle. The player can move up, down, left and right using the up, down, left and right keys respectively. The moving obstacles move from left to right. The player starts from the ‘START’ partition and must reach the ‘END’ position for player 1 and the ‘END’ becomes ‘START’, ‘START’ becomes ‘END’ for Player 2. There are two kinds of obstacles, moving and fixed. A player is safe when it is standing on a partition/slab. There are 2 players in the game, one at Top and another at Bottom (2 sides of the river bank). The playing arena of game consists of a river with some partitions in it. The RIVER CROSSING GAME is a simple two-player game built by using pygame in python. Now, run the following commands in your terminal in order to run the game in your system: Make sure that your system has the version of python>=3. Return coords - box_origin + CROSSING GAME Run the game in your system # move the coordinates so that 0, 0 is the box's position If player_coords.y - box_origin.y > BOX_HEIGHT:īox_origin.y = player_coords.y - BOX_HEIGHTĮlif box_origin.y - player_coords.y > BOX_HEIGHT:īox_origin.y = player_coords.y + BOX_HEIGHT If player_coords.x - box_origin.x > BOX_WIDTH:īox_origin.x = player_coords.x - BOX_WIDTHĮlif box_origin.x - player_coords.x > BOX_WIDTH:īox_origin.x = player_coords.x + BOX_WIDTH Pseudo code (not tested for negative coordinates): BOX_WIDTH = 320 Then you update the center of the box such that if the player leaves the box, the box will move along with him (thus moving the camera). To expand on this so that it's not absolutely positioned on the player, you can instead center the window upon a box. # then move the origin to the center of the window # move the coordinates so that 0, 0 is the player's position In my own game, I use a function to translate coordinates: def to_pygame_coords(coords): A very basic way of getting the camera centered on the player would be to just offset everything you draw so that the player is always in the center of the camera.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |