Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- RunCount = 0
- frames = 60
- #frames fixes visual Bugs by creating frame and state delays
- check = 2
- #Neutral = 0, True = 1, False = 2, EraseForGame = 3
- Mude = 0
- #Neutral = 0, Peasant = 1, Prince = 2, King = 3, GOD = 4
- foodState = 0
- #Neutral = 0, Gen Food = 1
- MyX = 500
- MyY = 500
- #Worm's postition
- fX = 50
- fY = 50
- #Food's position
- Tail = []
- TailLen = 8
- #For Size Growth Algorithm
- North = True
- South = False
- East = False
- West = False
- #Direction of the Worm
- Score = 0
- Time = 1000
- ScoreBoard = []
- #Score Board NOT IMPLEMENTED
- #Game stuf
- def setup():
- frameRate(frames)
- size(1000,1000)
- background(0)
- def draw():
- global check, Mude, RunCount, Tail, TailLen
- background(0)
- if check == 2:
- titleDraw()
- if mousePressed:
- check = 1
- if check == 1:
- modeDraw()
- RunCount = RunCount + 1
- if check == 4:
- Controls()
- if Mude == 0:
- pass
- elif Mude == 1:
- Peasant()
- drawFood()
- elif Mude == 2:
- Prince()
- drawFood()
- elif Mude == 3:
- King()
- drawFood()
- elif Mude == 4:
- GOD()
- #println(Mude)
- println(check)
- #println(RunCount)
- #println(fX)
- #println(fY)
- def titleDraw():
- #Draws the Starting Title
- global RunCount, frames
- frames = 60
- frameRate(frames)
- RunCount = 0
- fill(255)
- textSize(60)
- textAlign(CENTER,CENTER)
- text("Welcome To The Snake Game",500,200)
- textSize(25)
- textAlign(CENTER,CENTER)
- text("Click Mouse to Start",500, 600)
- def modeDraw():
- #Draws UI and interaction functions for the game
- global check, Mude, frames
- frames = 60
- frameRate(frames)
- background(0)
- textAlign(CENTER,CENTER)
- fill(255)
- ellipse(500,1000-200,200,100)
- ellipse(500,1000-400,200,100)
- ellipse(500,1000-600,200,100)
- ellipse(500,1000-800,200,100)
- rect(0,0,300,100)
- rect(700,0,1000,100)
- fill(0)
- textSize(30)
- text("Return to Title",150,50)
- text("Controls & Rules",850,50)
- fill(255)
- textSize(50)
- fill(200)
- text("Color of Worm",500,50)
- textSize(30)
- fill(0)
- text("Green",500,200)
- text("Yellow",500,400)
- text("Red",500,600)
- text("Rainbow",500,800)
- #draws screen
- if mousePressed:
- if 700 < mouseX < 1000 and 0 < mouseY < 100:
- check = 4
- if 0 < mouseX < 300 and 0 < mouseY < 100:
- check = 2
- if 400 < mouseX < 600 and 150 < mouseY < 250 and RunCount > 60:
- Mude = 1
- #green
- if 400 < mouseX < 600 and 350 < mouseY < 450 and RunCount > 60:
- Mude = 2
- #yellow
- if 400 < mouseX < 600 and 550 < mouseY < 650 and RunCount > 60:
- Mude = 3
- #red
- if 400 < mouseX < 600 and 750 < mouseY < 850 and RunCount > 60:
- Mude = 4
- #rainbow
- if 400 < mouseX < 600 and 150 < mouseY < 250:
- fill(0,255,0)
- ellipse(500,1000-800,200,100)
- fill(0)
- text("Green",500,200)
- if 400 < mouseX < 600 and 350 < mouseY < 450:
- fill(255,255,0)
- ellipse(500,1000-600,200,100)
- fill(0)
- text("Yellow",500,400)
- if 400 < mouseX < 600 and 550 < mouseY < 650:
- fill(255,0,0)
- ellipse(500,1000-400,200,100)
- fill(0)
- text("Red",500,600)
- if 400 < mouseX < 600 and 750 < mouseY < 850:
- fill(random(200)+55,random(200)+55,random(200)+55)
- ellipse(500,1000-200,200,100)
- fill(0)
- text("Rainbow",500,800)
- def GOD():
- #The hardest difficulty
- global Mude, check, MyX, MyY,frames,TailLen,Score,Time,Tail,foodState
- frames = 10
- frameRate(frames)
- Zx = 0
- Zy = 0
- check = 3
- background(0)
- while Zx < 1000:
- stroke(50)
- line(Zx,1000,Zx,0)
- Zx = Zx + 25
- while Zy < 1000:
- stroke(50)
- line(1000,Zy,0,Zy)
- Zy = Zy + 25
- drawFood()
- if MyY >= 1000:
- MyY = 1000
- if MyY <= 0:
- MyY = 0
- if MyX >= 1000:
- MyX = 1000
- if MyX <= 0:
- MyX = 0
- textSize(50)
- if Time < 250:
- fill(random(200)+55,random(200)+55,random(200)+55)
- else:
- fill(255)
- text("TIME",800,50)
- text("SCORE",200,50)
- textSize(30)
- text(Time,800,100)
- text(Score, 200,100)
- fill(255)
- noStroke()
- Move()
- EatEvent()
- fill(random(200)+55,random(200)+55,random(200)+55)
- ellipse(MyX,MyY,50,50)
- DrawFace()
- TailAlgorithum()
- if Time <= 0:
- foodState = 2
- background(0)
- Time = 0
- textSize(80)
- fill(100)
- text("GAME OVER",500,300)
- textSize(50)
- text("SCORE",500,500)
- text(Score,500,600)
- noLoop()
- else:
- Time = Time - 4
- def Peasant():
- #The "Green" difficulty
- global Mude, check, MyX, MyY, frames, TailLen, Score, Time, Tail, foodState
- frames = 10
- Time = Time - 1
- frameRate(frames)
- Zx = 0
- Zy = 0
- check = 3
- background(0)
- fill(0,255,0)
- noStroke()
- while Zx < 1000:
- stroke(50)
- line(Zx,1000,Zx,0)
- Zx = Zx + 25
- while Zy < 1000:
- stroke(50)
- line(1000,Zy,0,Zy)
- Zy = Zy + 25
- drawFood()
- textSize(50)
- if Time < 250:
- fill(0,random(200)+55,0)
- else:
- fill(255)
- text("TIME",800,50)
- text("SCORE",200,50)
- textSize(30)
- text(Time,800,100)
- text(Score, 200,100)
- fill(255)
- noStroke()
- Move()
- EatEvent()
- fill(0,255,0)
- ellipse(MyX,MyY,50,50)
- DrawFace()
- TailAlgorithum()
- if Time <= 0:
- foodState = 2
- background(0)
- Time = 0
- textSize(80)
- fill(100)
- text("GAME OVER",500,300)
- textSize(50)
- text("SCORE",500,500)
- text(Score,500,600)
- noLoop()
- else:
- Time = Time - 4
- #expand this later to be a Pickfork on the sides
- def King():
- #The "Red" difficulty
- global Mude, check, MyX, MyY, frames, TailLen, Score, Time, Tail, foodState
- frames = 10
- Time = Time - 3
- frameRate(frames)
- Zx = 0
- Zy = 0
- check = 3
- background(0)
- fill(255,0,0)
- noStroke()
- while Zx < 1000:
- stroke(50)
- line(Zx,1000,Zx,0)
- Zx = Zx + 25
- while Zy < 1000:
- stroke(50)
- line(1000,Zy,0,Zy)
- Zy = Zy + 25
- drawFood()
- textSize(50)
- if Time < 250:
- fill(random(200)+55,0,0)
- else:
- fill(255)
- text("TIME",800,50)
- text("SCORE",200,50)
- textSize(30)
- text(Time,800,100)
- text(Score, 200,100)
- fill(255)
- noStroke()
- Move()
- EatEvent()
- fill(255,0,0)
- ellipse(MyX,MyY,50,50)
- DrawFace()
- TailAlgorithum()
- if Time <= 0:
- foodState = 2
- background(0)
- Time = 0
- textSize(80)
- fill(100)
- text("GAME OVER",500,300)
- textSize(50)
- text("SCORE",500,500)
- text(Score,500,600)
- noLoop()
- else:
- Time = Time - 4
- def Prince():
- #The "Yellow" difficulty
- global Mude, check, MyX, MyY, frames, TailLen, Time, Score, Tail, foodState
- frames = 10
- Time = Time - 2
- frameRate(frames)
- Zx = 0
- Zy = 0
- check = 3
- background(0)
- fill(255,255,0)
- noStroke()
- while Zx < 1000:
- stroke(50)
- line(Zx,1000,Zx,0)
- Zx = Zx + 25
- while Zy < 1000:
- stroke(50)
- line(1000,Zy,0,Zy)
- Zy = Zy + 25
- drawFood()
- textSize(50)
- if Time < 250:
- fill(random(200)+55,random(200)+55,0)
- else:
- fill(255)
- text("TIME",800,50)
- text("SCORE",200,50)
- textSize(30)
- text(Time,800,100)
- text(Score, 200,100)
- fill(255)
- noStroke()
- Move()
- EatEvent()
- fill(255,255,0)
- ellipse(MyX,MyY,50,50)
- DrawFace()
- TailAlgorithum()
- if Time <= 0:
- foodState = 2
- background(0)
- Time = 0
- textSize(80)
- fill(100)
- text("GAME OVER",500,300)
- textSize(50)
- text("SCORE",500,500)
- text(Score,500,600)
- noLoop()
- else:
- Time = Time - 4
- def drawFood():
- #Places the food in-game using pointers
- global Mude, fX, fY, foodState
- if foodState == 2:
- pass
- if foodState == 0:
- setFood()
- foodState = 1
- if Mude == 1:
- stroke(0,255,0)
- elif Mude == 2:
- stroke(255,255,0)
- elif Mude == 3:
- stroke(255,0,0)
- elif Mude == 4:
- stroke(random(200)+55,random(200)+55,random(200)+55)
- strokeWeight(20)
- point(fX,fY)
- strokeWeight(1)
- noStroke()
- def setFood():
- #Sets pointers for the food in-game
- if foodState == 1:
- pass
- elif foodState == 0:
- global fX,fY
- fX = floor(random(1,19))*50
- fY = floor(random(1,19))*50
- def TailAlgorithum():
- #The main algorithum, generates the "tail" of the worm with sudo-memory in an array
- global Tail,MyX,MyY,check,TailLen
- i = 2
- if check == 3 and keyPressed == True:
- Tail.insert(0, MyY)
- Tail.insert(0, MyX)
- if len(Tail) > TailLen:
- Tail.pop()
- Tail.pop()
- if len(Tail) == TailLen:
- while len(Tail)/2 > i/2:
- if Mude == 1:
- fill(0,255,0)
- elif Mude == 2:
- fill(255,255,0)
- elif Mude == 3:
- fill(255,0,0)
- elif Mude == 4:
- fill(random(200)+55,random(200)+55,random(200)+55)
- #noStroke()
- ellipse(Tail[i],Tail[i+1],50,50)
- i = i + 2
- def EatEvent():
- #A Basic Event that effects the game and triggers other things
- global TailLen,fX,fY,MyX,MyY,foodState,Score
- if MyX == fX and MyY == fY:
- Score = Score + 1
- TailLen = TailLen + 2
- foodState = 0
- drawFood()
- def Move():
- #This method takes input from the key board to move the worm
- global MyY, MyX, North, South, East, West
- if keyPressed:
- if key == 'w':
- MyY = MyY - 25
- North = True
- East = False
- West = False
- South = False
- if key == 's':
- MyY = MyY + 25
- North = False
- East = False
- West = False
- South = True
- if key == 'a':
- MyX = MyX - 25
- North = False
- East = False
- West = True
- South = False
- if key == 'd':
- MyX = MyX + 25
- North = False
- East = True
- West = False
- South = False
- def Controls():
- global check
- background(0)
- fill(255)
- textSize(80)
- text("CONTROLS",500,100)
- text("RULES",500,400)
- text("Upcoming Features",500,700)
- textSize(30)
- text("W-A-S-D To Move the Worm", 500 ,200)
- text("Press 'b' To exit a Screen", 500, 250)
- text("Your Goal is to feed your worm by eating the pellets.", 500,500)
- text("When the Timer hits zero the game is over.",500,550)
- text("-> Image and Terrian backgrounds",500,800)
- text("-> A Score Board",500,850)
- if keyPressed:
- if key == "b":
- check = 1
- def DrawFace():
- #This Method Draws the eyes of the worm in the corrisponding direction
- global North, South, East, West, MyX, MyY
- if North == True:
- fill(255)
- ellipse(MyX-10,MyY-10,20,20)
- ellipse(MyX+10,MyY-10,20,20)
- fill(0)
- ellipse(MyX-10,MyY-15,10,10)
- ellipse(MyX+10,MyY-15,10,10)
- if South == True:
- fill(255)
- ellipse(MyX-10,MyY+10,20,20)
- ellipse(MyX+10,MyY+10,20,20)
- fill(0)
- ellipse(MyX-10,MyY+15,10,10)
- ellipse(MyX+10,MyY+15,10,10)
- if East == True:
- fill(255)
- ellipse(MyX+10,MyY-10,20,20)
- ellipse(MyX+10,MyY+10,20,20)
- fill(0)
- ellipse(MyX+15,MyY-10,10,10)
- ellipse(MyX+15,MyY+10,10,10)
- if West == True:
- fill(255)
- ellipse(MyX-10,MyY-10,20,20)
- ellipse(MyX-10,MyY+10,20,20)
- fill(0)
- ellipse(MyX-15,MyY-10,10,10)
- ellipse(MyX-15,MyY+10,10,10)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement