Skip to content

Winceg/BISC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Game description

BISC is a fusion between Tron, Bix and splix.io

it's a multiplayer game when your goal is to capture the maximum of territory and avoid to be killed or killed by yourself.

Screenshot menu Screenshot start Screenshot in-game Screenshot game over

User manual

To play BISC

Commands: Player1 : arrow keys, up , down, left, right Player2 : WASD, w=up, s=down, a=left, d=right -> Press enter on the Menu After 3 seconds the game will start

Your Goal ?

  • Capture more terrain than your opponent and avoid dying.

How to capture ?

  • Make a path on the grid , and reach back a territory you already captured. Everything inside the polygon you've draw will be yours !
  • Each square captured is one point, the player to win is the one with the higher score

How to die ? (end the game)

  • Reach out the border
  • Cut your own capturing line
  • Your own capturing line is cut by the other player

Once the game is over , you can see all players scores -> Press enter to go back to the menu -> Press escape to quit the program

Code explanation :

The Arena class

The arena is a grid, an array of arrays, containing values, representing the status of each cell (free, captured by a player, tail of a player, etc.) An arena object is created with the wanted size.

action() function

Each player moves into the arena, by incrementing or decrementing x and y values of his position in the grid:
  • If the player's position gets out of the array, the game is over for him.
  • If the player's position is in a cell that contains his own tail, the game is over for him
  • If the player's position is in a cell containing another player's tail, the game is over for the other player
  • If the player's position corresponds to a cell already captured by himself, it triggers the floodFill() function

floodFill() function

The function runs through the entire array, by moving to the next free cell, which means that it can't go through the perimeter established by the player. Every cell outside the perimeter is set to 0, and then every cell that is not a zero gets turned into the player's ID, as captured.

The Player class

This class contains all the player's attributes :
  • starting position
  • current position: position of the player after having moved
  • last position
  • direction: direction in which the player is moving
  • last direction
  • score: number of captured cells
  • game over: if the player has lost, this value is true

playerMove() function

This function receives the keyboard input, checks if the input is opposite to the direction, and ignores the input if it's the case (otherwise the head hits the tail and the game is over). The function the increments or decrements the x and y values, and check if the next position is within the arena's boundaries.

getScore() function

This function runs through all the cells in the array and counts the cells containing the player's ID.

startDirection() function

Checks if the starting position is in the left or right side of the arena and determines in which direction the first movement will be.

The GameDisplay class

The GameDisplay Class is the Class who will generate all Graphical content of the game based on all the data we've in the other classes.

Once Created , the Arena Array is cropped to be used and drawed later. All Color and font are declared and a new Fungraphic Instance is created.

gamePaintClock, is the method called every frame to redraw the entire arena , based on the values of the Arena.grid Array. It also draw the black separation lines. (note: it can be optimized to avoid flickering). Its basicly a loop that take the array , amplify with a choosen factor, and draw a grid of the right dimension , the size depends of the choosen factor.

menuScreen, pauseScreen, launchScreen and gameOverScreen , are methods used and called whenever we need to display each specific state of the game.

The KeyboardInput class

This class is responsible for listening to the keyboard inputs and returning the direction to each player.

Main

At first, the Arena object is created, with the desired size (only one value, the arena is always a square). Then a new GameDisplay object is created : this object is responsible for the graphic part. A mainKeyboard object is created : this object will listen to keyboard inputs not related to a specific player. The players are now created, with their ID, starting position, and a keyboard listener.

Main loop

As long as we want to play, we stay in that loop. The menu is displayed, followed by th launching sequence.

Game loop

As long as no player has made a terrible mistake, we stay in this loop.
Player loop
This code is where the main action of the game happens, and it loops through the array of players : for each player, the following actions are executed :
  • displaying the grid
  • getting the player's last direction and his keyboard input
  • make the player move
  • executing the action based on the position of the player and the content of the cell
    • floodFill if the player closes his perimeter
    • game over if he hits his own tail
    • game over for the other player if he hits the other player's tail
    • sets the tail of the player (cells that are not yet captured)
Game over loop
This loop checks through the array of players if one or more are game over.

Game over screen

A for loop checks which player has won (which player has not gameOver = true), and then the scores and winner are displayed on the screen. If the "enter" key is pressed, a new game is started. If the "esc" key is pressed, we exit the game.

Resetting

The grid and the player are reset to the starting values, in order to start a new game.

About

Programmation project, grid-based game

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •