Skip to content

Commit

Permalink
Added clouds
Browse files Browse the repository at this point in the history
  • Loading branch information
MysteryCoder456 committed Mar 26, 2020
1 parent 73c23fb commit 17e1de4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
13 changes: 9 additions & 4 deletions game/entities/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@


class Cloud(Entity):
def __init__(self, app, scene, player):
pos = vec3(0, 200, -5000)
vel = vec3(randint(-15, 15), 0, player.velocity.z)
super().__init__(app, scene, SHIP_IMAGE_PATH, position=pos, velocity=vel)
if randint(0, 10) <= 5:
hdg = -1
else:
hdg = 1

def __init__(self, app, scene, pos: vec3, z_vel: float):
vel = vec3(randint(0, 15) * Cloud.hdg, 0, z_vel)

super().__init__(app, scene, SHIP_IMAGE_PATH, position=pos, velocity=vel)
9 changes: 8 additions & 1 deletion game/states/game.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
import pygame
from glm import vec3, sign
from random import randint

from game.base.inputs import Inputs, Axis, Button
from game.base.state import State
Expand Down Expand Up @@ -29,7 +30,6 @@ def __init__(self, app, state=None):
self.camera = self.scene.add(Camera(app, self.scene, self.app.size))
self.scene.add(Ground(app, self.scene, GROUND_HEIGHT))
self.player = self.scene.add(Player(app, self.scene))
self.cloud = self.scene.add(Cloud(app, self.scene, self.player))
# self.msg = self.scene.add(Message(self.app, self.scene, "HELLO"))

self.scene.script = Level1
Expand All @@ -40,6 +40,13 @@ def __init__(self, app, state=None):

self.time = 0

for i in range(20):
x = randint(-1000, 1000)
y = randint(300, 600)
z = randint(-6000, -3000)
pos = vec3(x, y, z)
self.scene.add(Cloud(self.app, self.scene, pos, self.player.velocity.z))

def pend(self):

# self.dirty = True
Expand Down

0 comments on commit 17e1de4

Please sign in to comment.