SUPER BEGINNER: Check my code Printing Score is the issue
$begingroup$
This code doesn't allow me to do anything when I added a scoring method.If someone can show me how to use a class that'd be extra helpful.
import random
import pygame
import time
import os
pygame.init()
screenwd = 1200
screenht = 800
yellow = (255,255, 0)
white = (255, 255, 255)
black = (0,0,0)
carwd = 80
carht = 60
starttime = 6000
window = pygame.display.set_mode((screenwd, screenht))
pygame.display.set_caption('Spell Me')
clock = pygame.time.Clock()
starttime = 6000
carim = pygame.image.load('CAR.png')
bg = pygame.image.load('BG.jpeg')
BlockA = pygame.image.load('blockA.png')
BlockB = pygame.image.load('blockB.png')
BlockC = pygame.image.load('blockC.png')
BlockD = pygame.image.load('blockD.png')
BlockE = pygame.image.load('blockE.png')
BlockCir = pygame.image.load('blockCir.png')
BlockO = pygame.image.load('blockCir copy.png')
def objecta(objectx, objecty, objectwd, objectht):
window.blit(BlockA, (objectx, objecty, objectwd, objectht))
def objectb(objectx, objecty, objectwd, objectht):
window.blit(BlockB, (objectx, objecty, objectwd, objectht))
def objectc(objectx, objecty, objectwd, objectht):
window.blit(BlockC, (objectx, objecty, objectwd, objectht))
def objectd(objectx, objecty, objectwd, objectht):
window.blit(BlockD, (objectx, objecty, objectwd, objectht))
def objecte(objectx, objecty, objectwd, objectht):
window.blit(BlockE, (objectx, objecty, objectwd, objectht))
def objectcir(objectx, objecty, objectwd, objectht):
window.blit(BlockCir, (objectx, objecty, objectwd, objectht))
def objectO(objectx, objecty, objectwd, objectht):
window.blit(BlockO, (objectx, objecty, objectwd, objectht))
def car(carstartx,carstarty):
window.blit(carim, (carstartx, carstarty))
def msgwintext(text, font):
msgwinsurf = font.render(text, True, black)
return msgwinsurf, msgwinsurf.get_rect()
def msgwintexts(text, font):
msgwinsurfs = font.render(text, True, black)
return msgwinsurfs, msgwinsurfs.get_rect()
def messagedisplay(text):
Bigmsg = pygame.font.Font('freesansbold.ttf', 86)
msgwinsurf, msgwinrect = msgwintext(text,Bigmsg)
msgwinrect.center = ((screenwd/2),(screenht/6))
window.blit(msgwinsurf, msgwinrect)
pygame.display.update()
time.sleep(1.5)
gameloop()
def displayscore(text):
Bigmsgs = pygame.font.Font('freesansbold.ttf', 18)
msgwinsurfs, msgwinrects = msgwintexts(text,Bigmsgs)
msgwinrects.center = ((50),(50))
window.blit(msgwinsurfs, msgwinrects)
pygame.display.update()
time.sleep(1.5)
gameloop()
def crashed():
messagedisplay("You Have Crashed!")
global points
points = False
global Pscore
Pscore= 0
def Notime():
messagedisplay('You ran out of nTime!')
def score(goal):
displayscore("SCORE: " + goal)
window.blit(text, [0,0])
def gameloop():
carstartx = (screenwd * 0.45)
carstarty = (screenht * 0.92)
velx = 0
velp = 0
Pscore = 0
points = 0
aobjectsartx = random.randrange(0, screenwd)
aobjectsarty = -600
aobjectvel = 22
aobjectwidth = 100
aobjectheight = 75
bobjectsartx = random.randrange(0, screenwd)
bobjectsarty = -600
bobjectvel = 25
bobjectwidth = 100
bobjectheight = 75
cobjectsartx = random.randrange(0, screenwd)
cobjectsarty = -600
cobjectvel = 27
cobjectwidth = 100
cobjectheight = 75
dobjectsartx = random.randrange(0, screenwd)
dobjectsarty = -600
dobjectvel = 35
dobjectwidth = 100
dobjectheight = 75
eobjectsartx = random.randrange(0, screenwd)
eobjectsarty = -600
eobjectvel = 32
eobjectwidth = 100
eobjectheight = 75
objectsartx = random.randrange(0, screenwd)
objectsarty = -600
objectvel = 80
objectwidth = 80
objectheight = 55
objectsartxc = random.randrange(0, screenwd)
objectsartyc = -600
objectvelc = 85
objectwidthc = 80
objectheightc = 55
gameexit = False
while not gameexit:
#timer
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.QUIT()
quit()
if event.type == pygame.K_ESCAPE:
pygame.QUIT()
quit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
velx = -20
velp = 0.25
if event.key == pygame.K_RIGHT:
velx = 20
velp = 0.25
if event.type == pygame.KEYUP:
if event.key == pygame.K_LEFT or event.key == pygame.K_RIGHT:
velx = 0
#if event.type == pygame.KEYDOWN:
#f event.key == pygame.K_DOWN:
#vely = 15
#if event.key == pygame.K_UP:
#vely = -15
#if event.type == pygame.KEYUP:
#if event.key == pygame.K_DOWN or event.key == pygame.K_UP:
#vely = 0
carstartx += velx
points += velp
#carstarty += vely
window.fill(white)
window.blit(bg, (0,0))
objecta(aobjectsartx, aobjectsarty, aobjectwidth, aobjectheight)
objectb(bobjectsartx, bobjectsarty, bobjectwidth, bobjectheight)
objectc(cobjectsartx, cobjectsarty, cobjectwidth, cobjectheight)
objectd(dobjectsartx, dobjectsarty, dobjectwidth, dobjectheight)
objecte(eobjectsartx, eobjectsarty, eobjectwidth, eobjectheight)
objectcir(objectsartx, objectsarty, objectwidth, objectheight)
objectO(objectsartxc, objectsartyc, objectwidthc, objectheightc)
aobjectsarty += aobjectvel
bobjectsarty += bobjectvel
cobjectsarty += cobjectvel
dobjectsarty += dobjectvel
eobjectsarty += eobjectvel
objectsarty += objectvel
objectsartyc += objectvelc
car(carstartx,carstarty)
if carstartx > screenwd - carwd or carstartx < 5:
crashed()
if aobjectsarty > screenht:
aobjectsarty = 0 - aobjectheight
aobjectsartx = random.randrange(0, screenwd)
if carstarty < aobjectsarty + aobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > aobjectsartx and carstartx < aobjectsartx + aobjectheight or carstartx + carwd > aobjectsartx and carstartx + carwd < aobjectsartx + aobjectwidth:
print('x axis crossover')
crashed()
if bobjectsarty > screenht:
bobjectsarty = 0 - bobjectheight
bobjectsartx = random.randrange(0, screenwd)
if carstarty < bobjectsarty + bobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > bobjectsartx and carstartx < bobjectsartx + bobjectheight or carstartx + carwd > bobjectsartx and carstartx + carwd < bobjectsartx + bobjectwidth:
print('x axis crossover')
crashed()
if cobjectsarty > screenht:
cobjectsarty = 0 - cobjectheight
cobjectsartx = random.randrange(0, screenwd)
if carstarty < cobjectsarty + cobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > cobjectsartx and carstartx < cobjectsartx + cobjectheight or carstartx + carwd > cobjectsartx and carstartx + carwd < cobjectsartx + cobjectwidth:
print('x axis crossover')
crashed()
if dobjectsarty > screenht:
dobjectsarty = 0 - dobjectheight
dobjectsartx = random.randrange(0, screenwd)
if carstarty < dobjectsarty + dobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > dobjectsartx and carstartx < dobjectsartx + dobjectheight or carstartx + carwd > dobjectsartx and carstartx + carwd < dobjectsartx + dobjectwidth:
print('x axis crossover')
crashed()
if eobjectsarty > screenht:
eobjectsarty = 0 - eobjectheight
eobjectsartx = random.randrange(0, screenwd)
if carstarty < eobjectsarty + eobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > eobjectsartx and carstartx < eobjectsartx + eobjectheight or carstartx + carwd > eobjectsartx and carstartx + carwd < eobjectsartx + eobjectwidth:
print('x axis crossover')
crashed()
if objectsarty > screenht:
objectsarty = 0 - objectheight
objectsartx = random.randrange(0, screenwd)
if carstarty < objectsarty + objectheight:
print('y axis ')
if carstartx > objectsartx and carstartx < objectsartx + objectheight or carstartx + carwd > objectsartx and carstartx + carwd < objectsartx + objectwidth:
print('x axis crossover')
if objectsartyc > screenht:
objectsartyc = 0 - objectheightc
objectsartxc = random.randrange(0, screenwd)
points = False
while not points:
print(str(Pscore))
goal = Pscore
score(str(goal))
pygame.display.update()
clock.tick(60)
gameloop()
pygame.quit()
quit()
screenwd = 1200
screenht = 800
yellow = (255,255, 0)
white = (255, 255, 255)
black = (0,0,0)
carwd = 80
carht = 60
starttime = 6000
window = pygame.display.set_mode((screenwd, screenht))
pygame.display.set_caption('Spell Me')
clock = pygame.time.Clock()
starttime = 6000
carim = pygame.image.load('CAR.png')
bg = pygame.image.load('BG.jpeg')
BlockA = pygame.image.load('blockA.png')
BlockB = pygame.image.load('blockB.png')
BlockC = pygame.image.load('blockC.png')
BlockD = pygame.image.load('blockD.png')
BlockE = pygame.image.load('blockE.png')
BlockCir = pygame.image.load('blockCir.png')
BlockO = pygame.image.load('blockCir copy.png')
def objecta(objectx, objecty, objectwd, objectht):
window.blit(BlockA, (objectx, objecty, objectwd, objectht))
def objectb(objectx, objecty, objectwd, objectht):
window.blit(BlockB, (objectx, objecty, objectwd, objectht))
def objectc(objectx, objecty, objectwd, objectht):
window.blit(BlockC, (objectx, objecty, objectwd, objectht))
def objectd(objectx, objecty, objectwd, objectht):
window.blit(BlockD, (objectx, objecty, objectwd, objectht))
def objecte(objectx, objecty, objectwd, objectht):
window.blit(BlockE, (objectx, objecty, objectwd, objectht))
def objectcir(objectx, objecty, objectwd, objectht):
window.blit(BlockCir, (objectx, objecty, objectwd, objectht))
def objectO(objectx, objecty, objectwd, objectht):
window.blit(BlockO, (objectx, objecty, objectwd, objectht))
def car(carstartx,carstarty):
window.blit(carim, (carstartx, carstarty))
def msgwintext(text, font):
msgwinsurf = font.render(text, True, black)
return msgwinsurf, msgwinsurf.get_rect()
def msgwintexts(text, font):
msgwinsurfs = font.render(text, True, black)
return msgwinsurfs, msgwinsurfs.get_rect()
def messagedisplay(text):
Bigmsg = pygame.font.Font('freesansbold.ttf', 86)
msgwinsurf, msgwinrect = msgwintext(text,Bigmsg)
msgwinrect.center = ((screenwd/2),(screenht/6))
window.blit(msgwinsurf, msgwinrect)
pygame.display.update()
time.sleep(1.5)
gameloop()
def displayscore(text):
Bigmsgs = pygame.font.Font('freesansbold.ttf', 18)
msgwinsurfs, msgwinrects = msgwintexts(text,Bigmsgs)
msgwinrects.center = ((50),(50))
window.blit(msgwinsurfs, msgwinrects)
pygame.display.update()
time.sleep(1.5)
gameloop()
def crashed():
messagedisplay("You Have Crashed!")
global points
points = False
global Pscore
Pscore= 0
def Notime():
messagedisplay('You ran out of nTime!')
def score(goal):
displayscore("SCORE: " + goal)
window.blit(text, [0,0])
def gameloop():
carstartx = (screenwd * 0.45)
carstarty = (screenht * 0.92)
velx = 0
velp = 0
Pscore = 0
points = 0
aobjectsartx = random.randrange(0, screenwd)
aobjectsarty = -600
aobjectvel = 22
aobjectwidth = 100
aobjectheight = 75
bobjectsartx = random.randrange(0, screenwd)
bobjectsarty = -600
bobjectvel = 25
bobjectwidth = 100
bobjectheight = 75
cobjectsartx = random.randrange(0, screenwd)
cobjectsarty = -600
cobjectvel = 27
cobjectwidth = 100
cobjectheight = 75
dobjectsartx = random.randrange(0, screenwd)
dobjectsarty = -600
dobjectvel = 35
dobjectwidth = 100
dobjectheight = 75
eobjectsartx = random.randrange(0, screenwd)
eobjectsarty = -600
eobjectvel = 32
eobjectwidth = 100
eobjectheight = 75
objectsartx = random.randrange(0, screenwd)
objectsarty = -600
objectvel = 80
objectwidth = 80
objectheight = 55
objectsartxc = random.randrange(0, screenwd)
objectsartyc = -600
objectvelc = 85
objectwidthc = 80
objectheightc = 55
gameexit = False
while not gameexit:
#timer
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.QUIT()
quit()
if event.type == pygame.K_ESCAPE:
pygame.QUIT()
quit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
velx = -20
velp = 0.25
if event.key == pygame.K_RIGHT:
velx = 20
velp = 0.25
if event.type == pygame.KEYUP:
if event.key == pygame.K_LEFT or event.key == pygame.K_RIGHT:
velx = 0
#if event.type == pygame.KEYDOWN:
#f event.key == pygame.K_DOWN:
#vely = 15
#if event.key == pygame.K_UP:
#vely = -15
#if event.type == pygame.KEYUP:
#if event.key == pygame.K_DOWN or event.key == pygame.K_UP:
#vely = 0
carstartx += velx
points += velp
#carstarty += vely
window.fill(white)
window.blit(bg, (0,0))
objecta(aobjectsartx, aobjectsarty, aobjectwidth, aobjectheight)
objectb(bobjectsartx, bobjectsarty, bobjectwidth, bobjectheight)
objectc(cobjectsartx, cobjectsarty, cobjectwidth, cobjectheight)
objectd(dobjectsartx, dobjectsarty, dobjectwidth, dobjectheight)
objecte(eobjectsartx, eobjectsarty, eobjectwidth, eobjectheight)
objectcir(objectsartx, objectsarty, objectwidth, objectheight)
objectO(objectsartxc, objectsartyc, objectwidthc, objectheightc)
aobjectsarty += aobjectvel
bobjectsarty += bobjectvel
cobjectsarty += cobjectvel
dobjectsarty += dobjectvel
eobjectsarty += eobjectvel
objectsarty += objectvel
objectsartyc += objectvelc
car(carstartx,carstarty)
if carstartx > screenwd - carwd or carstartx < 5:
crashed()
if aobjectsarty > screenht:
aobjectsarty = 0 - aobjectheight
aobjectsartx = random.randrange(0, screenwd)
if carstarty < aobjectsarty + aobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > aobjectsartx and carstartx < aobjectsartx + aobjectheight or carstartx + carwd > aobjectsartx and carstartx + carwd < aobjectsartx + aobjectwidth:
print('x axis crossover')
crashed()
if bobjectsarty > screenht:
bobjectsarty = 0 - bobjectheight
bobjectsartx = random.randrange(0, screenwd)
if carstarty < bobjectsarty + bobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > bobjectsartx and carstartx < bobjectsartx + bobjectheight or carstartx + carwd > bobjectsartx and carstartx + carwd < bobjectsartx + bobjectwidth:
print('x axis crossover')
crashed()
if cobjectsarty > screenht:
cobjectsarty = 0 - cobjectheight
cobjectsartx = random.randrange(0, screenwd)
if carstarty < cobjectsarty + cobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > cobjectsartx and carstartx < cobjectsartx + cobjectheight or carstartx + carwd > cobjectsartx and carstartx + carwd < cobjectsartx + cobjectwidth:
print('x axis crossover')
crashed()
if dobjectsarty > screenht:
dobjectsarty = 0 - dobjectheight
dobjectsartx = random.randrange(0, screenwd)
if carstarty < dobjectsarty + dobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > dobjectsartx and carstartx < dobjectsartx + dobjectheight or carstartx + carwd > dobjectsartx and carstartx + carwd < dobjectsartx + dobjectwidth:
print('x axis crossover')
crashed()
if eobjectsarty > screenht:
eobjectsarty = 0 - eobjectheight
eobjectsartx = random.randrange(0, screenwd)
if carstarty < eobjectsarty + eobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > eobjectsartx and carstartx < eobjectsartx + eobjectheight or carstartx + carwd > eobjectsartx and carstartx + carwd < eobjectsartx + eobjectwidth:
print('x axis crossover')
crashed()
if objectsarty > screenht:
objectsarty = 0 - objectheight
objectsartx = random.randrange(0, screenwd)
if carstarty < objectsarty + objectheight:
print('y axis ')
if carstartx > objectsartx and carstartx < objectsartx + objectheight or carstartx + carwd > objectsartx and carstartx + carwd < objectsartx + objectwidth:
print('x axis crossover')
if objectsartyc > screenht:
objectsartyc = 0 - objectheightc
objectsartxc = random.randrange(0, screenwd)
points = False
while not points:
print(str(Pscore))
goal = Pscore
score(str(goal))
pygame.display.update()
clock.tick(60)
gameloop()
pygame.quit()
quit()
python pygame
New contributor
$endgroup$
add a comment |
$begingroup$
This code doesn't allow me to do anything when I added a scoring method.If someone can show me how to use a class that'd be extra helpful.
import random
import pygame
import time
import os
pygame.init()
screenwd = 1200
screenht = 800
yellow = (255,255, 0)
white = (255, 255, 255)
black = (0,0,0)
carwd = 80
carht = 60
starttime = 6000
window = pygame.display.set_mode((screenwd, screenht))
pygame.display.set_caption('Spell Me')
clock = pygame.time.Clock()
starttime = 6000
carim = pygame.image.load('CAR.png')
bg = pygame.image.load('BG.jpeg')
BlockA = pygame.image.load('blockA.png')
BlockB = pygame.image.load('blockB.png')
BlockC = pygame.image.load('blockC.png')
BlockD = pygame.image.load('blockD.png')
BlockE = pygame.image.load('blockE.png')
BlockCir = pygame.image.load('blockCir.png')
BlockO = pygame.image.load('blockCir copy.png')
def objecta(objectx, objecty, objectwd, objectht):
window.blit(BlockA, (objectx, objecty, objectwd, objectht))
def objectb(objectx, objecty, objectwd, objectht):
window.blit(BlockB, (objectx, objecty, objectwd, objectht))
def objectc(objectx, objecty, objectwd, objectht):
window.blit(BlockC, (objectx, objecty, objectwd, objectht))
def objectd(objectx, objecty, objectwd, objectht):
window.blit(BlockD, (objectx, objecty, objectwd, objectht))
def objecte(objectx, objecty, objectwd, objectht):
window.blit(BlockE, (objectx, objecty, objectwd, objectht))
def objectcir(objectx, objecty, objectwd, objectht):
window.blit(BlockCir, (objectx, objecty, objectwd, objectht))
def objectO(objectx, objecty, objectwd, objectht):
window.blit(BlockO, (objectx, objecty, objectwd, objectht))
def car(carstartx,carstarty):
window.blit(carim, (carstartx, carstarty))
def msgwintext(text, font):
msgwinsurf = font.render(text, True, black)
return msgwinsurf, msgwinsurf.get_rect()
def msgwintexts(text, font):
msgwinsurfs = font.render(text, True, black)
return msgwinsurfs, msgwinsurfs.get_rect()
def messagedisplay(text):
Bigmsg = pygame.font.Font('freesansbold.ttf', 86)
msgwinsurf, msgwinrect = msgwintext(text,Bigmsg)
msgwinrect.center = ((screenwd/2),(screenht/6))
window.blit(msgwinsurf, msgwinrect)
pygame.display.update()
time.sleep(1.5)
gameloop()
def displayscore(text):
Bigmsgs = pygame.font.Font('freesansbold.ttf', 18)
msgwinsurfs, msgwinrects = msgwintexts(text,Bigmsgs)
msgwinrects.center = ((50),(50))
window.blit(msgwinsurfs, msgwinrects)
pygame.display.update()
time.sleep(1.5)
gameloop()
def crashed():
messagedisplay("You Have Crashed!")
global points
points = False
global Pscore
Pscore= 0
def Notime():
messagedisplay('You ran out of nTime!')
def score(goal):
displayscore("SCORE: " + goal)
window.blit(text, [0,0])
def gameloop():
carstartx = (screenwd * 0.45)
carstarty = (screenht * 0.92)
velx = 0
velp = 0
Pscore = 0
points = 0
aobjectsartx = random.randrange(0, screenwd)
aobjectsarty = -600
aobjectvel = 22
aobjectwidth = 100
aobjectheight = 75
bobjectsartx = random.randrange(0, screenwd)
bobjectsarty = -600
bobjectvel = 25
bobjectwidth = 100
bobjectheight = 75
cobjectsartx = random.randrange(0, screenwd)
cobjectsarty = -600
cobjectvel = 27
cobjectwidth = 100
cobjectheight = 75
dobjectsartx = random.randrange(0, screenwd)
dobjectsarty = -600
dobjectvel = 35
dobjectwidth = 100
dobjectheight = 75
eobjectsartx = random.randrange(0, screenwd)
eobjectsarty = -600
eobjectvel = 32
eobjectwidth = 100
eobjectheight = 75
objectsartx = random.randrange(0, screenwd)
objectsarty = -600
objectvel = 80
objectwidth = 80
objectheight = 55
objectsartxc = random.randrange(0, screenwd)
objectsartyc = -600
objectvelc = 85
objectwidthc = 80
objectheightc = 55
gameexit = False
while not gameexit:
#timer
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.QUIT()
quit()
if event.type == pygame.K_ESCAPE:
pygame.QUIT()
quit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
velx = -20
velp = 0.25
if event.key == pygame.K_RIGHT:
velx = 20
velp = 0.25
if event.type == pygame.KEYUP:
if event.key == pygame.K_LEFT or event.key == pygame.K_RIGHT:
velx = 0
#if event.type == pygame.KEYDOWN:
#f event.key == pygame.K_DOWN:
#vely = 15
#if event.key == pygame.K_UP:
#vely = -15
#if event.type == pygame.KEYUP:
#if event.key == pygame.K_DOWN or event.key == pygame.K_UP:
#vely = 0
carstartx += velx
points += velp
#carstarty += vely
window.fill(white)
window.blit(bg, (0,0))
objecta(aobjectsartx, aobjectsarty, aobjectwidth, aobjectheight)
objectb(bobjectsartx, bobjectsarty, bobjectwidth, bobjectheight)
objectc(cobjectsartx, cobjectsarty, cobjectwidth, cobjectheight)
objectd(dobjectsartx, dobjectsarty, dobjectwidth, dobjectheight)
objecte(eobjectsartx, eobjectsarty, eobjectwidth, eobjectheight)
objectcir(objectsartx, objectsarty, objectwidth, objectheight)
objectO(objectsartxc, objectsartyc, objectwidthc, objectheightc)
aobjectsarty += aobjectvel
bobjectsarty += bobjectvel
cobjectsarty += cobjectvel
dobjectsarty += dobjectvel
eobjectsarty += eobjectvel
objectsarty += objectvel
objectsartyc += objectvelc
car(carstartx,carstarty)
if carstartx > screenwd - carwd or carstartx < 5:
crashed()
if aobjectsarty > screenht:
aobjectsarty = 0 - aobjectheight
aobjectsartx = random.randrange(0, screenwd)
if carstarty < aobjectsarty + aobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > aobjectsartx and carstartx < aobjectsartx + aobjectheight or carstartx + carwd > aobjectsartx and carstartx + carwd < aobjectsartx + aobjectwidth:
print('x axis crossover')
crashed()
if bobjectsarty > screenht:
bobjectsarty = 0 - bobjectheight
bobjectsartx = random.randrange(0, screenwd)
if carstarty < bobjectsarty + bobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > bobjectsartx and carstartx < bobjectsartx + bobjectheight or carstartx + carwd > bobjectsartx and carstartx + carwd < bobjectsartx + bobjectwidth:
print('x axis crossover')
crashed()
if cobjectsarty > screenht:
cobjectsarty = 0 - cobjectheight
cobjectsartx = random.randrange(0, screenwd)
if carstarty < cobjectsarty + cobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > cobjectsartx and carstartx < cobjectsartx + cobjectheight or carstartx + carwd > cobjectsartx and carstartx + carwd < cobjectsartx + cobjectwidth:
print('x axis crossover')
crashed()
if dobjectsarty > screenht:
dobjectsarty = 0 - dobjectheight
dobjectsartx = random.randrange(0, screenwd)
if carstarty < dobjectsarty + dobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > dobjectsartx and carstartx < dobjectsartx + dobjectheight or carstartx + carwd > dobjectsartx and carstartx + carwd < dobjectsartx + dobjectwidth:
print('x axis crossover')
crashed()
if eobjectsarty > screenht:
eobjectsarty = 0 - eobjectheight
eobjectsartx = random.randrange(0, screenwd)
if carstarty < eobjectsarty + eobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > eobjectsartx and carstartx < eobjectsartx + eobjectheight or carstartx + carwd > eobjectsartx and carstartx + carwd < eobjectsartx + eobjectwidth:
print('x axis crossover')
crashed()
if objectsarty > screenht:
objectsarty = 0 - objectheight
objectsartx = random.randrange(0, screenwd)
if carstarty < objectsarty + objectheight:
print('y axis ')
if carstartx > objectsartx and carstartx < objectsartx + objectheight or carstartx + carwd > objectsartx and carstartx + carwd < objectsartx + objectwidth:
print('x axis crossover')
if objectsartyc > screenht:
objectsartyc = 0 - objectheightc
objectsartxc = random.randrange(0, screenwd)
points = False
while not points:
print(str(Pscore))
goal = Pscore
score(str(goal))
pygame.display.update()
clock.tick(60)
gameloop()
pygame.quit()
quit()
screenwd = 1200
screenht = 800
yellow = (255,255, 0)
white = (255, 255, 255)
black = (0,0,0)
carwd = 80
carht = 60
starttime = 6000
window = pygame.display.set_mode((screenwd, screenht))
pygame.display.set_caption('Spell Me')
clock = pygame.time.Clock()
starttime = 6000
carim = pygame.image.load('CAR.png')
bg = pygame.image.load('BG.jpeg')
BlockA = pygame.image.load('blockA.png')
BlockB = pygame.image.load('blockB.png')
BlockC = pygame.image.load('blockC.png')
BlockD = pygame.image.load('blockD.png')
BlockE = pygame.image.load('blockE.png')
BlockCir = pygame.image.load('blockCir.png')
BlockO = pygame.image.load('blockCir copy.png')
def objecta(objectx, objecty, objectwd, objectht):
window.blit(BlockA, (objectx, objecty, objectwd, objectht))
def objectb(objectx, objecty, objectwd, objectht):
window.blit(BlockB, (objectx, objecty, objectwd, objectht))
def objectc(objectx, objecty, objectwd, objectht):
window.blit(BlockC, (objectx, objecty, objectwd, objectht))
def objectd(objectx, objecty, objectwd, objectht):
window.blit(BlockD, (objectx, objecty, objectwd, objectht))
def objecte(objectx, objecty, objectwd, objectht):
window.blit(BlockE, (objectx, objecty, objectwd, objectht))
def objectcir(objectx, objecty, objectwd, objectht):
window.blit(BlockCir, (objectx, objecty, objectwd, objectht))
def objectO(objectx, objecty, objectwd, objectht):
window.blit(BlockO, (objectx, objecty, objectwd, objectht))
def car(carstartx,carstarty):
window.blit(carim, (carstartx, carstarty))
def msgwintext(text, font):
msgwinsurf = font.render(text, True, black)
return msgwinsurf, msgwinsurf.get_rect()
def msgwintexts(text, font):
msgwinsurfs = font.render(text, True, black)
return msgwinsurfs, msgwinsurfs.get_rect()
def messagedisplay(text):
Bigmsg = pygame.font.Font('freesansbold.ttf', 86)
msgwinsurf, msgwinrect = msgwintext(text,Bigmsg)
msgwinrect.center = ((screenwd/2),(screenht/6))
window.blit(msgwinsurf, msgwinrect)
pygame.display.update()
time.sleep(1.5)
gameloop()
def displayscore(text):
Bigmsgs = pygame.font.Font('freesansbold.ttf', 18)
msgwinsurfs, msgwinrects = msgwintexts(text,Bigmsgs)
msgwinrects.center = ((50),(50))
window.blit(msgwinsurfs, msgwinrects)
pygame.display.update()
time.sleep(1.5)
gameloop()
def crashed():
messagedisplay("You Have Crashed!")
global points
points = False
global Pscore
Pscore= 0
def Notime():
messagedisplay('You ran out of nTime!')
def score(goal):
displayscore("SCORE: " + goal)
window.blit(text, [0,0])
def gameloop():
carstartx = (screenwd * 0.45)
carstarty = (screenht * 0.92)
velx = 0
velp = 0
Pscore = 0
points = 0
aobjectsartx = random.randrange(0, screenwd)
aobjectsarty = -600
aobjectvel = 22
aobjectwidth = 100
aobjectheight = 75
bobjectsartx = random.randrange(0, screenwd)
bobjectsarty = -600
bobjectvel = 25
bobjectwidth = 100
bobjectheight = 75
cobjectsartx = random.randrange(0, screenwd)
cobjectsarty = -600
cobjectvel = 27
cobjectwidth = 100
cobjectheight = 75
dobjectsartx = random.randrange(0, screenwd)
dobjectsarty = -600
dobjectvel = 35
dobjectwidth = 100
dobjectheight = 75
eobjectsartx = random.randrange(0, screenwd)
eobjectsarty = -600
eobjectvel = 32
eobjectwidth = 100
eobjectheight = 75
objectsartx = random.randrange(0, screenwd)
objectsarty = -600
objectvel = 80
objectwidth = 80
objectheight = 55
objectsartxc = random.randrange(0, screenwd)
objectsartyc = -600
objectvelc = 85
objectwidthc = 80
objectheightc = 55
gameexit = False
while not gameexit:
#timer
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.QUIT()
quit()
if event.type == pygame.K_ESCAPE:
pygame.QUIT()
quit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
velx = -20
velp = 0.25
if event.key == pygame.K_RIGHT:
velx = 20
velp = 0.25
if event.type == pygame.KEYUP:
if event.key == pygame.K_LEFT or event.key == pygame.K_RIGHT:
velx = 0
#if event.type == pygame.KEYDOWN:
#f event.key == pygame.K_DOWN:
#vely = 15
#if event.key == pygame.K_UP:
#vely = -15
#if event.type == pygame.KEYUP:
#if event.key == pygame.K_DOWN or event.key == pygame.K_UP:
#vely = 0
carstartx += velx
points += velp
#carstarty += vely
window.fill(white)
window.blit(bg, (0,0))
objecta(aobjectsartx, aobjectsarty, aobjectwidth, aobjectheight)
objectb(bobjectsartx, bobjectsarty, bobjectwidth, bobjectheight)
objectc(cobjectsartx, cobjectsarty, cobjectwidth, cobjectheight)
objectd(dobjectsartx, dobjectsarty, dobjectwidth, dobjectheight)
objecte(eobjectsartx, eobjectsarty, eobjectwidth, eobjectheight)
objectcir(objectsartx, objectsarty, objectwidth, objectheight)
objectO(objectsartxc, objectsartyc, objectwidthc, objectheightc)
aobjectsarty += aobjectvel
bobjectsarty += bobjectvel
cobjectsarty += cobjectvel
dobjectsarty += dobjectvel
eobjectsarty += eobjectvel
objectsarty += objectvel
objectsartyc += objectvelc
car(carstartx,carstarty)
if carstartx > screenwd - carwd or carstartx < 5:
crashed()
if aobjectsarty > screenht:
aobjectsarty = 0 - aobjectheight
aobjectsartx = random.randrange(0, screenwd)
if carstarty < aobjectsarty + aobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > aobjectsartx and carstartx < aobjectsartx + aobjectheight or carstartx + carwd > aobjectsartx and carstartx + carwd < aobjectsartx + aobjectwidth:
print('x axis crossover')
crashed()
if bobjectsarty > screenht:
bobjectsarty = 0 - bobjectheight
bobjectsartx = random.randrange(0, screenwd)
if carstarty < bobjectsarty + bobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > bobjectsartx and carstartx < bobjectsartx + bobjectheight or carstartx + carwd > bobjectsartx and carstartx + carwd < bobjectsartx + bobjectwidth:
print('x axis crossover')
crashed()
if cobjectsarty > screenht:
cobjectsarty = 0 - cobjectheight
cobjectsartx = random.randrange(0, screenwd)
if carstarty < cobjectsarty + cobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > cobjectsartx and carstartx < cobjectsartx + cobjectheight or carstartx + carwd > cobjectsartx and carstartx + carwd < cobjectsartx + cobjectwidth:
print('x axis crossover')
crashed()
if dobjectsarty > screenht:
dobjectsarty = 0 - dobjectheight
dobjectsartx = random.randrange(0, screenwd)
if carstarty < dobjectsarty + dobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > dobjectsartx and carstartx < dobjectsartx + dobjectheight or carstartx + carwd > dobjectsartx and carstartx + carwd < dobjectsartx + dobjectwidth:
print('x axis crossover')
crashed()
if eobjectsarty > screenht:
eobjectsarty = 0 - eobjectheight
eobjectsartx = random.randrange(0, screenwd)
if carstarty < eobjectsarty + eobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > eobjectsartx and carstartx < eobjectsartx + eobjectheight or carstartx + carwd > eobjectsartx and carstartx + carwd < eobjectsartx + eobjectwidth:
print('x axis crossover')
crashed()
if objectsarty > screenht:
objectsarty = 0 - objectheight
objectsartx = random.randrange(0, screenwd)
if carstarty < objectsarty + objectheight:
print('y axis ')
if carstartx > objectsartx and carstartx < objectsartx + objectheight or carstartx + carwd > objectsartx and carstartx + carwd < objectsartx + objectwidth:
print('x axis crossover')
if objectsartyc > screenht:
objectsartyc = 0 - objectheightc
objectsartxc = random.randrange(0, screenwd)
points = False
while not points:
print(str(Pscore))
goal = Pscore
score(str(goal))
pygame.display.update()
clock.tick(60)
gameloop()
pygame.quit()
quit()
python pygame
New contributor
$endgroup$
$begingroup$
I'm sorry we don't help people write new code or fix broken code. We review working code in an effort to make it better. Once you figure out what you need to make it work bring it back and we can then provide feedback.
$endgroup$
– bruglesco
2 mins ago
add a comment |
$begingroup$
This code doesn't allow me to do anything when I added a scoring method.If someone can show me how to use a class that'd be extra helpful.
import random
import pygame
import time
import os
pygame.init()
screenwd = 1200
screenht = 800
yellow = (255,255, 0)
white = (255, 255, 255)
black = (0,0,0)
carwd = 80
carht = 60
starttime = 6000
window = pygame.display.set_mode((screenwd, screenht))
pygame.display.set_caption('Spell Me')
clock = pygame.time.Clock()
starttime = 6000
carim = pygame.image.load('CAR.png')
bg = pygame.image.load('BG.jpeg')
BlockA = pygame.image.load('blockA.png')
BlockB = pygame.image.load('blockB.png')
BlockC = pygame.image.load('blockC.png')
BlockD = pygame.image.load('blockD.png')
BlockE = pygame.image.load('blockE.png')
BlockCir = pygame.image.load('blockCir.png')
BlockO = pygame.image.load('blockCir copy.png')
def objecta(objectx, objecty, objectwd, objectht):
window.blit(BlockA, (objectx, objecty, objectwd, objectht))
def objectb(objectx, objecty, objectwd, objectht):
window.blit(BlockB, (objectx, objecty, objectwd, objectht))
def objectc(objectx, objecty, objectwd, objectht):
window.blit(BlockC, (objectx, objecty, objectwd, objectht))
def objectd(objectx, objecty, objectwd, objectht):
window.blit(BlockD, (objectx, objecty, objectwd, objectht))
def objecte(objectx, objecty, objectwd, objectht):
window.blit(BlockE, (objectx, objecty, objectwd, objectht))
def objectcir(objectx, objecty, objectwd, objectht):
window.blit(BlockCir, (objectx, objecty, objectwd, objectht))
def objectO(objectx, objecty, objectwd, objectht):
window.blit(BlockO, (objectx, objecty, objectwd, objectht))
def car(carstartx,carstarty):
window.blit(carim, (carstartx, carstarty))
def msgwintext(text, font):
msgwinsurf = font.render(text, True, black)
return msgwinsurf, msgwinsurf.get_rect()
def msgwintexts(text, font):
msgwinsurfs = font.render(text, True, black)
return msgwinsurfs, msgwinsurfs.get_rect()
def messagedisplay(text):
Bigmsg = pygame.font.Font('freesansbold.ttf', 86)
msgwinsurf, msgwinrect = msgwintext(text,Bigmsg)
msgwinrect.center = ((screenwd/2),(screenht/6))
window.blit(msgwinsurf, msgwinrect)
pygame.display.update()
time.sleep(1.5)
gameloop()
def displayscore(text):
Bigmsgs = pygame.font.Font('freesansbold.ttf', 18)
msgwinsurfs, msgwinrects = msgwintexts(text,Bigmsgs)
msgwinrects.center = ((50),(50))
window.blit(msgwinsurfs, msgwinrects)
pygame.display.update()
time.sleep(1.5)
gameloop()
def crashed():
messagedisplay("You Have Crashed!")
global points
points = False
global Pscore
Pscore= 0
def Notime():
messagedisplay('You ran out of nTime!')
def score(goal):
displayscore("SCORE: " + goal)
window.blit(text, [0,0])
def gameloop():
carstartx = (screenwd * 0.45)
carstarty = (screenht * 0.92)
velx = 0
velp = 0
Pscore = 0
points = 0
aobjectsartx = random.randrange(0, screenwd)
aobjectsarty = -600
aobjectvel = 22
aobjectwidth = 100
aobjectheight = 75
bobjectsartx = random.randrange(0, screenwd)
bobjectsarty = -600
bobjectvel = 25
bobjectwidth = 100
bobjectheight = 75
cobjectsartx = random.randrange(0, screenwd)
cobjectsarty = -600
cobjectvel = 27
cobjectwidth = 100
cobjectheight = 75
dobjectsartx = random.randrange(0, screenwd)
dobjectsarty = -600
dobjectvel = 35
dobjectwidth = 100
dobjectheight = 75
eobjectsartx = random.randrange(0, screenwd)
eobjectsarty = -600
eobjectvel = 32
eobjectwidth = 100
eobjectheight = 75
objectsartx = random.randrange(0, screenwd)
objectsarty = -600
objectvel = 80
objectwidth = 80
objectheight = 55
objectsartxc = random.randrange(0, screenwd)
objectsartyc = -600
objectvelc = 85
objectwidthc = 80
objectheightc = 55
gameexit = False
while not gameexit:
#timer
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.QUIT()
quit()
if event.type == pygame.K_ESCAPE:
pygame.QUIT()
quit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
velx = -20
velp = 0.25
if event.key == pygame.K_RIGHT:
velx = 20
velp = 0.25
if event.type == pygame.KEYUP:
if event.key == pygame.K_LEFT or event.key == pygame.K_RIGHT:
velx = 0
#if event.type == pygame.KEYDOWN:
#f event.key == pygame.K_DOWN:
#vely = 15
#if event.key == pygame.K_UP:
#vely = -15
#if event.type == pygame.KEYUP:
#if event.key == pygame.K_DOWN or event.key == pygame.K_UP:
#vely = 0
carstartx += velx
points += velp
#carstarty += vely
window.fill(white)
window.blit(bg, (0,0))
objecta(aobjectsartx, aobjectsarty, aobjectwidth, aobjectheight)
objectb(bobjectsartx, bobjectsarty, bobjectwidth, bobjectheight)
objectc(cobjectsartx, cobjectsarty, cobjectwidth, cobjectheight)
objectd(dobjectsartx, dobjectsarty, dobjectwidth, dobjectheight)
objecte(eobjectsartx, eobjectsarty, eobjectwidth, eobjectheight)
objectcir(objectsartx, objectsarty, objectwidth, objectheight)
objectO(objectsartxc, objectsartyc, objectwidthc, objectheightc)
aobjectsarty += aobjectvel
bobjectsarty += bobjectvel
cobjectsarty += cobjectvel
dobjectsarty += dobjectvel
eobjectsarty += eobjectvel
objectsarty += objectvel
objectsartyc += objectvelc
car(carstartx,carstarty)
if carstartx > screenwd - carwd or carstartx < 5:
crashed()
if aobjectsarty > screenht:
aobjectsarty = 0 - aobjectheight
aobjectsartx = random.randrange(0, screenwd)
if carstarty < aobjectsarty + aobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > aobjectsartx and carstartx < aobjectsartx + aobjectheight or carstartx + carwd > aobjectsartx and carstartx + carwd < aobjectsartx + aobjectwidth:
print('x axis crossover')
crashed()
if bobjectsarty > screenht:
bobjectsarty = 0 - bobjectheight
bobjectsartx = random.randrange(0, screenwd)
if carstarty < bobjectsarty + bobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > bobjectsartx and carstartx < bobjectsartx + bobjectheight or carstartx + carwd > bobjectsartx and carstartx + carwd < bobjectsartx + bobjectwidth:
print('x axis crossover')
crashed()
if cobjectsarty > screenht:
cobjectsarty = 0 - cobjectheight
cobjectsartx = random.randrange(0, screenwd)
if carstarty < cobjectsarty + cobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > cobjectsartx and carstartx < cobjectsartx + cobjectheight or carstartx + carwd > cobjectsartx and carstartx + carwd < cobjectsartx + cobjectwidth:
print('x axis crossover')
crashed()
if dobjectsarty > screenht:
dobjectsarty = 0 - dobjectheight
dobjectsartx = random.randrange(0, screenwd)
if carstarty < dobjectsarty + dobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > dobjectsartx and carstartx < dobjectsartx + dobjectheight or carstartx + carwd > dobjectsartx and carstartx + carwd < dobjectsartx + dobjectwidth:
print('x axis crossover')
crashed()
if eobjectsarty > screenht:
eobjectsarty = 0 - eobjectheight
eobjectsartx = random.randrange(0, screenwd)
if carstarty < eobjectsarty + eobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > eobjectsartx and carstartx < eobjectsartx + eobjectheight or carstartx + carwd > eobjectsartx and carstartx + carwd < eobjectsartx + eobjectwidth:
print('x axis crossover')
crashed()
if objectsarty > screenht:
objectsarty = 0 - objectheight
objectsartx = random.randrange(0, screenwd)
if carstarty < objectsarty + objectheight:
print('y axis ')
if carstartx > objectsartx and carstartx < objectsartx + objectheight or carstartx + carwd > objectsartx and carstartx + carwd < objectsartx + objectwidth:
print('x axis crossover')
if objectsartyc > screenht:
objectsartyc = 0 - objectheightc
objectsartxc = random.randrange(0, screenwd)
points = False
while not points:
print(str(Pscore))
goal = Pscore
score(str(goal))
pygame.display.update()
clock.tick(60)
gameloop()
pygame.quit()
quit()
screenwd = 1200
screenht = 800
yellow = (255,255, 0)
white = (255, 255, 255)
black = (0,0,0)
carwd = 80
carht = 60
starttime = 6000
window = pygame.display.set_mode((screenwd, screenht))
pygame.display.set_caption('Spell Me')
clock = pygame.time.Clock()
starttime = 6000
carim = pygame.image.load('CAR.png')
bg = pygame.image.load('BG.jpeg')
BlockA = pygame.image.load('blockA.png')
BlockB = pygame.image.load('blockB.png')
BlockC = pygame.image.load('blockC.png')
BlockD = pygame.image.load('blockD.png')
BlockE = pygame.image.load('blockE.png')
BlockCir = pygame.image.load('blockCir.png')
BlockO = pygame.image.load('blockCir copy.png')
def objecta(objectx, objecty, objectwd, objectht):
window.blit(BlockA, (objectx, objecty, objectwd, objectht))
def objectb(objectx, objecty, objectwd, objectht):
window.blit(BlockB, (objectx, objecty, objectwd, objectht))
def objectc(objectx, objecty, objectwd, objectht):
window.blit(BlockC, (objectx, objecty, objectwd, objectht))
def objectd(objectx, objecty, objectwd, objectht):
window.blit(BlockD, (objectx, objecty, objectwd, objectht))
def objecte(objectx, objecty, objectwd, objectht):
window.blit(BlockE, (objectx, objecty, objectwd, objectht))
def objectcir(objectx, objecty, objectwd, objectht):
window.blit(BlockCir, (objectx, objecty, objectwd, objectht))
def objectO(objectx, objecty, objectwd, objectht):
window.blit(BlockO, (objectx, objecty, objectwd, objectht))
def car(carstartx,carstarty):
window.blit(carim, (carstartx, carstarty))
def msgwintext(text, font):
msgwinsurf = font.render(text, True, black)
return msgwinsurf, msgwinsurf.get_rect()
def msgwintexts(text, font):
msgwinsurfs = font.render(text, True, black)
return msgwinsurfs, msgwinsurfs.get_rect()
def messagedisplay(text):
Bigmsg = pygame.font.Font('freesansbold.ttf', 86)
msgwinsurf, msgwinrect = msgwintext(text,Bigmsg)
msgwinrect.center = ((screenwd/2),(screenht/6))
window.blit(msgwinsurf, msgwinrect)
pygame.display.update()
time.sleep(1.5)
gameloop()
def displayscore(text):
Bigmsgs = pygame.font.Font('freesansbold.ttf', 18)
msgwinsurfs, msgwinrects = msgwintexts(text,Bigmsgs)
msgwinrects.center = ((50),(50))
window.blit(msgwinsurfs, msgwinrects)
pygame.display.update()
time.sleep(1.5)
gameloop()
def crashed():
messagedisplay("You Have Crashed!")
global points
points = False
global Pscore
Pscore= 0
def Notime():
messagedisplay('You ran out of nTime!')
def score(goal):
displayscore("SCORE: " + goal)
window.blit(text, [0,0])
def gameloop():
carstartx = (screenwd * 0.45)
carstarty = (screenht * 0.92)
velx = 0
velp = 0
Pscore = 0
points = 0
aobjectsartx = random.randrange(0, screenwd)
aobjectsarty = -600
aobjectvel = 22
aobjectwidth = 100
aobjectheight = 75
bobjectsartx = random.randrange(0, screenwd)
bobjectsarty = -600
bobjectvel = 25
bobjectwidth = 100
bobjectheight = 75
cobjectsartx = random.randrange(0, screenwd)
cobjectsarty = -600
cobjectvel = 27
cobjectwidth = 100
cobjectheight = 75
dobjectsartx = random.randrange(0, screenwd)
dobjectsarty = -600
dobjectvel = 35
dobjectwidth = 100
dobjectheight = 75
eobjectsartx = random.randrange(0, screenwd)
eobjectsarty = -600
eobjectvel = 32
eobjectwidth = 100
eobjectheight = 75
objectsartx = random.randrange(0, screenwd)
objectsarty = -600
objectvel = 80
objectwidth = 80
objectheight = 55
objectsartxc = random.randrange(0, screenwd)
objectsartyc = -600
objectvelc = 85
objectwidthc = 80
objectheightc = 55
gameexit = False
while not gameexit:
#timer
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.QUIT()
quit()
if event.type == pygame.K_ESCAPE:
pygame.QUIT()
quit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
velx = -20
velp = 0.25
if event.key == pygame.K_RIGHT:
velx = 20
velp = 0.25
if event.type == pygame.KEYUP:
if event.key == pygame.K_LEFT or event.key == pygame.K_RIGHT:
velx = 0
#if event.type == pygame.KEYDOWN:
#f event.key == pygame.K_DOWN:
#vely = 15
#if event.key == pygame.K_UP:
#vely = -15
#if event.type == pygame.KEYUP:
#if event.key == pygame.K_DOWN or event.key == pygame.K_UP:
#vely = 0
carstartx += velx
points += velp
#carstarty += vely
window.fill(white)
window.blit(bg, (0,0))
objecta(aobjectsartx, aobjectsarty, aobjectwidth, aobjectheight)
objectb(bobjectsartx, bobjectsarty, bobjectwidth, bobjectheight)
objectc(cobjectsartx, cobjectsarty, cobjectwidth, cobjectheight)
objectd(dobjectsartx, dobjectsarty, dobjectwidth, dobjectheight)
objecte(eobjectsartx, eobjectsarty, eobjectwidth, eobjectheight)
objectcir(objectsartx, objectsarty, objectwidth, objectheight)
objectO(objectsartxc, objectsartyc, objectwidthc, objectheightc)
aobjectsarty += aobjectvel
bobjectsarty += bobjectvel
cobjectsarty += cobjectvel
dobjectsarty += dobjectvel
eobjectsarty += eobjectvel
objectsarty += objectvel
objectsartyc += objectvelc
car(carstartx,carstarty)
if carstartx > screenwd - carwd or carstartx < 5:
crashed()
if aobjectsarty > screenht:
aobjectsarty = 0 - aobjectheight
aobjectsartx = random.randrange(0, screenwd)
if carstarty < aobjectsarty + aobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > aobjectsartx and carstartx < aobjectsartx + aobjectheight or carstartx + carwd > aobjectsartx and carstartx + carwd < aobjectsartx + aobjectwidth:
print('x axis crossover')
crashed()
if bobjectsarty > screenht:
bobjectsarty = 0 - bobjectheight
bobjectsartx = random.randrange(0, screenwd)
if carstarty < bobjectsarty + bobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > bobjectsartx and carstartx < bobjectsartx + bobjectheight or carstartx + carwd > bobjectsartx and carstartx + carwd < bobjectsartx + bobjectwidth:
print('x axis crossover')
crashed()
if cobjectsarty > screenht:
cobjectsarty = 0 - cobjectheight
cobjectsartx = random.randrange(0, screenwd)
if carstarty < cobjectsarty + cobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > cobjectsartx and carstartx < cobjectsartx + cobjectheight or carstartx + carwd > cobjectsartx and carstartx + carwd < cobjectsartx + cobjectwidth:
print('x axis crossover')
crashed()
if dobjectsarty > screenht:
dobjectsarty = 0 - dobjectheight
dobjectsartx = random.randrange(0, screenwd)
if carstarty < dobjectsarty + dobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > dobjectsartx and carstartx < dobjectsartx + dobjectheight or carstartx + carwd > dobjectsartx and carstartx + carwd < dobjectsartx + dobjectwidth:
print('x axis crossover')
crashed()
if eobjectsarty > screenht:
eobjectsarty = 0 - eobjectheight
eobjectsartx = random.randrange(0, screenwd)
if carstarty < eobjectsarty + eobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > eobjectsartx and carstartx < eobjectsartx + eobjectheight or carstartx + carwd > eobjectsartx and carstartx + carwd < eobjectsartx + eobjectwidth:
print('x axis crossover')
crashed()
if objectsarty > screenht:
objectsarty = 0 - objectheight
objectsartx = random.randrange(0, screenwd)
if carstarty < objectsarty + objectheight:
print('y axis ')
if carstartx > objectsartx and carstartx < objectsartx + objectheight or carstartx + carwd > objectsartx and carstartx + carwd < objectsartx + objectwidth:
print('x axis crossover')
if objectsartyc > screenht:
objectsartyc = 0 - objectheightc
objectsartxc = random.randrange(0, screenwd)
points = False
while not points:
print(str(Pscore))
goal = Pscore
score(str(goal))
pygame.display.update()
clock.tick(60)
gameloop()
pygame.quit()
quit()
python pygame
New contributor
$endgroup$
This code doesn't allow me to do anything when I added a scoring method.If someone can show me how to use a class that'd be extra helpful.
import random
import pygame
import time
import os
pygame.init()
screenwd = 1200
screenht = 800
yellow = (255,255, 0)
white = (255, 255, 255)
black = (0,0,0)
carwd = 80
carht = 60
starttime = 6000
window = pygame.display.set_mode((screenwd, screenht))
pygame.display.set_caption('Spell Me')
clock = pygame.time.Clock()
starttime = 6000
carim = pygame.image.load('CAR.png')
bg = pygame.image.load('BG.jpeg')
BlockA = pygame.image.load('blockA.png')
BlockB = pygame.image.load('blockB.png')
BlockC = pygame.image.load('blockC.png')
BlockD = pygame.image.load('blockD.png')
BlockE = pygame.image.load('blockE.png')
BlockCir = pygame.image.load('blockCir.png')
BlockO = pygame.image.load('blockCir copy.png')
def objecta(objectx, objecty, objectwd, objectht):
window.blit(BlockA, (objectx, objecty, objectwd, objectht))
def objectb(objectx, objecty, objectwd, objectht):
window.blit(BlockB, (objectx, objecty, objectwd, objectht))
def objectc(objectx, objecty, objectwd, objectht):
window.blit(BlockC, (objectx, objecty, objectwd, objectht))
def objectd(objectx, objecty, objectwd, objectht):
window.blit(BlockD, (objectx, objecty, objectwd, objectht))
def objecte(objectx, objecty, objectwd, objectht):
window.blit(BlockE, (objectx, objecty, objectwd, objectht))
def objectcir(objectx, objecty, objectwd, objectht):
window.blit(BlockCir, (objectx, objecty, objectwd, objectht))
def objectO(objectx, objecty, objectwd, objectht):
window.blit(BlockO, (objectx, objecty, objectwd, objectht))
def car(carstartx,carstarty):
window.blit(carim, (carstartx, carstarty))
def msgwintext(text, font):
msgwinsurf = font.render(text, True, black)
return msgwinsurf, msgwinsurf.get_rect()
def msgwintexts(text, font):
msgwinsurfs = font.render(text, True, black)
return msgwinsurfs, msgwinsurfs.get_rect()
def messagedisplay(text):
Bigmsg = pygame.font.Font('freesansbold.ttf', 86)
msgwinsurf, msgwinrect = msgwintext(text,Bigmsg)
msgwinrect.center = ((screenwd/2),(screenht/6))
window.blit(msgwinsurf, msgwinrect)
pygame.display.update()
time.sleep(1.5)
gameloop()
def displayscore(text):
Bigmsgs = pygame.font.Font('freesansbold.ttf', 18)
msgwinsurfs, msgwinrects = msgwintexts(text,Bigmsgs)
msgwinrects.center = ((50),(50))
window.blit(msgwinsurfs, msgwinrects)
pygame.display.update()
time.sleep(1.5)
gameloop()
def crashed():
messagedisplay("You Have Crashed!")
global points
points = False
global Pscore
Pscore= 0
def Notime():
messagedisplay('You ran out of nTime!')
def score(goal):
displayscore("SCORE: " + goal)
window.blit(text, [0,0])
def gameloop():
carstartx = (screenwd * 0.45)
carstarty = (screenht * 0.92)
velx = 0
velp = 0
Pscore = 0
points = 0
aobjectsartx = random.randrange(0, screenwd)
aobjectsarty = -600
aobjectvel = 22
aobjectwidth = 100
aobjectheight = 75
bobjectsartx = random.randrange(0, screenwd)
bobjectsarty = -600
bobjectvel = 25
bobjectwidth = 100
bobjectheight = 75
cobjectsartx = random.randrange(0, screenwd)
cobjectsarty = -600
cobjectvel = 27
cobjectwidth = 100
cobjectheight = 75
dobjectsartx = random.randrange(0, screenwd)
dobjectsarty = -600
dobjectvel = 35
dobjectwidth = 100
dobjectheight = 75
eobjectsartx = random.randrange(0, screenwd)
eobjectsarty = -600
eobjectvel = 32
eobjectwidth = 100
eobjectheight = 75
objectsartx = random.randrange(0, screenwd)
objectsarty = -600
objectvel = 80
objectwidth = 80
objectheight = 55
objectsartxc = random.randrange(0, screenwd)
objectsartyc = -600
objectvelc = 85
objectwidthc = 80
objectheightc = 55
gameexit = False
while not gameexit:
#timer
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.QUIT()
quit()
if event.type == pygame.K_ESCAPE:
pygame.QUIT()
quit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
velx = -20
velp = 0.25
if event.key == pygame.K_RIGHT:
velx = 20
velp = 0.25
if event.type == pygame.KEYUP:
if event.key == pygame.K_LEFT or event.key == pygame.K_RIGHT:
velx = 0
#if event.type == pygame.KEYDOWN:
#f event.key == pygame.K_DOWN:
#vely = 15
#if event.key == pygame.K_UP:
#vely = -15
#if event.type == pygame.KEYUP:
#if event.key == pygame.K_DOWN or event.key == pygame.K_UP:
#vely = 0
carstartx += velx
points += velp
#carstarty += vely
window.fill(white)
window.blit(bg, (0,0))
objecta(aobjectsartx, aobjectsarty, aobjectwidth, aobjectheight)
objectb(bobjectsartx, bobjectsarty, bobjectwidth, bobjectheight)
objectc(cobjectsartx, cobjectsarty, cobjectwidth, cobjectheight)
objectd(dobjectsartx, dobjectsarty, dobjectwidth, dobjectheight)
objecte(eobjectsartx, eobjectsarty, eobjectwidth, eobjectheight)
objectcir(objectsartx, objectsarty, objectwidth, objectheight)
objectO(objectsartxc, objectsartyc, objectwidthc, objectheightc)
aobjectsarty += aobjectvel
bobjectsarty += bobjectvel
cobjectsarty += cobjectvel
dobjectsarty += dobjectvel
eobjectsarty += eobjectvel
objectsarty += objectvel
objectsartyc += objectvelc
car(carstartx,carstarty)
if carstartx > screenwd - carwd or carstartx < 5:
crashed()
if aobjectsarty > screenht:
aobjectsarty = 0 - aobjectheight
aobjectsartx = random.randrange(0, screenwd)
if carstarty < aobjectsarty + aobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > aobjectsartx and carstartx < aobjectsartx + aobjectheight or carstartx + carwd > aobjectsartx and carstartx + carwd < aobjectsartx + aobjectwidth:
print('x axis crossover')
crashed()
if bobjectsarty > screenht:
bobjectsarty = 0 - bobjectheight
bobjectsartx = random.randrange(0, screenwd)
if carstarty < bobjectsarty + bobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > bobjectsartx and carstartx < bobjectsartx + bobjectheight or carstartx + carwd > bobjectsartx and carstartx + carwd < bobjectsartx + bobjectwidth:
print('x axis crossover')
crashed()
if cobjectsarty > screenht:
cobjectsarty = 0 - cobjectheight
cobjectsartx = random.randrange(0, screenwd)
if carstarty < cobjectsarty + cobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > cobjectsartx and carstartx < cobjectsartx + cobjectheight or carstartx + carwd > cobjectsartx and carstartx + carwd < cobjectsartx + cobjectwidth:
print('x axis crossover')
crashed()
if dobjectsarty > screenht:
dobjectsarty = 0 - dobjectheight
dobjectsartx = random.randrange(0, screenwd)
if carstarty < dobjectsarty + dobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > dobjectsartx and carstartx < dobjectsartx + dobjectheight or carstartx + carwd > dobjectsartx and carstartx + carwd < dobjectsartx + dobjectwidth:
print('x axis crossover')
crashed()
if eobjectsarty > screenht:
eobjectsarty = 0 - eobjectheight
eobjectsartx = random.randrange(0, screenwd)
if carstarty < eobjectsarty + eobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > eobjectsartx and carstartx < eobjectsartx + eobjectheight or carstartx + carwd > eobjectsartx and carstartx + carwd < eobjectsartx + eobjectwidth:
print('x axis crossover')
crashed()
if objectsarty > screenht:
objectsarty = 0 - objectheight
objectsartx = random.randrange(0, screenwd)
if carstarty < objectsarty + objectheight:
print('y axis ')
if carstartx > objectsartx and carstartx < objectsartx + objectheight or carstartx + carwd > objectsartx and carstartx + carwd < objectsartx + objectwidth:
print('x axis crossover')
if objectsartyc > screenht:
objectsartyc = 0 - objectheightc
objectsartxc = random.randrange(0, screenwd)
points = False
while not points:
print(str(Pscore))
goal = Pscore
score(str(goal))
pygame.display.update()
clock.tick(60)
gameloop()
pygame.quit()
quit()
screenwd = 1200
screenht = 800
yellow = (255,255, 0)
white = (255, 255, 255)
black = (0,0,0)
carwd = 80
carht = 60
starttime = 6000
window = pygame.display.set_mode((screenwd, screenht))
pygame.display.set_caption('Spell Me')
clock = pygame.time.Clock()
starttime = 6000
carim = pygame.image.load('CAR.png')
bg = pygame.image.load('BG.jpeg')
BlockA = pygame.image.load('blockA.png')
BlockB = pygame.image.load('blockB.png')
BlockC = pygame.image.load('blockC.png')
BlockD = pygame.image.load('blockD.png')
BlockE = pygame.image.load('blockE.png')
BlockCir = pygame.image.load('blockCir.png')
BlockO = pygame.image.load('blockCir copy.png')
def objecta(objectx, objecty, objectwd, objectht):
window.blit(BlockA, (objectx, objecty, objectwd, objectht))
def objectb(objectx, objecty, objectwd, objectht):
window.blit(BlockB, (objectx, objecty, objectwd, objectht))
def objectc(objectx, objecty, objectwd, objectht):
window.blit(BlockC, (objectx, objecty, objectwd, objectht))
def objectd(objectx, objecty, objectwd, objectht):
window.blit(BlockD, (objectx, objecty, objectwd, objectht))
def objecte(objectx, objecty, objectwd, objectht):
window.blit(BlockE, (objectx, objecty, objectwd, objectht))
def objectcir(objectx, objecty, objectwd, objectht):
window.blit(BlockCir, (objectx, objecty, objectwd, objectht))
def objectO(objectx, objecty, objectwd, objectht):
window.blit(BlockO, (objectx, objecty, objectwd, objectht))
def car(carstartx,carstarty):
window.blit(carim, (carstartx, carstarty))
def msgwintext(text, font):
msgwinsurf = font.render(text, True, black)
return msgwinsurf, msgwinsurf.get_rect()
def msgwintexts(text, font):
msgwinsurfs = font.render(text, True, black)
return msgwinsurfs, msgwinsurfs.get_rect()
def messagedisplay(text):
Bigmsg = pygame.font.Font('freesansbold.ttf', 86)
msgwinsurf, msgwinrect = msgwintext(text,Bigmsg)
msgwinrect.center = ((screenwd/2),(screenht/6))
window.blit(msgwinsurf, msgwinrect)
pygame.display.update()
time.sleep(1.5)
gameloop()
def displayscore(text):
Bigmsgs = pygame.font.Font('freesansbold.ttf', 18)
msgwinsurfs, msgwinrects = msgwintexts(text,Bigmsgs)
msgwinrects.center = ((50),(50))
window.blit(msgwinsurfs, msgwinrects)
pygame.display.update()
time.sleep(1.5)
gameloop()
def crashed():
messagedisplay("You Have Crashed!")
global points
points = False
global Pscore
Pscore= 0
def Notime():
messagedisplay('You ran out of nTime!')
def score(goal):
displayscore("SCORE: " + goal)
window.blit(text, [0,0])
def gameloop():
carstartx = (screenwd * 0.45)
carstarty = (screenht * 0.92)
velx = 0
velp = 0
Pscore = 0
points = 0
aobjectsartx = random.randrange(0, screenwd)
aobjectsarty = -600
aobjectvel = 22
aobjectwidth = 100
aobjectheight = 75
bobjectsartx = random.randrange(0, screenwd)
bobjectsarty = -600
bobjectvel = 25
bobjectwidth = 100
bobjectheight = 75
cobjectsartx = random.randrange(0, screenwd)
cobjectsarty = -600
cobjectvel = 27
cobjectwidth = 100
cobjectheight = 75
dobjectsartx = random.randrange(0, screenwd)
dobjectsarty = -600
dobjectvel = 35
dobjectwidth = 100
dobjectheight = 75
eobjectsartx = random.randrange(0, screenwd)
eobjectsarty = -600
eobjectvel = 32
eobjectwidth = 100
eobjectheight = 75
objectsartx = random.randrange(0, screenwd)
objectsarty = -600
objectvel = 80
objectwidth = 80
objectheight = 55
objectsartxc = random.randrange(0, screenwd)
objectsartyc = -600
objectvelc = 85
objectwidthc = 80
objectheightc = 55
gameexit = False
while not gameexit:
#timer
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.QUIT()
quit()
if event.type == pygame.K_ESCAPE:
pygame.QUIT()
quit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
velx = -20
velp = 0.25
if event.key == pygame.K_RIGHT:
velx = 20
velp = 0.25
if event.type == pygame.KEYUP:
if event.key == pygame.K_LEFT or event.key == pygame.K_RIGHT:
velx = 0
#if event.type == pygame.KEYDOWN:
#f event.key == pygame.K_DOWN:
#vely = 15
#if event.key == pygame.K_UP:
#vely = -15
#if event.type == pygame.KEYUP:
#if event.key == pygame.K_DOWN or event.key == pygame.K_UP:
#vely = 0
carstartx += velx
points += velp
#carstarty += vely
window.fill(white)
window.blit(bg, (0,0))
objecta(aobjectsartx, aobjectsarty, aobjectwidth, aobjectheight)
objectb(bobjectsartx, bobjectsarty, bobjectwidth, bobjectheight)
objectc(cobjectsartx, cobjectsarty, cobjectwidth, cobjectheight)
objectd(dobjectsartx, dobjectsarty, dobjectwidth, dobjectheight)
objecte(eobjectsartx, eobjectsarty, eobjectwidth, eobjectheight)
objectcir(objectsartx, objectsarty, objectwidth, objectheight)
objectO(objectsartxc, objectsartyc, objectwidthc, objectheightc)
aobjectsarty += aobjectvel
bobjectsarty += bobjectvel
cobjectsarty += cobjectvel
dobjectsarty += dobjectvel
eobjectsarty += eobjectvel
objectsarty += objectvel
objectsartyc += objectvelc
car(carstartx,carstarty)
if carstartx > screenwd - carwd or carstartx < 5:
crashed()
if aobjectsarty > screenht:
aobjectsarty = 0 - aobjectheight
aobjectsartx = random.randrange(0, screenwd)
if carstarty < aobjectsarty + aobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > aobjectsartx and carstartx < aobjectsartx + aobjectheight or carstartx + carwd > aobjectsartx and carstartx + carwd < aobjectsartx + aobjectwidth:
print('x axis crossover')
crashed()
if bobjectsarty > screenht:
bobjectsarty = 0 - bobjectheight
bobjectsartx = random.randrange(0, screenwd)
if carstarty < bobjectsarty + bobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > bobjectsartx and carstartx < bobjectsartx + bobjectheight or carstartx + carwd > bobjectsartx and carstartx + carwd < bobjectsartx + bobjectwidth:
print('x axis crossover')
crashed()
if cobjectsarty > screenht:
cobjectsarty = 0 - cobjectheight
cobjectsartx = random.randrange(0, screenwd)
if carstarty < cobjectsarty + cobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > cobjectsartx and carstartx < cobjectsartx + cobjectheight or carstartx + carwd > cobjectsartx and carstartx + carwd < cobjectsartx + cobjectwidth:
print('x axis crossover')
crashed()
if dobjectsarty > screenht:
dobjectsarty = 0 - dobjectheight
dobjectsartx = random.randrange(0, screenwd)
if carstarty < dobjectsarty + dobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > dobjectsartx and carstartx < dobjectsartx + dobjectheight or carstartx + carwd > dobjectsartx and carstartx + carwd < dobjectsartx + dobjectwidth:
print('x axis crossover')
crashed()
if eobjectsarty > screenht:
eobjectsarty = 0 - eobjectheight
eobjectsartx = random.randrange(0, screenwd)
if carstarty < eobjectsarty + eobjectheight:
print('y axis crossover')
Pscore += 1
if carstartx > eobjectsartx and carstartx < eobjectsartx + eobjectheight or carstartx + carwd > eobjectsartx and carstartx + carwd < eobjectsartx + eobjectwidth:
print('x axis crossover')
crashed()
if objectsarty > screenht:
objectsarty = 0 - objectheight
objectsartx = random.randrange(0, screenwd)
if carstarty < objectsarty + objectheight:
print('y axis ')
if carstartx > objectsartx and carstartx < objectsartx + objectheight or carstartx + carwd > objectsartx and carstartx + carwd < objectsartx + objectwidth:
print('x axis crossover')
if objectsartyc > screenht:
objectsartyc = 0 - objectheightc
objectsartxc = random.randrange(0, screenwd)
points = False
while not points:
print(str(Pscore))
goal = Pscore
score(str(goal))
pygame.display.update()
clock.tick(60)
gameloop()
pygame.quit()
quit()
python pygame
python pygame
New contributor
New contributor
New contributor
asked 4 mins ago
VisionsCreatesVisionsCreates
1
1
New contributor
New contributor
$begingroup$
I'm sorry we don't help people write new code or fix broken code. We review working code in an effort to make it better. Once you figure out what you need to make it work bring it back and we can then provide feedback.
$endgroup$
– bruglesco
2 mins ago
add a comment |
$begingroup$
I'm sorry we don't help people write new code or fix broken code. We review working code in an effort to make it better. Once you figure out what you need to make it work bring it back and we can then provide feedback.
$endgroup$
– bruglesco
2 mins ago
$begingroup$
I'm sorry we don't help people write new code or fix broken code. We review working code in an effort to make it better. Once you figure out what you need to make it work bring it back and we can then provide feedback.
$endgroup$
– bruglesco
2 mins ago
$begingroup$
I'm sorry we don't help people write new code or fix broken code. We review working code in an effort to make it better. Once you figure out what you need to make it work bring it back and we can then provide feedback.
$endgroup$
– bruglesco
2 mins ago
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
});
});
}, "mathjax-editing");
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "196"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
VisionsCreates is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f211964%2fsuper-beginner-check-my-code-printing-score-is-the-issue%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
VisionsCreates is a new contributor. Be nice, and check out our Code of Conduct.
VisionsCreates is a new contributor. Be nice, and check out our Code of Conduct.
VisionsCreates is a new contributor. Be nice, and check out our Code of Conduct.
VisionsCreates is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Code Review Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f211964%2fsuper-beginner-check-my-code-printing-score-is-the-issue%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
$begingroup$
I'm sorry we don't help people write new code or fix broken code. We review working code in an effort to make it better. Once you figure out what you need to make it work bring it back and we can then provide feedback.
$endgroup$
– bruglesco
2 mins ago