Start remaking without numpy
This commit is contained in:
+32
-36
@@ -1,45 +1,41 @@
|
||||
import numpy as np
|
||||
from tools import *
|
||||
|
||||
class Entity:
|
||||
position = np.array([0,0])
|
||||
class entity:
|
||||
position = Vector2(0,0)
|
||||
name = ""
|
||||
def __init__(self, InitialPosition, name):
|
||||
self.position = InitialPosition
|
||||
def __init__(self, initial_position, name):
|
||||
self.position = initial_position
|
||||
self.name = name
|
||||
|
||||
|
||||
class Actor(Entity):
|
||||
perceptionRadius = 0
|
||||
percievedCells = None
|
||||
def __init__(self, InitialPosition, name, perceptionRadius):
|
||||
super().__init__(InitialPosition, name)
|
||||
self.perceptionRadius = perceptionRadius
|
||||
|
||||
|
||||
class Neo(Actor):
|
||||
keyMakerPosition = np.array([0,0])
|
||||
def __init__(self, InitialPosition, perceptionRadius, keyMakerPosition):
|
||||
super().__init__(InitialPosition, "Neo", perceptionRadius)
|
||||
self.keyMakerPosition = keyMakerPosition
|
||||
|
||||
class Smith(Actor):
|
||||
def __init__(self, InitialPosition, perceptionRadius):
|
||||
super().__init__(InitialPosition, "Smith", perceptionRadius)
|
||||
def Kill():
|
||||
print("Neo is killed.") #TODO: delete
|
||||
class actor(entity):
|
||||
perception_radius = 0
|
||||
perceived_cells = None
|
||||
def __init__(self, initial_position, name, perception_radius):
|
||||
super().__init__(initial_position, name)
|
||||
self.perception_radius = perception_radius
|
||||
|
||||
class Sentinel(Actor):
|
||||
def __init__(self, InitialPosition, perceptionRadius):
|
||||
super().__init__(InitialPosition, "Sentinel", perceptionRadius)
|
||||
def Kill():
|
||||
class neo(actor):
|
||||
key_maker_position = Vector2(0,0)
|
||||
def __init__(self, initial_position, perception_radius, key_maker_position):
|
||||
super().__init__(initial_position, "neo", perception_radius)
|
||||
self.key_maker_position = key_maker_position
|
||||
|
||||
class smith(actor):
|
||||
def __init__(self, initial_position, perception_radius):
|
||||
super().__init__(initial_position, "smith", perception_radius)
|
||||
def kill():
|
||||
print("Neo is killed.") #TODO: delete
|
||||
|
||||
class Keymaker(Entity):
|
||||
def __init__(self, InitialPosition):
|
||||
super().__init__(InitialPosition, "Keymaker")
|
||||
|
||||
class BackdoorKey(Entity):
|
||||
def __init__(self, InitialPosition):
|
||||
super().__init__(InitialPosition, "BackdoorKey")
|
||||
class sentinel(actor):
|
||||
def __init__(self, initial_position, perception_radius):
|
||||
super().__init__(initial_position, "sentinel", perception_radius)
|
||||
def kill():
|
||||
print("Neo is killed.") #TODO: delete
|
||||
|
||||
class key_maker(entity):
|
||||
def __init__(self, initial_position):
|
||||
super().__init__(initial_position, "key_maker")
|
||||
|
||||
class backdoor_key(entity):
|
||||
def __init__(self, initial_position):
|
||||
super().__init__(initial_position, "backdoor_key")
|
||||
|
||||
@@ -1,14 +1,6 @@
|
||||
import pygame as pg
|
||||
#import pygame as pg
|
||||
#from tools import *
|
||||
from map import *
|
||||
|
||||
cell = Cell(coordinates=np.array([50,50]))
|
||||
|
||||
running = True
|
||||
|
||||
while (running):
|
||||
for event in pg.event.get():
|
||||
if event.type == pg.QUIT:
|
||||
running = False
|
||||
screen.fill('BLACK')
|
||||
cell.draw()
|
||||
|
||||
@@ -1,21 +1,45 @@
|
||||
import numpy as np
|
||||
import pygame as pg
|
||||
from tools import *
|
||||
from entities import *
|
||||
|
||||
pg.init()
|
||||
screen = pg.display.set_mode([512,512])
|
||||
pg.display.set_caption("Matrix Universe")
|
||||
pg.init()
|
||||
|
||||
|
||||
class Cell:
|
||||
coordinates = np.array([0,0])
|
||||
position = np.array([0,0])
|
||||
coordinates = Vector2(0,0)
|
||||
position = Vector2(0,0)
|
||||
size = 50
|
||||
piece = pg.draw.rect(screen, (255,255,255), (0, 0, size, size))
|
||||
piece = pg.Rect(0, 0, size, size)
|
||||
def __init__(self, coordinates):
|
||||
self.coordinates = coordinates
|
||||
self.position = coordinates // self.size
|
||||
self.piece = pg.Rect(self.coordinates.x, self.coordinates.y, self.size, self.size)
|
||||
def draw(self):
|
||||
screen.blit(screen, self.coordinates ,self.piece)
|
||||
pg.draw.rect(screen, (255, 255, 255), self.piece)
|
||||
|
||||
class Map:
|
||||
cellGrid = None
|
||||
cell_Grid = []
|
||||
margin = 5
|
||||
dimension = Vector2(8,8)
|
||||
offset = Vector2(50, 50)
|
||||
def __init__(self):
|
||||
pass
|
||||
for x in range(self.dimension.x):
|
||||
for y in range(self.dimension.y):
|
||||
self.cell_Grid.append(Cell()) #TODO: Finish it
|
||||
pass
|
||||
|
||||
|
||||
|
||||
cell = Cell(coordinates=Vector2(50,50))
|
||||
|
||||
running = True
|
||||
|
||||
while (running):
|
||||
for event in pg.event.get():
|
||||
if event.type == pg.QUIT:
|
||||
running = False
|
||||
screen.fill('BLACK')
|
||||
cell.draw()
|
||||
pg.display.update()
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
class Vector2:
|
||||
def __init__(self, x, y):
|
||||
self.x = x
|
||||
self.y = y
|
||||
|
||||
def __add__(self, other):
|
||||
return Vector2(self.x + other.x, self.y + other.y)
|
||||
|
||||
def __sub__(self, other):
|
||||
return Vector2(self.x - other.x, self.y - other.y)
|
||||
|
||||
def __mul__(self, other):
|
||||
return Vector2(self.x * other, self.y * other)
|
||||
|
||||
def __truediv__(self, other):
|
||||
return Vector2(self.x / other, self.y / other)
|
||||
|
||||
def __floordiv__(self, other):
|
||||
return Vector2(self.x // other, self.y // other)
|
||||
|
||||
def magnitude(self):
|
||||
return (self.x**2 + self.y**2)**0.5
|
||||
def to_array(vector):
|
||||
return [vector.x, vector.y]
|
||||
def normalize(self):
|
||||
length = self.magnitude()
|
||||
return Vector2(self.x / length, self.y / length)
|
||||
Reference in New Issue
Block a user