-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtemplate.py
66 lines (56 loc) · 1.29 KB
/
template.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#Jump Platform game
import pygame as pg
import random
import pyglet as pyg
import os
from settings import *
class Game:
def __init__(self):
#initialize game window
pg.init()
pg.mixer.init()
self.screen = pg.display.set_mode((WIDTH, HEIGHT))
pg.display.set_caption(TITLE)
self.clock = pg.time.Clock()
self.running = True
def new(self):
#start a new game
self.all_sprites = pg.sprite.Group()
#self.player = Player()
#self.all_sprites.add(self.player)
self.run()
def run(self):
#game Loop
self.playing = True
while self.playing:
self.clock.tick(FPS)
self.events()
self.update()
self.draw()
def update(self):
#Game Loop Update
self.all_sprites.update()
def events(self):
# Game Loop Events
for event in pg.event.get():
#Terminate the program
if event.type == pg.QUIT:
self.playing = False
self.running = False
def draw(self):
#Game Loop draw
self.screen.fill(BLACK)
self.all_sprites.draw(self.screen)
pg.display.flip() #Flips newly rendered frame to the viewer
def show_start_screen(self):
# Game splash/start screen
pass
def show_go_screen(self):
#game over/continue
pass
g = Game()
g.show_start_screen()
while g.running:
g.new()
g.show_go_screen()
pg.quit()