This is a basic implementation of the NES game Bomberman, but it's missing a few things intentionally and they're left as further exploration for the reader.
- Player death
- The player should die when it is hit by an explosion from a bomb
Normie box: | |
sand: 1 | |
cookie: 3 | |
banknote: 1 | |
Meme box: | |
phone: 1 | |
tidepod: 1 | |
fakeid: 1 | |
sand: 1 |
# Definition OF Recusrsion | |
Recursion is a common mathematical and programming concept. It means that a function calls itself. This has the benefit of meaning that you can loop through data to reach a result. | |
The developer should be very careful with recursion as it can be quite easy to slip into writing a function which never terminates, or one that uses excess amounts of memory or processor power. However, when written correctly recursion can be a very efficient and mathematically-elegant approach to programming. | |
In this example, tri_recursion() is a function that we have defined to call itself ("recurse"). We use the k variable as the data, which decrements (-1) every time we recurse. The recursion ends when the condition is not greater than 0 (i.e. when it is 0). | |
To a new developer it can take some time to work out how exactly this works, best way to find out is by testing and modifying it. | |
Here"s An Example Code : | |
def tri_recursion(k): |
import time | |
import threading | |
from pynput.mouse import Button, Controller | |
from pynput.keyboard import Listener, KeyCode | |
delay = 0.001 | |
button = Button.left | |
start_stop_key = KeyCode(char='s') | |
exit_key = KeyCode(char='e') |
<html> | |
<head> | |
<title>Flappy Bird</title> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script> | |
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> | |
<link href='https://fonts.googleapis.com/css?family=Pacifico' rel='stylesheet'> | |
<link href='https://fonts.googleapis.com/css?family=Permanent Marker' rel='stylesheet'> |
# SNAKES GAME | |
# Use ARROW KEYS to play, SPACE BAR for pausing/resuming and Esc Key for exiting | |
import curses | |
from curses import KEY_RIGHT, KEY_LEFT, KEY_UP, KEY_DOWN | |
from random import randint | |
curses.initscr() | |
win = curses.newwin(20, 60, 0, 0) |