-
Notifications
You must be signed in to change notification settings - Fork 2
/
game.py
36 lines (28 loc) · 1.37 KB
/
game.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
__author__ = 'Nathan'
import random as r
import tribute
class GameState(object):
"""
represents, well, the state of the game.
how should we separate the line between the map and the game state?
for now, I'm making the crude assumption that the map read parses to an empty game-state
"""
def __init__(self, particles, width=50, height=50):
self.width, self.height = width, height
self.world = {
'ground': (),
'particle': ()
}
self.particles = particles
self.grid = {
'ground': [(x, y, (r.randint(0, 255), r.randint(0, 255), r.randint(0, 255), 0), None) for x in range(width) for y in range(height)],
'particle': [(p.state[0], p.state[1],
((255 * (1 - (p.stats['health'] / p.attributes['max_health']))), 0,
(255 * ((p.stats['health'] / p.attributes['max_health']))), 0), p) for p in self.particles]
}
def update(self):
self.grid['particle'] = [(p.state[0], p.state[1],
(int(round(min(max((255 * (1 - (float(p.stats['health']) / p.attributes['max_health']))), 0), 255))), 0,
int(round(min(max((255 * ((float(p.stats['health']) / p.attributes['max_health']))), 0), 255))), 0), p) for p in self.particles]
def apply_action(self):
pass