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

@ -2,4 +2,6 @@
A simple game using Pygame library (version 2.1 or later is required to avoid camera issues).
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
pygame.init()
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)
clock = pygame.time.Clock()
crashbg = 'backgrounds/crash.png'
@ -281,8 +281,11 @@ else:
if music:
pygame.mixer.music.play(-1)
running = True
live = True
complete = False
rstate = 0
# 0 for title screen
# 1 for live spaceship
# 2 for crashed spaceship
# 3 for completed
debug = False # This set debug mode
pygame.mouse.set_visible(False)
#rect = pygame.Rect((0, 0), (32, 32))
@ -307,6 +310,7 @@ while running:
if debug:
#this trigger spaceship crash event
live = False
rstate = 2
pygame.mixer.music.stop()
background = Background('backgrounds/crash.png')
csfx.play()
@ -370,6 +374,7 @@ while running:
pygame.mixer.music.play(-1)
live = True
complete = False
rstate = 1
if music:
pygame.mixer.music.play(-1)
start_time = pygame.time.get_ticks()
@ -389,97 +394,96 @@ while running:
ey = ay * 1
if live:
if (rstate == 1):
runtime = pygame.time.get_ticks() - start_time
if (live & debug == False):
if (debug == False):
if pygame.sprite.collide_rect(player, wall3):
live = False
rstate = 2
pygame.mixer.music.stop()
background = Background(crashbg)
csfx.play()
elif pygame.sprite.collide_rect(player, wall4):
live = False
rstate = 2
pygame.mixer.music.stop()
background = Background(crashbg)
csfx.play()
elif pygame.sprite.collide_rect(player, wall1):
live = False
rstate = 2
pygame.mixer.music.stop()
background = Background(crashbg)
csfx.play()
elif pygame.sprite.collide_rect(player, wall2):
live = False
rstate = 2
pygame.mixer.music.stop()
background = Background(crashbg)
csfx.play()
elif pygame.sprite.collide_rect(player, css1):
live = False
rstate = 2
pygame.mixer.music.stop()
background = Background(crashbg)
csfx.play()
elif pygame.sprite.collide_rect(player, css2):
live = False
rstate = 2
pygame.mixer.music.stop()
background = Background(crashbg)
csfx.play()
elif pygame.sprite.collide_rect(player, css3):
live = False
rstate = 2
pygame.mixer.music.stop()
background = Background(crashbg)
csfx.play()
elif pygame.sprite.collide_rect(player, sat1):
live = False
rstate = 2
pygame.mixer.music.stop()
background = Background(crashbg)
csfx.play()
elif pygame.sprite.collide_rect(player, sat2):
live = False
rstate = 2
pygame.mixer.music.stop()
background = Background(crashbg)
csfx.play()
elif pygame.sprite.collide_rect(player, sat3):
live = False
rstate = 2
pygame.mixer.music.stop()
background = Background(crashbg)
csfx.play()
elif pygame.sprite.collide_rect(player, bus1):
live = False
rstate = 2
pygame.mixer.music.stop()
background = Background(crashbg)
csfx.play()
elif pygame.sprite.collide_rect(player, bus2):
live = False
rstate = 2
pygame.mixer.music.stop()
background = Background(crashbg)
csfx.play()
elif pygame.sprite.collide_rect(player, tc1):
live = False
rstate = 2
pygame.mixer.music.stop()
background = Background(crashbg)
csfx.play()
elif pygame.sprite.collide_rect(player, tc2):
live = False
rstate = 2
pygame.mixer.music.stop()
background = Background(crashbg)
csfx.play()
elif pygame.sprite.collide_rect(player, iss1):
live = False
rstate = 2
pygame.mixer.music.stop()
background = Background(crashbg)
csfx.play()
elif pygame.sprite.collide_rect(player, iss2):
live = False
rstate = 2
pygame.mixer.music.stop()
background = Background(crashbg)
csfx.play()
elif pygame.sprite.collide_rect(player, iss3):
live = False
rstate = 2
pygame.mixer.music.stop()
background = Background(crashbg)
csfx.play()
elif pygame.sprite.collide_rect(player, goal):
live = False
complete = True
rstate = 3
pygame.mixer.music.stop()
background = Background('backgrounds/antenna.png')
lcfx.play()
@ -509,7 +513,7 @@ while running:
wall4.update()
background.update()
screen.blit(background.image, background.rect)
if live:
if (rstate == 1):
#screen.blit(background.image, background.rect)
screen.blit(ast3.image, ast3.rect)
screen.blit(ast2.image, ast2.rect)
@ -535,36 +539,28 @@ while running:
screen.blit(wall2.image, wall2.rect)
screen.blit(wall3.image, wall3.rect)
screen.blit(wall4.image, wall4.rect)
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))
elif (rstate == 0):
yourtimetext = font.render(str("Move computer mouse and press R to start playing"), True, pygame.Color('white'))
screen.blit(yourtimetext, (150, 400))
else:
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(crash.image, crash.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))
#rfps = font.render(str(int(rstate)), True, pygame.Color('white'))
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'))
infox = font.render(str(bx), True, pygame.Color('white'))
infoy = font.render(str(by), True, pygame.Color('white'))
infox = font.render(str(ax), True, pygame.Color('white'))
infoy = font.render(str(ay), True, pygame.Color('white'))
screen.blit(sysclock, (120, 50))
screen.blit(cpuarch, (50, 80))
screen.blit(playcount, (160, 80))