Share your repls and programming experiences

← Back to all posts
My game for kajam
Vivaanawesome

Hey guys
This is my game

use left and right keys to move

here is the code(please don't copy and if you do please give credits)
'''pygame
import pygame, random, sys
from pygame.locals import *

WINDOWWIDTH = 600
WINDOWHEIGHT = 600
TEXTCOLOR = (255,69,0)
BACKGROUNDCOLOR = (90,30,70)
FPS = 40
BADDIEMINSIZE = 30
BADDIEMAXSIZE = 60
BADDIEMINSPEED = 2
BADDIEMAXSPEED = 10
ADDNEWBADDIERATE = 6
PLAYERMOVERATE = 5

def terminate():
pygame.quit()
sys.exit()

def waitForPlayerToPressKey():
while True:
for event in pygame.event.get():
if event.type == QUIT:
terminate()
if event.type == KEYDOWN:
if event.key == K_ESCAPE: # pressing escape quits
terminate()
return

def playerHasHitBaddie(playerRect, baddies):
for b in baddies:
if playerRect.colliderect(b['rect']):
return True
return False

def drawText(text, font, surface, x, y):
textobj = font.render(text, 1, TEXTCOLOR)
textrect = textobj.get_rect()
textrect.topleft = (x, y)
surface.blit(textobj, textrect)
def centerdrawText(text, font, surface, x, y):
textobj = font.render(text, 1, TEXTCOLOR)
textrect = textobj.get_rect()
textrect.center = (x, y)
surface.blit(textobj, textrect)

set up pygame, the window, and the mouse cursor

pygame.init()
mainClock = pygame.time.Clock()
windowSurface = pygame.display.set_mode((WINDOWWIDTH, WINDOWHEIGHT))
pygame.display.set_caption('Dodger')
pygame.mouse.set_visible(False)

set up fonts

font = pygame.font.SysFont(None, 48)

set up images

playerImage = pygame.image.load('player.png')
playerRect = playerImage.get_rect()
baddieImage = pygame.image.load('baddie.png')

show the "Start" screen

centerdrawText('Halloween Dodger', font, windowSurface, (WINDOWWIDTH / 2), (WINDOWHEIGHT / 2))
drawText('Press a key to start.', font, windowSurface, (WINDOWWIDTH / 3)+30, (WINDOWHEIGHT / 3)-50)
pygame.display.update()
waitForPlayerToPressKey()
scoreaddcounter = 1

topScore = 0
while True:

'''

Comments
hotnewtop
MrVoo

Kajam didn't start yet, you don't even know what the theme is :P