Compare commits

..

5 commits
1.1.0 ... main

Author SHA1 Message Date
fff046fd16 update readme 2023-08-12 20:47:28 -07:00
7909b93327 set version number 2022-07-04 17:56:52 -07:00
a6581d47ef title screen 2022-07-04 17:54:48 -07:00
e8343d9fcf code cleanup 2022-07-04 17:42:47 -07:00
1702acdcbb code cleanup 2022-07-04 17:34:43 -07:00
2 changed files with 38 additions and 40 deletions

View file

@ -3,3 +3,5 @@ A simple game using Pygame library (version 2.1 or later is required to avoid ca
You control a spaceship moving computer mouse (or any other input device that can emulate it like touchpads, joysticks or trackballs) You control a spaceship moving computer mouse (or any other input device that can emulate it like touchpads, joysticks or trackballs)
"Source" and "level maps" folders are not required to play the game, only "backgounds", "music", "sfx", "sprites" and "r3.py" executable "Source" and "level maps" folders are not required to play the game, only "backgounds", "music", "sfx", "sprites" and "r3.py" executable
I'm not longer working on this project, it is being ported to Godot Game Engine

74
r3.py
View file

@ -7,7 +7,7 @@ import platform
import subprocess import subprocess
pygame.init() pygame.init()
screen = pygame.display.set_mode((800, 480)) screen = pygame.display.set_mode((800, 480))
pygame.display.set_caption('The Red Robot Radio 1.1.0 - Virtualx Game Engine') pygame.display.set_caption('The Red Robot Radio 1.1.1 - Virtualx Game Engine')
font = pygame.font.Font(None, 30) font = pygame.font.Font(None, 30)
clock = pygame.time.Clock() clock = pygame.time.Clock()
crashbg = 'backgrounds/crash.png' crashbg = 'backgrounds/crash.png'
@ -281,8 +281,11 @@ else:
if music: if music:
pygame.mixer.music.play(-1) pygame.mixer.music.play(-1)
running = True running = True
live = True rstate = 0
complete = False # 0 for title screen
# 1 for live spaceship
# 2 for crashed spaceship
# 3 for completed
debug = False # This set debug mode debug = False # This set debug mode
pygame.mouse.set_visible(False) pygame.mouse.set_visible(False)
#rect = pygame.Rect((0, 0), (32, 32)) #rect = pygame.Rect((0, 0), (32, 32))
@ -307,6 +310,7 @@ while running:
if debug: if debug:
#this trigger spaceship crash event #this trigger spaceship crash event
live = False live = False
rstate = 2
pygame.mixer.music.stop() pygame.mixer.music.stop()
background = Background('backgrounds/crash.png') background = Background('backgrounds/crash.png')
csfx.play() csfx.play()
@ -370,6 +374,7 @@ while running:
pygame.mixer.music.play(-1) pygame.mixer.music.play(-1)
live = True live = True
complete = False complete = False
rstate = 1
if music: if music:
pygame.mixer.music.play(-1) pygame.mixer.music.play(-1)
start_time = pygame.time.get_ticks() start_time = pygame.time.get_ticks()
@ -389,97 +394,96 @@ while running:
ey = ay * 1 ey = ay * 1
if live: if (rstate == 1):
runtime = pygame.time.get_ticks() - start_time runtime = pygame.time.get_ticks() - start_time
if (live & debug == False): if (debug == False):
if pygame.sprite.collide_rect(player, wall3): if pygame.sprite.collide_rect(player, wall3):
live = False rstate = 2
pygame.mixer.music.stop() pygame.mixer.music.stop()
background = Background(crashbg) background = Background(crashbg)
csfx.play() csfx.play()
elif pygame.sprite.collide_rect(player, wall4): elif pygame.sprite.collide_rect(player, wall4):
live = False rstate = 2
pygame.mixer.music.stop() pygame.mixer.music.stop()
background = Background(crashbg) background = Background(crashbg)
csfx.play() csfx.play()
elif pygame.sprite.collide_rect(player, wall1): elif pygame.sprite.collide_rect(player, wall1):
live = False rstate = 2
pygame.mixer.music.stop() pygame.mixer.music.stop()
background = Background(crashbg) background = Background(crashbg)
csfx.play() csfx.play()
elif pygame.sprite.collide_rect(player, wall2): elif pygame.sprite.collide_rect(player, wall2):
live = False rstate = 2
pygame.mixer.music.stop() pygame.mixer.music.stop()
background = Background(crashbg) background = Background(crashbg)
csfx.play() csfx.play()
elif pygame.sprite.collide_rect(player, css1): elif pygame.sprite.collide_rect(player, css1):
live = False rstate = 2
pygame.mixer.music.stop() pygame.mixer.music.stop()
background = Background(crashbg) background = Background(crashbg)
csfx.play() csfx.play()
elif pygame.sprite.collide_rect(player, css2): elif pygame.sprite.collide_rect(player, css2):
live = False rstate = 2
pygame.mixer.music.stop() pygame.mixer.music.stop()
background = Background(crashbg) background = Background(crashbg)
csfx.play() csfx.play()
elif pygame.sprite.collide_rect(player, css3): elif pygame.sprite.collide_rect(player, css3):
live = False rstate = 2
pygame.mixer.music.stop() pygame.mixer.music.stop()
background = Background(crashbg) background = Background(crashbg)
csfx.play() csfx.play()
elif pygame.sprite.collide_rect(player, sat1): elif pygame.sprite.collide_rect(player, sat1):
live = False rstate = 2
pygame.mixer.music.stop() pygame.mixer.music.stop()
background = Background(crashbg) background = Background(crashbg)
csfx.play() csfx.play()
elif pygame.sprite.collide_rect(player, sat2): elif pygame.sprite.collide_rect(player, sat2):
live = False rstate = 2
pygame.mixer.music.stop() pygame.mixer.music.stop()
background = Background(crashbg) background = Background(crashbg)
csfx.play() csfx.play()
elif pygame.sprite.collide_rect(player, sat3): elif pygame.sprite.collide_rect(player, sat3):
live = False rstate = 2
pygame.mixer.music.stop() pygame.mixer.music.stop()
background = Background(crashbg) background = Background(crashbg)
csfx.play() csfx.play()
elif pygame.sprite.collide_rect(player, bus1): elif pygame.sprite.collide_rect(player, bus1):
live = False rstate = 2
pygame.mixer.music.stop() pygame.mixer.music.stop()
background = Background(crashbg) background = Background(crashbg)
csfx.play() csfx.play()
elif pygame.sprite.collide_rect(player, bus2): elif pygame.sprite.collide_rect(player, bus2):
live = False rstate = 2
pygame.mixer.music.stop() pygame.mixer.music.stop()
background = Background(crashbg) background = Background(crashbg)
csfx.play() csfx.play()
elif pygame.sprite.collide_rect(player, tc1): elif pygame.sprite.collide_rect(player, tc1):
live = False rstate = 2
pygame.mixer.music.stop() pygame.mixer.music.stop()
background = Background(crashbg) background = Background(crashbg)
csfx.play() csfx.play()
elif pygame.sprite.collide_rect(player, tc2): elif pygame.sprite.collide_rect(player, tc2):
live = False rstate = 2
pygame.mixer.music.stop() pygame.mixer.music.stop()
background = Background(crashbg) background = Background(crashbg)
csfx.play() csfx.play()
elif pygame.sprite.collide_rect(player, iss1): elif pygame.sprite.collide_rect(player, iss1):
live = False rstate = 2
pygame.mixer.music.stop() pygame.mixer.music.stop()
background = Background(crashbg) background = Background(crashbg)
csfx.play() csfx.play()
elif pygame.sprite.collide_rect(player, iss2): elif pygame.sprite.collide_rect(player, iss2):
live = False rstate = 2
pygame.mixer.music.stop() pygame.mixer.music.stop()
background = Background(crashbg) background = Background(crashbg)
csfx.play() csfx.play()
elif pygame.sprite.collide_rect(player, iss3): elif pygame.sprite.collide_rect(player, iss3):
live = False rstate = 2
pygame.mixer.music.stop() pygame.mixer.music.stop()
background = Background(crashbg) background = Background(crashbg)
csfx.play() csfx.play()
elif pygame.sprite.collide_rect(player, goal): elif pygame.sprite.collide_rect(player, goal):
live = False rstate = 3
complete = True
pygame.mixer.music.stop() pygame.mixer.music.stop()
background = Background('backgrounds/antenna.png') background = Background('backgrounds/antenna.png')
lcfx.play() lcfx.play()
@ -509,7 +513,7 @@ while running:
wall4.update() wall4.update()
background.update() background.update()
screen.blit(background.image, background.rect) screen.blit(background.image, background.rect)
if live: if (rstate == 1):
#screen.blit(background.image, background.rect) #screen.blit(background.image, background.rect)
screen.blit(ast3.image, ast3.rect) screen.blit(ast3.image, ast3.rect)
screen.blit(ast2.image, ast2.rect) screen.blit(ast2.image, ast2.rect)
@ -535,36 +539,28 @@ while running:
screen.blit(wall2.image, wall2.rect) screen.blit(wall2.image, wall2.rect)
screen.blit(wall3.image, wall3.rect) screen.blit(wall3.image, wall3.rect)
screen.blit(wall4.image, wall4.rect) screen.blit(wall4.image, wall4.rect)
elif complete: elif (rstate == 0):
playhr = (int(runtime / 3600000)) yourtimetext = font.render(str("Move computer mouse and press R to start playing"), True, pygame.Color('white'))
playmin = (int(runtime / 60000) - (playhr * 60)) screen.blit(yourtimetext, (150, 400))
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))
else: else:
playhr = (int(runtime / 3600000)) playhr = (int(runtime / 3600000))
playmin = (int(runtime / 60000) - (playhr * 60)) playmin = (int(runtime / 60000) - (playhr * 60))
playsec = (int(runtime / 1000) - (playmin * 60) - (playhr * 3600)) playsec = (int(runtime / 1000) - (playmin * 60) - (playhr * 3600))
playmsec = (runtime - (playsec * 1000) - (playmin * 60000) - (playhr * 3600000)) playmsec = (runtime - (playsec * 1000) - (playmin * 60000) - (playhr * 3600000))
playtime = "%d:%02d:%02d:%03d" % (playhr, playmin, playsec, playmsec) playtime = "%d:%02d:%02d:%03d" % (playhr, playmin, playsec, playmsec)
#screen.blit(crash.image, crash.rect)
yourtimetext = font.render(str("Your Time"), True, pygame.Color('white')) yourtimetext = font.render(str("Your Time"), True, pygame.Color('white'))
screen.blit(yourtimetext, (350, 400)) screen.blit(yourtimetext, (350, 400))
yourtime = font.render(str(playtime), True, pygame.Color('white')) yourtime = font.render(str(playtime), True, pygame.Color('white'))
screen.blit(yourtime, (350, 440)) screen.blit(yourtime, (350, 440))
#rfps = font.render(str(int(rstate)), True, pygame.Color('white'))
rfps = font.render(str(int(clock.get_fps())), True, pygame.Color('white')) rfps = font.render(str(int(clock.get_fps())), True, pygame.Color('white'))
screen.blit(rfps, (50, 50)) screen.blit(rfps, (50, 50))
if debug: if debug:
sysclock = font.render(str(datetime.datetime.utcnow()), True, pygame.Color('white')) sysclock = font.render(str(datetime.datetime.utcnow()), True, pygame.Color('white'))
cpuarch = font.render(str(platform.machine()), True, pygame.Color('white')) cpuarch = font.render(str(platform.machine()), True, pygame.Color('white'))
playcount = font.render(str(runtime), True, pygame.Color('white')) playcount = font.render(str(runtime), True, pygame.Color('white'))
infox = font.render(str(bx), True, pygame.Color('white')) infox = font.render(str(ax), True, pygame.Color('white'))
infoy = font.render(str(by), True, pygame.Color('white')) infoy = font.render(str(ay), True, pygame.Color('white'))
screen.blit(sysclock, (120, 50)) screen.blit(sysclock, (120, 50))
screen.blit(cpuarch, (50, 80)) screen.blit(cpuarch, (50, 80))
screen.blit(playcount, (160, 80)) screen.blit(playcount, (160, 80))