Set up an account here on the Bridges app.
(Signup)Locate your username and api key under Profile. You will need these to run your programs.
(Profile)When you run a Bridges program, it will appear under My Projects.
(My Projects)You will need Java version 1.8 running on your machine and your favorite Java IDE
Download the starter project from our git repo. It contains our bridges-games JAR file, and blocking and non-blocking code stubs to get your program moving quickly!
(GITHUB Link)Associate the bridges-games JAR file with your project. If you need help, check out the link below or try googling "add jar to classpath" + your IDE
(BRIDGES IDE setup help)At its core, your game is a simple grid with rows and columns. Each cell in the grid can have a background color, foreground color, and symbol.
You set the background color like this:
gamegrid.setBGColor(int row, int col, NamedColor);
For example, let's set the background color of the top row, third column (note that they are zero-indexed just like arrays!):
gamegrid.setBGColor(0, 2, NamedColor.purple);
You set the symbol like this (note that the final color argument is optional):
gamegrid.drawObject(int row, int col, NamedSymbol, [NamedColor]);
Let's draw a green circle in the 8th row, 5th column:
gamegrid.drawObject(7, 4, NamedSymbol.circle, NamedColor.green);
The blocking game architecture waits until a keypress is registered, performs some game logic, then renders the next state of the game.
Digging into the code:
Note the api key and username arguments in the initialization of the blocking game.
Each time the bg.render() method is called, the current state of the game grid is sent to your browser.
Inside the while loop, we listen for the next keypress and modify the game grid accordingly.
The non-blocking game architecture renders the state of the game continuously. You can examine the current keypresses at every frame.
Digging into the code:
Note the api key and username arguments in the initialization of the non-blocking game.
The initialize() method is called once when you first run your game. Modify the grid object using the setBGColor(..) and drawObject(..) methods described above.
The gameLoop() method is called multiple times per second. Examine the currently-pressed keys using the KeyUp(), KeyDown(), Keyw() methods (etc.) and modify the grid accordingly.
Description and Instructions
Snake is implemented in the non-blocking architecture. Arrow keys change the direction of the snake. Keep eating food to grow the snake, but be careful not to run into yourself!
If you followed the setup instructions above, just add your api key and username to play for yourself.
Learning Outcomes and Scaffolding
This project can be used at a variety of levels depending on what you want students to implement.
Looping
Early CS courses could keep most of the game logic intact and simply remove the nested for() loops for drawing the background each frame.
Conditional Statements
Students in early CS courses could be asked to implement the detectApple() method; the outcome depends on comparing the current position of the snake's head to the position of the food.
Data Structures
Students in second-year CS courses might implement snake using a linked list or queue structure. The detectDeath() and updatePosition() methods require stepping through the pieces of the snake.
Description and Instructions
Bug Stomp is implemented in the non-blocking architecture. Arrow keys change the position of the person. Quickly move to the randomly spawning bugs before they disappear!
If you followed the setup instructions above, just add your api key and username to play for yourself.
Learning Outcomes and Scaffolding
This project is fairly simple. It primarily involves loops, random number generation, and conditional comparisons.
Looping
Early CS courses could require students implement the for() loops for drawing the background each frame.
Conditional Statements
Students in early CS courses could be asked to implement the handleInput() method to update the current (row, column) position of the person based on the current keypresses.
Random Number Generating (and OOP)
Students could be asked to write the code to spawn a new bug at a random location in the grid with a random time duration. (This could be abstracted into a new Bug object with attributes and methods for an extra challenge).
Description and Instructions
Minesweeper is implemented in the blocking architecture. Arrow keys change the position of the current selection, 'space' exposes the current cell, and 'f' places a flag at a suspected mine location.
If you followed the setup instructions above, just add your api key and username to play for yourself.
Learning Outcomes and Scaffolding
This project is more complex due to the multiple cell states (mine, visited, unvisited, flagged, etc) and the trickier logic for maintaining the board symbols and colors.
Looping, Random Number Generating
Early CS courses could require students to implement the setupMines() and highlightMines() methods, which require nested for() loops and random number generation.
Conditional Statements
Students in earlier CS courses could implement the logic for counting the number of mines in cells adjacent to the current selection. These can be hard-coded conditional statements that must observe the dimensions of the grid.
Recursion
Intermediate students can implement the visitCell method, which recursively visits cells surrounding the current selection until a non-zero number of adjacent mines are found.