0,]']±>Sï}WÿÍu§ðp8·d%qy)6o;]ÉA¦ösï÷ôôô”°ÂVl†3gridTop+vShift then self.y=self.y-vShift end if check == true and time() > 5000 then troggle:checkCollision() if state.level >= 2 and time() > 10000 then troggle2:checkCollision() end end end -- Move down if btnp(1, 120, 6) then if self.y 5000 then troggle:checkCollision() if state.level >= 2 and time() > 10000 then troggle2:checkCollision() end end end -- Move left if btnp(2, 120, 6) then if self.x>gridLeft+hShift then self.x=self.x-hShift end if check == true and time() > 5000 then troggle:checkCollision() if state.level >= 2 and time() > 10000 then troggle2:checkCollision() end end end -- Move right if btnp(3, 120, 6) then if self.x 5000 then troggle:checkCollision() if state.level >= 2 and time() > 10000 then troggle2:checkCollision() end end end end function user:munch() -- is user (x,y) in btwn numbers (x,y)s if btnp(5, 120, 6) then local i = 1 for _, col in ipairs(xVals) do for _, row in ipairs(yVals) do if ((user.x >= col-4 and user.x <= col+16) and (user.y >= row-4 and user.y <= row+12)) then -- also change primes to whatever mode we're on --if state.setting == "primes" --if primes.correct(primes.numbers[i]) == true then if state.setting == "primes" then if primes.numbers[i] == 2 or primes.numbers[i] == 3 or primes.numbers[i] == 5 or primes.numbers[i] == 7 then primes.numbers[i] = 0 state.score = state.score + 5 sfx(1) state.answerCount = state.answerCount - 1 if state.answerCount == 0 then state.levelUp() end -- loop through the list of numbers -- if no primes left, then level over else primes.numbers[i] = 0 user.lives = user.lives - 1 sfx(2) if user.lives == 0 then state.gameover = true end end end if state.setting == "multiples" then if multiples.numbers[i] % multiples.rules == 0 then multiples.numbers[i] = 0 state.score = state.score + 5 sfx(1) state.answerCount = state.answerCount - 1 if state.answerCount == 0 then state.levelUp() end else multiples.numbers[i] = 0 user.lives = user.lives - 1 sfx(2) if user.lives == 0 then state.gameover = true end end end if state.setting == "factors" then if factors.numbers[i] ~= 0 then if factors.rules % factors.numbers[i] == 0 then factors.numbers[i] = 0 state.score = state.score + 5 sfx(1) state.answerCount = state.answerCount - 1 if state.answerCount == 0 then state.levelUp() end else factors.numbers[i] = 0 user.lives = user.lives - 1 sfx(2) if user.lives == 0 then state.gameover = true end end end end end i = i+1 end end end end function troggle:move() randomNum = math.random(1,4) if randomNum == 1 then if self.y>gridTop+vShift then self.y=self.y-vShift end troggle:checkCollision() if collision == true then check = false end elseif randomNum == 2 then if self.ygridLeft+hShift then self.x=self.x-hShift end troggle:checkCollision() if collision == true then check = false end else if self.xgridTop+vShift then self.y=self.y-vShift end troggle2:checkCollision() if collision == true then check = false end elseif randomNum == 2 then if self.ygridLeft+hShift then self.x=self.x-hShift end troggle2:checkCollision() if collision == true then check = false end else if self.x30 then self.y=self.y-20 end end -- Move down if btnp(1, 120, 6) then if self.y<70 then self.y=self.y+20 end end -- Press 'x' if btnp(5, 120, 6) then if self.y == 30 then state.setting = "multiples" settingClass = multiples elseif self.y == 50 then state.setting = "factors" settingClass = factors elseif self.y == 70 then state.setting = "primes" settingClass = primes end end end function TIC() -- starting game jingle if myMusic.start == true then music(0, 0, 0, false, false, 150, 6) myMusic.start = false end collision = false check = true if state.setting == nil then cls(16) print("Which game would you like to play?", 20, 10, 12) print("1. Multiples", 80, 35, 12) print("2. Factors", 80, 55, 12) print("3. Primes", 80, 75, 12) print("Use arrows to move, then press 'x'", 20, 124, 12) rectb(menu.x, menu.y, 70, 18, 12) menu:buttons() else if state.gameover == true then cls(16) print("GAME OVER", 84, 54, 12) print("YOUR SCORE: ", 74, 104, 12) print(state.score, 144, 104, 12) print("Press 'esc' to exit!", 60, 124, 12) else if start == false then sfx(0) if state.setting == "multiples" then multiples:generate() state:generateTitle(multiples.rules) end if state.setting == "primes" then primes:generate() state:generateTitle(nil) end if state.setting == "factors" then factors:generate() state:generateTitle(factors.rules) end --state.generateTitle(settingClass.rules) start = true end cls(13) map(30,0,30,17) settingClass:fill() print("Level:", 16, 12, 12) print(state.level, 52, 12, 12) print("Score:", 16, gridY + gridH + 12, 12) print(state.score, 52, gridY + gridH + 12, 12) print(state.title, gridX+40, 12, 12) local livesX = 110 for k=1,user.lives do spr(261,livesX, gridY+gridH+12) livesX = livesX + 24 end if time()>5000 then if myMusic.troggleStart == true then sfx(3) myMusic.troggleStart = false end spr(260,troggle.x,troggle.y) if time()>troggle.moveTime then troggle:move() troggle.moveTime = troggle.moveTime + 2000 end end if time()>10000 and state.level >= 2 then if myMusic.troggle2Start == true then sfx(3) myMusic.troggle2Start = false end spr(259, troggle2.x, troggle2.y) if time()>troggle2.moveTime then troggle2:move() troggle2.moveTime = troggle2.moveTime + 2000 end end spr(261,user.x,user.y) user:munch() user:move() t=t+1 end end end