2021-07-02 16:54:48 +02:00
|
|
|
import sys
|
|
|
|
import pygame
|
|
|
|
import threading
|
|
|
|
import time
|
|
|
|
import datetime
|
|
|
|
import platform
|
|
|
|
import subprocess
|
|
|
|
pygame.init()
|
2022-01-02 14:39:31 +01:00
|
|
|
screen = pygame.display.set_mode((800, 480))
|
2022-01-04 15:27:37 +01:00
|
|
|
pygame.display.set_caption('The Red Robot Radio 1.0.0 - Virtualx Game Engine')
|
2022-01-02 14:39:31 +01:00
|
|
|
font = pygame.font.Font(None, 30)
|
|
|
|
clock = pygame.time.Clock()
|
2022-01-03 00:17:01 +01:00
|
|
|
FPS = 6000
|
2022-01-02 16:22:51 +01:00
|
|
|
ax = 0
|
|
|
|
ay = 0
|
|
|
|
bx = 0
|
|
|
|
by = 0
|
|
|
|
cx = 0
|
|
|
|
cy = 0
|
|
|
|
dx = 0
|
|
|
|
dy = 0
|
2022-01-02 19:53:46 +01:00
|
|
|
ex = 0
|
|
|
|
ey = 0
|
2022-01-03 00:17:01 +01:00
|
|
|
music = False #To disable music at game start set to false
|
2022-01-02 14:39:31 +01:00
|
|
|
BLACK = (0, 0, 0)
|
|
|
|
#WHITE = (255, 255, 255)
|
|
|
|
pygame.mixer.music.load('music/space.ogg')
|
|
|
|
csfx = pygame.mixer.Sound('sfx/crash.ogg')
|
|
|
|
lcfx = pygame.mixer.Sound('sfx/complete.ogg')
|
2022-01-03 00:17:01 +01:00
|
|
|
if music:
|
|
|
|
pygame.mixer.music.play(-1)
|
2022-01-02 14:39:31 +01:00
|
|
|
#sound = pygame.mixer.Sound(file='bmx.ogg')
|
|
|
|
#raw_array = sound.get_raw()
|
|
|
|
#raw_array = raw_array[100000:92557920]
|
|
|
|
#cut_sound = pygame.mixer.Sound(buffer=raw_array)
|
|
|
|
#cut_sound.play(-1)
|
|
|
|
class Background(pygame.sprite.Sprite):
|
|
|
|
def __init__(self):
|
|
|
|
pygame.sprite.Sprite.__init__(self)
|
|
|
|
self.x = 0
|
|
|
|
self.y = 0
|
|
|
|
self.image = pygame.image.load('backgrounds/galaxy.png')
|
|
|
|
#self.image = pygame.Surface((32, 32))
|
|
|
|
#self.image.fill(WHITE)
|
|
|
|
self.rect = self.image.get_rect() # Get rect of some size as 'image'.
|
|
|
|
self.velocity = [0, 0]
|
|
|
|
def update(self):
|
|
|
|
self.rect.move_ip(*self.velocity)
|
2022-01-02 20:57:04 +01:00
|
|
|
class Crash(pygame.sprite.Sprite):
|
2022-01-02 14:39:31 +01:00
|
|
|
def __init__(self):
|
|
|
|
super().__init__()
|
2022-01-02 20:57:04 +01:00
|
|
|
self.image = pygame.image.load('backgrounds/crash.png')
|
2022-01-02 14:39:31 +01:00
|
|
|
#self.image = pygame.Surface((32, 32))
|
|
|
|
#self.image.fill(WHITE)
|
|
|
|
self.rect = self.image.get_rect() # Get rect of some size as 'image'.
|
|
|
|
self.velocity = [0, 0]
|
|
|
|
class Antenna(pygame.sprite.Sprite):
|
|
|
|
def __init__(self):
|
|
|
|
super().__init__()
|
2022-01-02 20:57:04 +01:00
|
|
|
self.image = pygame.image.load('backgrounds/antenna.png')
|
2022-01-02 14:39:31 +01:00
|
|
|
#self.image = pygame.Surface((32, 32))
|
|
|
|
#self.image.fill(WHITE)
|
|
|
|
self.rect = self.image.get_rect() # Get rect of some size as 'image'.
|
|
|
|
self.velocity = [0, 0]
|
2022-01-02 16:22:51 +01:00
|
|
|
def update(self):
|
|
|
|
self.rect.move_ip(*self.velocity)
|
2022-01-02 14:39:31 +01:00
|
|
|
class Player(pygame.sprite.Sprite):
|
|
|
|
def __init__(self,xset,yset):
|
|
|
|
pygame.sprite.Sprite.__init__(self)
|
|
|
|
self.x = xset
|
|
|
|
self.y = yset
|
|
|
|
self.image = pygame.image.load('sprites/ss.png')
|
|
|
|
#self.image = pygame.Surface((32, 32))
|
|
|
|
#self.image.fill(WHITE)
|
|
|
|
#self.rect = self.image.get_rect() # Get rect of some size as 'image'.
|
|
|
|
self.rect = pygame.Rect(self.x,self.y,108, 68)
|
|
|
|
self.velocity = [0, 0]
|
|
|
|
def update(self):
|
|
|
|
self.rect.move_ip(*self.velocity)
|
|
|
|
class Wallh(pygame.sprite.Sprite):
|
|
|
|
def __init__(self,xset,yset):
|
|
|
|
pygame.sprite.Sprite.__init__(self)
|
|
|
|
self.x = xset
|
|
|
|
self.y = yset
|
2022-01-02 17:57:24 +01:00
|
|
|
self.image = pygame.image.load('sprites/wallh.png')
|
2022-01-02 14:39:31 +01:00
|
|
|
#self.image = pygame.Surface((32, 32))
|
|
|
|
#self.image.fill(WHITE)
|
|
|
|
#self.rect = self.image.get_rect() # Get rect of some size as 'image'.
|
|
|
|
self.rect = pygame.Rect(self.x,self.y,50, 1000)
|
|
|
|
self.velocity = [0, 0]
|
|
|
|
def update(self):
|
2022-01-02 16:22:51 +01:00
|
|
|
self.rect.move_ip(bx, by)
|
2022-01-02 14:39:31 +01:00
|
|
|
class Wallv(pygame.sprite.Sprite):
|
|
|
|
def __init__(self,xset,yset):
|
|
|
|
pygame.sprite.Sprite.__init__(self)
|
|
|
|
self.x = xset
|
|
|
|
self.y = yset
|
2022-01-02 17:57:24 +01:00
|
|
|
self.image = pygame.image.load('sprites/wallv.png')
|
2022-01-02 14:39:31 +01:00
|
|
|
#self.image = pygame.Surface((32, 32))
|
|
|
|
#self.image.fill(WHITE)
|
|
|
|
#self.rect = self.image.get_rect() # Get rect of some size as 'image'.
|
|
|
|
self.rect = pygame.Rect(self.x,self.y,3400, 50)
|
|
|
|
self.velocity = [0, 0]
|
|
|
|
def update(self):
|
2022-01-02 16:22:51 +01:00
|
|
|
self.rect.move_ip(bx, by)
|
2022-01-02 14:39:31 +01:00
|
|
|
class Css(pygame.sprite.Sprite):
|
|
|
|
def __init__(self,xset,yset):
|
|
|
|
pygame.sprite.Sprite.__init__(self)
|
|
|
|
self.x = xset
|
|
|
|
self.y = yset
|
|
|
|
self.image = pygame.image.load('sprites/css.png')
|
|
|
|
#self.image = pygame.Surface((32, 32))
|
|
|
|
#self.image.fill(WHITE)
|
|
|
|
#self.rect = self.image.get_rect() # Get rect of some size as 'image'.
|
|
|
|
self.rect = pygame.Rect(self.x,self.y,108, 68)
|
|
|
|
self.velocity = [0, 0]
|
|
|
|
def update(self):
|
2022-01-02 16:22:51 +01:00
|
|
|
self.rect.move_ip(bx, by)
|
2022-01-02 14:39:31 +01:00
|
|
|
class Sat(pygame.sprite.Sprite):
|
|
|
|
def __init__(self,xset,yset):
|
|
|
|
pygame.sprite.Sprite.__init__(self)
|
|
|
|
self.x = xset
|
|
|
|
self.y = yset
|
|
|
|
self.image = pygame.image.load('sprites/sat.png')
|
|
|
|
#self.image = pygame.Surface((32, 32))
|
|
|
|
#self.image.fill(WHITE)
|
|
|
|
#self.rect = self.image.get_rect() # Get rect of some size as 'image'.
|
|
|
|
self.rect = pygame.Rect(self.x,self.y,30, 22)
|
|
|
|
self.velocity = [0, 0]
|
|
|
|
def update(self):
|
2022-01-02 16:22:51 +01:00
|
|
|
self.rect.move_ip(bx, by)
|
2022-01-02 14:39:31 +01:00
|
|
|
class Goal(pygame.sprite.Sprite):
|
|
|
|
def __init__(self,xset,yset):
|
|
|
|
pygame.sprite.Sprite.__init__(self)
|
|
|
|
self.x = xset
|
|
|
|
self.y = yset
|
|
|
|
self.image = pygame.image.load('sprites/radio.png')
|
|
|
|
#self.image = pygame.Surface((32, 32))
|
|
|
|
#self.image.fill(WHITE)
|
|
|
|
#self.rect = self.image.get_rect() # Get rect of some size as 'image'.
|
|
|
|
self.rect = pygame.Rect(self.x,self.y,69, 120)
|
|
|
|
self.velocity = [0, 0]
|
|
|
|
def update(self):
|
2022-01-02 16:22:51 +01:00
|
|
|
self.rect.move_ip(bx, by)
|
2022-01-02 20:57:04 +01:00
|
|
|
class Bus(pygame.sprite.Sprite):
|
|
|
|
def __init__(self,xset,yset):
|
|
|
|
pygame.sprite.Sprite.__init__(self)
|
|
|
|
self.x = xset
|
|
|
|
self.y = yset
|
|
|
|
self.image = pygame.image.load('sprites/bus.png')
|
|
|
|
#self.image = pygame.Surface((32, 32))
|
|
|
|
#self.image.fill(WHITE)
|
|
|
|
#self.rect = self.image.get_rect() # Get rect of some size as 'image'.
|
2022-01-02 23:40:28 +01:00
|
|
|
self.rect = pygame.Rect(self.x,self.y,118, 63)
|
|
|
|
self.velocity = [0, 0]
|
|
|
|
def update(self):
|
|
|
|
self.rect.move_ip(bx, by)
|
|
|
|
class Tc(pygame.sprite.Sprite):
|
|
|
|
def __init__(self,xset,yset):
|
|
|
|
pygame.sprite.Sprite.__init__(self)
|
|
|
|
self.x = xset
|
|
|
|
self.y = yset
|
|
|
|
self.image = pygame.image.load('sprites/tc.png')
|
|
|
|
#self.image = pygame.Surface((32, 32))
|
|
|
|
#self.image.fill(WHITE)
|
|
|
|
#self.rect = self.image.get_rect() # Get rect of some size as 'image'.
|
|
|
|
self.rect = pygame.Rect(self.x,self.y,118, 63)
|
2022-01-02 20:57:04 +01:00
|
|
|
self.velocity = [0, 0]
|
|
|
|
def update(self):
|
|
|
|
self.rect.move_ip(bx, by)
|
2022-01-03 00:17:01 +01:00
|
|
|
class Iss(pygame.sprite.Sprite):
|
|
|
|
def __init__(self,xset,yset):
|
|
|
|
pygame.sprite.Sprite.__init__(self)
|
|
|
|
self.x = xset
|
|
|
|
self.y = yset
|
|
|
|
self.image = pygame.image.load('sprites/iss.png')
|
|
|
|
#self.image = pygame.Surface((32, 32))
|
|
|
|
#self.image.fill(WHITE)
|
|
|
|
#self.rect = self.image.get_rect() # Get rect of some size as 'image'.
|
|
|
|
self.rect = pygame.Rect(self.x,self.y,98, 128)
|
|
|
|
self.velocity = [0, 0]
|
|
|
|
def update(self):
|
|
|
|
self.rect.move_ip(bx, by)
|
2022-01-02 16:22:51 +01:00
|
|
|
class Ast1(pygame.sprite.Sprite):
|
2022-01-02 14:39:31 +01:00
|
|
|
def __init__(self,xset,yset):
|
|
|
|
pygame.sprite.Sprite.__init__(self)
|
|
|
|
self.x = xset
|
|
|
|
self.y = yset
|
|
|
|
self.image = pygame.image.load('sprites/asteroid.png')
|
|
|
|
#self.image = pygame.Surface((32, 32))
|
|
|
|
#self.image.fill(WHITE)
|
|
|
|
#self.rect = self.image.get_rect() # Get rect of some size as 'image'.
|
|
|
|
self.rect = pygame.Rect(self.x,self.y,108, 78)
|
|
|
|
self.velocity = [0, 0]
|
|
|
|
def update(self):
|
2022-01-02 16:22:51 +01:00
|
|
|
self.rect.move_ip(cx, cy)
|
|
|
|
class Ast2(pygame.sprite.Sprite):
|
|
|
|
def __init__(self,xset,yset):
|
|
|
|
pygame.sprite.Sprite.__init__(self)
|
|
|
|
self.x = xset
|
|
|
|
self.y = yset
|
|
|
|
self.image = pygame.image.load('sprites/asteroid.png')
|
|
|
|
#self.image = pygame.Surface((32, 32))
|
|
|
|
#self.image.fill(WHITE)
|
|
|
|
#self.rect = self.image.get_rect() # Get rect of some size as 'image'.
|
|
|
|
self.rect = pygame.Rect(self.x,self.y,108, 78)
|
|
|
|
self.velocity = [0, 0]
|
|
|
|
def update(self):
|
|
|
|
self.rect.move_ip(dx, dy)
|
|
|
|
class Ast3(pygame.sprite.Sprite):
|
|
|
|
def __init__(self,xset,yset):
|
|
|
|
pygame.sprite.Sprite.__init__(self)
|
|
|
|
self.x = xset
|
|
|
|
self.y = yset
|
|
|
|
self.image = pygame.image.load('sprites/asteroid.png')
|
|
|
|
#self.image = pygame.Surface((32, 32))
|
|
|
|
#self.image.fill(WHITE)
|
|
|
|
#self.rect = self.image.get_rect() # Get rect of some size as 'image'.
|
|
|
|
self.rect = pygame.Rect(self.x,self.y,108, 78)
|
|
|
|
self.velocity = [0, 0]
|
|
|
|
def update(self):
|
2022-01-02 19:53:46 +01:00
|
|
|
self.rect.move_ip(ex, ey)
|
2022-01-02 14:39:31 +01:00
|
|
|
player = Player(346,206)
|
|
|
|
css1 = Css(483,262)
|
|
|
|
css2 = Css(500,400)
|
2022-01-03 00:47:55 +01:00
|
|
|
css3 = Css(1582,470)
|
2022-01-02 14:39:31 +01:00
|
|
|
sat1 = Sat(550,-100)
|
|
|
|
sat2 = Sat(600,100)
|
2022-01-03 00:47:55 +01:00
|
|
|
sat3 = Sat(1240,120)
|
|
|
|
goal = Goal(1940,-16)
|
2022-01-02 20:57:04 +01:00
|
|
|
bus1 = Bus(600,656)
|
2022-01-03 00:17:01 +01:00
|
|
|
bus2 = Bus(1258,320)
|
2022-01-03 00:47:55 +01:00
|
|
|
bus3 = Bus(1970,524)
|
2022-01-02 23:40:28 +01:00
|
|
|
tc1 = Tc(854,472)
|
2022-01-03 00:17:01 +01:00
|
|
|
tc2 = Tc(1164,570)
|
2022-01-03 00:47:55 +01:00
|
|
|
tc3 = Tc(1760,680)
|
2022-01-03 00:17:01 +01:00
|
|
|
iss1 = Iss(878,140)
|
|
|
|
iss2 = Iss(1136,-6)
|
2022-01-03 00:47:55 +01:00
|
|
|
iss3 = Iss(1742,222)
|
2022-01-02 16:22:51 +01:00
|
|
|
ast1 = Ast1(120,200)
|
|
|
|
ast2 = Ast2(300,100)
|
|
|
|
ast3 = Ast3(500,150)
|
2022-01-02 14:39:31 +01:00
|
|
|
wall1 = Wallh(-100,-200)
|
2022-01-03 00:47:55 +01:00
|
|
|
wall2 = Wallh(2150,-200)
|
2022-01-02 14:39:31 +01:00
|
|
|
wall3 = Wallv(-200,-200)
|
|
|
|
wall4 = Wallv(-200,800)
|
|
|
|
background = Background()
|
2022-01-02 20:57:04 +01:00
|
|
|
crash = Crash()
|
2022-01-02 14:39:31 +01:00
|
|
|
antenna = Antenna()
|
|
|
|
running = True
|
|
|
|
live = True
|
|
|
|
complete = False
|
|
|
|
debug = False # This set debug mode
|
2022-01-02 16:22:51 +01:00
|
|
|
pygame.mouse.set_visible(False)
|
2022-01-02 14:39:31 +01:00
|
|
|
#rect = pygame.Rect((0, 0), (32, 32))
|
|
|
|
#image = pygame.Surface((32, 32))
|
|
|
|
#image.fill(WHITE)
|
|
|
|
start_time = pygame.time.get_ticks()
|
|
|
|
runtime = 0
|
2022-01-02 16:22:51 +01:00
|
|
|
pygame.event.set_grab(True)
|
2022-01-02 14:39:31 +01:00
|
|
|
while running:
|
|
|
|
dt = clock.tick(FPS) / 1000
|
|
|
|
#screen.fill(BLACK)
|
|
|
|
datetime.datetime.now()
|
|
|
|
for event in pygame.event.get():
|
|
|
|
if event.type == pygame.QUIT:
|
|
|
|
quit()
|
|
|
|
elif event.type == pygame.KEYDOWN:
|
2022-01-02 17:57:24 +01:00
|
|
|
if event.key == pygame.K_n:
|
2021-07-02 16:54:48 +02:00
|
|
|
pygame.mixer.music.stop()
|
2022-01-02 14:39:31 +01:00
|
|
|
elif event.key == pygame.K_m:
|
2021-07-02 16:54:48 +02:00
|
|
|
pygame.mixer.music.play(-1)
|
2022-01-02 14:39:31 +01:00
|
|
|
elif event.key == pygame.K_c:
|
|
|
|
if debug:
|
|
|
|
#this trigger spaceship crash event
|
|
|
|
live = False
|
|
|
|
pygame.mixer.music.stop()
|
|
|
|
csfx.play()
|
|
|
|
elif event.key == pygame.K_r:
|
2021-07-02 16:54:48 +02:00
|
|
|
#this restart the game
|
2022-01-02 13:55:56 +01:00
|
|
|
player = Player(346,206)
|
|
|
|
css1 = Css(483,262)
|
2021-07-02 16:54:48 +02:00
|
|
|
css2 = Css(500,400)
|
2022-01-03 00:47:55 +01:00
|
|
|
css3 = Css(1582,470)
|
2021-07-02 16:54:48 +02:00
|
|
|
sat1 = Sat(550,-100)
|
|
|
|
sat2 = Sat(600,100)
|
2022-01-03 00:47:55 +01:00
|
|
|
sat3 = Sat(1240,120)
|
|
|
|
goal = Goal(1940,-16)
|
2022-01-02 20:57:04 +01:00
|
|
|
bus1 = Bus(600,656)
|
2022-01-03 00:17:01 +01:00
|
|
|
bus2 = Bus(1258,320)
|
2022-01-03 00:47:55 +01:00
|
|
|
bus3 = Bus(1970,524)
|
2022-01-02 23:40:28 +01:00
|
|
|
tc1 = Tc(854,472)
|
2022-01-03 00:17:01 +01:00
|
|
|
tc2 = Tc(1164,570)
|
2022-01-03 00:47:55 +01:00
|
|
|
tc3 = Tc(1760,680)
|
2022-01-03 00:17:01 +01:00
|
|
|
iss1 = Iss(878,140)
|
|
|
|
iss2 = Iss(1136,-6)
|
2022-01-03 00:47:55 +01:00
|
|
|
iss3 = Iss(1742,222)
|
2022-01-02 16:22:51 +01:00
|
|
|
ast1 = Ast1(120,200)
|
|
|
|
ast2 = Ast2(300,100)
|
|
|
|
ast3 = Ast3(500,150)
|
2021-07-02 16:54:48 +02:00
|
|
|
wall1 = Wallh(-100,-200)
|
2022-01-03 00:47:55 +01:00
|
|
|
wall2 = Wallh(2150,-200)
|
2021-07-02 16:54:48 +02:00
|
|
|
wall3 = Wallv(-200,-200)
|
|
|
|
wall4 = Wallv(-200,800)
|
|
|
|
live = True
|
|
|
|
complete = False
|
2022-01-03 00:17:01 +01:00
|
|
|
if music:
|
|
|
|
pygame.mixer.music.play(-1)
|
2021-07-02 16:54:48 +02:00
|
|
|
start_time = pygame.time.get_ticks()
|
2022-01-02 16:22:51 +01:00
|
|
|
elif event.key == pygame.K_ESCAPE:
|
|
|
|
quit()
|
|
|
|
if event.type == pygame.MOUSEMOTION:
|
2022-01-02 17:57:24 +01:00
|
|
|
#This control camera
|
2022-01-02 16:22:51 +01:00
|
|
|
pygame.mouse.set_pos([400, 240])
|
|
|
|
ax, ay = event.rel
|
2022-01-02 19:53:46 +01:00
|
|
|
bx = ax * 7
|
|
|
|
by = ay * 7
|
2022-01-03 01:15:24 +01:00
|
|
|
cx = ax * 3
|
|
|
|
cy = ay * 3
|
|
|
|
dx = ax * 2
|
|
|
|
dy = ay * 2
|
|
|
|
ex = ax * 1
|
|
|
|
ey = ay * 1
|
2022-01-02 16:22:51 +01:00
|
|
|
|
|
|
|
|
2022-01-02 14:39:31 +01:00
|
|
|
if live:
|
|
|
|
runtime = pygame.time.get_ticks() - start_time
|
|
|
|
if (live & debug == False):
|
2022-01-02 17:57:24 +01:00
|
|
|
if pygame.sprite.collide_rect(player, wall3):
|
|
|
|
live = False
|
|
|
|
pygame.mixer.music.stop()
|
|
|
|
csfx.play()
|
|
|
|
elif pygame.sprite.collide_rect(player, wall4):
|
|
|
|
live = False
|
|
|
|
pygame.mixer.music.stop()
|
|
|
|
csfx.play()
|
2022-01-03 00:47:55 +01:00
|
|
|
elif pygame.sprite.collide_rect(player, wall1):
|
2022-01-02 17:57:24 +01:00
|
|
|
live = False
|
|
|
|
pygame.mixer.music.stop()
|
|
|
|
csfx.play()
|
|
|
|
elif pygame.sprite.collide_rect(player, wall2):
|
|
|
|
live = False
|
|
|
|
pygame.mixer.music.stop()
|
|
|
|
csfx.play()
|
|
|
|
elif pygame.sprite.collide_rect(player, css1):
|
2022-01-02 14:39:31 +01:00
|
|
|
live = False
|
|
|
|
pygame.mixer.music.stop()
|
|
|
|
csfx.play()
|
|
|
|
elif pygame.sprite.collide_rect(player, css2):
|
|
|
|
live = False
|
|
|
|
pygame.mixer.music.stop()
|
|
|
|
csfx.play()
|
2022-01-03 00:47:55 +01:00
|
|
|
elif pygame.sprite.collide_rect(player, css3):
|
|
|
|
live = False
|
|
|
|
pygame.mixer.music.stop()
|
|
|
|
csfx.play()
|
2022-01-02 14:39:31 +01:00
|
|
|
elif pygame.sprite.collide_rect(player, sat1):
|
|
|
|
live = False
|
|
|
|
pygame.mixer.music.stop()
|
|
|
|
csfx.play()
|
|
|
|
elif pygame.sprite.collide_rect(player, sat2):
|
|
|
|
live = False
|
|
|
|
pygame.mixer.music.stop()
|
|
|
|
csfx.play()
|
2022-01-03 00:47:55 +01:00
|
|
|
elif pygame.sprite.collide_rect(player, sat3):
|
2022-01-02 20:57:04 +01:00
|
|
|
live = False
|
|
|
|
pygame.mixer.music.stop()
|
|
|
|
csfx.play()
|
2022-01-03 00:47:55 +01:00
|
|
|
elif pygame.sprite.collide_rect(player, bus1):
|
2022-01-02 23:40:28 +01:00
|
|
|
live = False
|
|
|
|
pygame.mixer.music.stop()
|
|
|
|
csfx.play()
|
2022-01-03 00:47:55 +01:00
|
|
|
elif pygame.sprite.collide_rect(player, bus2):
|
2022-01-03 00:17:01 +01:00
|
|
|
live = False
|
|
|
|
pygame.mixer.music.stop()
|
|
|
|
csfx.play()
|
2022-01-03 00:47:55 +01:00
|
|
|
elif pygame.sprite.collide_rect(player, tc1):
|
2022-01-03 00:17:01 +01:00
|
|
|
live = False
|
|
|
|
pygame.mixer.music.stop()
|
|
|
|
csfx.play()
|
|
|
|
elif pygame.sprite.collide_rect(player, tc2):
|
|
|
|
live = False
|
|
|
|
pygame.mixer.music.stop()
|
|
|
|
csfx.play()
|
2022-01-03 00:47:55 +01:00
|
|
|
elif pygame.sprite.collide_rect(player, iss1):
|
|
|
|
live = False
|
|
|
|
pygame.mixer.music.stop()
|
|
|
|
csfx.play()
|
2022-01-03 00:17:01 +01:00
|
|
|
elif pygame.sprite.collide_rect(player, iss2):
|
|
|
|
live = False
|
|
|
|
pygame.mixer.music.stop()
|
|
|
|
csfx.play()
|
2022-01-03 00:47:55 +01:00
|
|
|
elif pygame.sprite.collide_rect(player, iss3):
|
|
|
|
live = False
|
|
|
|
pygame.mixer.music.stop()
|
|
|
|
csfx.play()
|
2022-01-02 14:39:31 +01:00
|
|
|
elif pygame.sprite.collide_rect(player, goal):
|
|
|
|
live = False
|
|
|
|
complete = True
|
|
|
|
pygame.mixer.music.stop()
|
|
|
|
lcfx.play()
|
|
|
|
player.update()
|
|
|
|
css1.update()
|
|
|
|
css2.update()
|
2022-01-03 00:47:55 +01:00
|
|
|
css3.update()
|
2022-01-02 14:39:31 +01:00
|
|
|
sat1.update()
|
|
|
|
sat2.update()
|
2022-01-03 00:47:55 +01:00
|
|
|
sat3.update()
|
2022-01-02 14:39:31 +01:00
|
|
|
goal.update()
|
2022-01-02 20:57:04 +01:00
|
|
|
bus1.update()
|
2022-01-03 00:17:01 +01:00
|
|
|
bus2.update()
|
2022-01-03 00:47:55 +01:00
|
|
|
bus3.update()
|
2022-01-02 23:40:28 +01:00
|
|
|
tc1.update()
|
2022-01-03 00:17:01 +01:00
|
|
|
tc2.update()
|
2022-01-03 00:47:55 +01:00
|
|
|
tc3.update()
|
2022-01-03 00:17:01 +01:00
|
|
|
iss1.update()
|
|
|
|
iss2.update()
|
2022-01-03 00:47:55 +01:00
|
|
|
iss3.update()
|
2022-01-02 14:39:31 +01:00
|
|
|
ast1.update()
|
|
|
|
ast2.update()
|
|
|
|
ast3.update()
|
|
|
|
wall1.update()
|
|
|
|
wall2.update()
|
|
|
|
wall3.update()
|
|
|
|
wall4.update()
|
|
|
|
if live:
|
|
|
|
screen.blit(background.image, background.rect)
|
|
|
|
screen.blit(ast3.image, ast3.rect)
|
2022-01-03 00:47:55 +01:00
|
|
|
screen.blit(ast2.image, ast2.rect)
|
2022-01-02 14:39:31 +01:00
|
|
|
screen.blit(ast1.image, ast1.rect)
|
|
|
|
screen.blit(player.image, player.rect)
|
|
|
|
screen.blit(css1.image, css1.rect)
|
|
|
|
screen.blit(css2.image, css2.rect)
|
2022-01-03 00:47:55 +01:00
|
|
|
screen.blit(css3.image, css3.rect)
|
2022-01-02 14:39:31 +01:00
|
|
|
screen.blit(sat1.image, sat1.rect)
|
|
|
|
screen.blit(sat2.image, sat2.rect)
|
2022-01-03 00:47:55 +01:00
|
|
|
screen.blit(sat3.image, sat3.rect)
|
2022-01-02 14:39:31 +01:00
|
|
|
screen.blit(goal.image, goal.rect)
|
2022-01-02 20:57:04 +01:00
|
|
|
screen.blit(bus1.image, bus1.rect)
|
2022-01-03 00:17:01 +01:00
|
|
|
screen.blit(bus2.image, bus2.rect)
|
2022-01-03 00:47:55 +01:00
|
|
|
screen.blit(bus3.image, bus3.rect)
|
2022-01-02 23:40:28 +01:00
|
|
|
screen.blit(tc1.image, tc1.rect)
|
2022-01-03 00:17:01 +01:00
|
|
|
screen.blit(tc2.image, tc2.rect)
|
2022-01-03 00:47:55 +01:00
|
|
|
screen.blit(tc3.image, tc3.rect)
|
2022-01-03 00:17:01 +01:00
|
|
|
screen.blit(iss1.image, iss1.rect)
|
|
|
|
screen.blit(iss2.image, iss2.rect)
|
2022-01-03 00:47:55 +01:00
|
|
|
screen.blit(iss3.image, iss3.rect)
|
2022-01-02 17:57:24 +01:00
|
|
|
screen.blit(wall1.image, wall1.rect)
|
|
|
|
screen.blit(wall2.image, wall2.rect)
|
|
|
|
screen.blit(wall3.image, wall3.rect)
|
|
|
|
screen.blit(wall4.image, wall4.rect)
|
2022-01-02 14:39:31 +01:00
|
|
|
elif complete:
|
|
|
|
playhr = (int(runtime / 3600000))
|
|
|
|
playmin = (int(runtime / 60000) - (playhr * 60))
|
|
|
|
playsec = (int(runtime / 1000) - (playmin * 60) - (playhr * 3600))
|
|
|
|
playmsec = (runtime - (playsec * 1000) - (playmin * 60000) - (playhr * 3600000))
|
|
|
|
playtime = "%d:%02d:%02d:%03d" % (playhr, playmin, playsec, playmsec)
|
|
|
|
screen.blit(antenna.image, antenna.rect)
|
|
|
|
yourtimetext = font.render(str("Your Time"), True, pygame.Color('white'))
|
|
|
|
screen.blit(yourtimetext, (350, 400))
|
|
|
|
yourtime = font.render(str(playtime), True, pygame.Color('white'))
|
|
|
|
screen.blit(yourtime, (350, 440))
|
2021-07-02 16:54:48 +02:00
|
|
|
else:
|
2022-01-02 14:39:31 +01:00
|
|
|
playhr = (int(runtime / 3600000))
|
|
|
|
playmin = (int(runtime / 60000) - (playhr * 60))
|
|
|
|
playsec = (int(runtime / 1000) - (playmin * 60) - (playhr * 3600))
|
|
|
|
playmsec = (runtime - (playsec * 1000) - (playmin * 60000) - (playhr * 3600000))
|
|
|
|
playtime = "%d:%02d:%02d:%03d" % (playhr, playmin, playsec, playmsec)
|
2022-01-02 20:57:04 +01:00
|
|
|
screen.blit(crash.image, crash.rect)
|
2022-01-02 14:39:31 +01:00
|
|
|
yourtimetext = font.render(str("Your Time"), True, pygame.Color('white'))
|
|
|
|
screen.blit(yourtimetext, (350, 400))
|
|
|
|
yourtime = font.render(str(playtime), True, pygame.Color('white'))
|
|
|
|
screen.blit(yourtime, (350, 440))
|
|
|
|
rfps = font.render(str(int(clock.get_fps())), True, pygame.Color('white'))
|
|
|
|
screen.blit(rfps, (50, 50))
|
|
|
|
if debug:
|
|
|
|
sysclock = font.render(str(datetime.datetime.utcnow()), True, pygame.Color('white'))
|
|
|
|
cpuarch = font.render(str(platform.machine()), True, pygame.Color('white'))
|
|
|
|
playcount = font.render(str(runtime), True, pygame.Color('white'))
|
2022-01-03 20:04:09 +01:00
|
|
|
infox = font.render(str(bx), True, pygame.Color('white'))
|
|
|
|
infoy = font.render(str(by), True, pygame.Color('white'))
|
2022-01-02 14:39:31 +01:00
|
|
|
screen.blit(sysclock, (120, 50))
|
|
|
|
screen.blit(cpuarch, (50, 80))
|
|
|
|
screen.blit(playcount, (160, 80))
|
2022-01-03 20:04:09 +01:00
|
|
|
screen.blit(infox, (50, 110))
|
|
|
|
screen.blit(infoy, (50, 140))
|
2022-01-02 14:39:31 +01:00
|
|
|
pygame.display.update()
|