Hi, I am a elementary schooler, and I started collabbing with my friend in python. He would make the sprites, I would code. We are making Super Mario Brothers stage 1-1, because the whole game would take us too long time to make. When I was making the grounds, some bug, or error happened. I have tried every single thing to fix it, put over an 2 full hour to fix this but I just couldn’t. Can you help me fix this project? The code that I wrote right now goes like this-
from processing import *
from time import time
rectx = 50
recty = 300
touchingGround = False
vy = 0
sprint = False
pressed = [0, 0]
costume = 0
look = 0
timerun = 0.0
bottom = 410
noneComboStart = 0
def setup():
global stillr, run1r, run2r, stilll, still, run1, run2, mario, block, a
noStroke()
stillr = loadImage("http://coder200.oyosite.com/mario/photo/still.png")
run1r = loadImage("http://coder200.oyosite.com/mario/photo/run1.png")
run2r = loadImage("http://coder200.oyosite.com/mario/photo/run2.png")
jumpr = loadImage("http://coder200.oyosite.com/mario/photo/jump.png")
stilll = loadImage("http://coder200.oyosite.com/mario/photo/still_l.png")
run1l = loadImage("http://coder200.oyosite.com/mario/photo/run1_l.png")
run2l = loadImage("http://coder200.oyosite.com/mario/photo/run2_l.png")
jumpl = loadImage("http://coder200.oyosite.com/mario/photo/jump_l.png")
block = loadImage("http://coder200.oyosite.com/mario/photo/block.png")
a = [block, block, block, None, None, None, block, None, block, block, None, None]
still = [stillr, stilll]
run1 = [run1r, run1l]
run2 = [run2r, run2l]
jump = [jumpr, jumpl]
mario = [still, run1, run2, jump]
size(500, 500)
def draw():
move()
changeCostume()
background(255, 255, 255)
fill(0, 0, 0)
image(mario[costume][look], rectx, recty, 40, 40)
stroke(255, 255, 255)
for i in range(len(a)):
if not a[i] == None:
image(a[i], i * 40, 450, 40, 40)
def keyPressed():
global touchingGround, vy, rectx, sprint, look, timerun
if keyboard.keyCode == 38:
if touchingGround:
vy += 11
touchingGround = False
if keyboard.keyCode == 37:
if pressed[0] == 0:
timerun = time()
pressed[0] = 2
if keyboard.keyCode == 39:
if pressed[1] == 0:
timerun = time()
pressed[1] = 2
if keyboard.keyCode == 16:
sprint = True
def keyReleased():
global sprint, costume
if keyboard.keyCode == 37:
pressed[0] = 0
if keyboard.keyCode == 39:
pressed[1] = 0
if keyboard.keyCode == 16:
sprint = False
def move():
global recty, touchingGround, vy, rectx, noneComboStart, bottom
for i in range(len(a)):
if a[i] == None:
if i - 1 >= 0:
if a[i - 1] != None:
noneComboStart = i * 40
if not i + 1 >= len(a):
if a[i + 1] == None:
continue
else:
if rectx >= noneComboStart and rectx <= i * 40:
bottom = 500
else:
bottom = 410
if sprint:
if pressed[0] != 0:
pressed[0] = 4
if pressed[1] != 0:
pressed[1] = 4
else:
if pressed[0] != 0:
pressed[0] = 2
if pressed[1] != 0:
pressed[1] = 2
if not touchingGround:
vy -= 0.5
rectx -= pressed[0]
rectx += pressed[1]
recty -= vy
if recty >= bottom:
recty = bottom
touchingGround = True
vy = 0
if rectx <= 0:
rectx = 0
def changeCostume():
global costume, look
if abs(pressed[0] - pressed[1]) == 0:
costume = 0
elif abs(pressed[0] - pressed[1]) == 2:
if round((time() - timerun) * 2) % 2 == 0:
costume = 1
else:
costume = 2
if pressed[0] - pressed[1] == 2:
look = 1
elif pressed[0] - pressed[1] == -2:
look = 0
elif abs(pressed[0] - pressed[1]) == 4:
if round((time() - timerun) * 4) % 2 == 0:
costume = 1
else:
costume = 2
if pressed[0] - pressed[1] == 4:
look = 1
elif pressed[0] - pressed[1] == -4:
look = 0
if not touchingGround:
costume = 3
run()
It’s very long, because this is my first time coding platformers. Also just saying I coded this from Python Mini in the coding platform called kidOYO, so it doesn’t have lots of accessibilities that we usually have.