from game_engine import Game
import time

g = Game(log=True)

# create box in frame
box = g.create_box(4, 4, 10, 10)
g.next_frame(250)

# create box top left
box2 = g.create_box(4, 4, -2, -2)
g.next_frame(250)

# create box top right
box3 = g.create_box(4, 4, g.width - 2, -2)
g.next_frame(250)

# create box bottom left
box4 = g.create_box(4, 4, -2, g.height - 2)
g.next_frame(250)

# create box bottom right
box5 = g.create_box(4, 4, g.width - 2, g.height - 2)
g.next_frame(250)

# create box outside
box6 = g.create_box(4, 4, -10, -10)
g.next_frame(600)

# remove box outside of frame
g.destroy_box(box6)
Exemple #2
0
from game_engine import Game
import random as rd
import subprocess
g = Game(log=True)

dino = g.create_box(2, 3, 5, 20)
dino.set_text("^^\n-0-\n/\\")
score_box = g.create_box(5, 10, 1, 1)
width, height = g.dimensions()
score = 0
boxes = []
ground = g.create_box(width - 1, 3, 0, int(height / 2) + 4)
ground.set_text("^" * 200, repeatable=True)


def fire():
    #os.system('exec aplay -q ~/Div/waw-files/boing_poing.wav')
    if (count_shots() < 3):
        subprocess.Popen(["aplay", "-q", "../sounds/boing_poing.wav"])
        boxes.append(
            g.create_box(1, 1, dino.x + dino.width + 1, dino.y + 1, shot=True))


def jump():
    dino.set_y(dino.y - 2)


def crouch():
    dino.set_y(dino.y + 2)

Exemple #3
0
#!/usr/bin/python3
from game_engine import Game
import random as rd

g = Game(log=True)

dino = g.create_box(2, 3, 5, 20)

boxes = []
boxes.append(g.create_box(2, 2, 70, 21))

## need to save and display highscore
time_elapsed = 0
score = 0
delay = 50
score_box = g.create_box(20, 1)

while True:
    #k = g.next_frame(delay, score) # enter delay in ms

    # Update stats
    time_elapsed += 50
    score += int(time_elapsed / 10000) + 1

    # Update boxes
    for box in boxes:
        box.set_x(box.x - 1)

    #if time_elapsed % 10000 == 0:
    #delay -= 2
    if time_elapsed % 1000 == 0: