├── README.md ├── sounds ├── stab.ogg ├── win.ogg ├── eat_ghost.ogg ├── ghosts_runaway.ogg ├── ghosts_siren.ogg ├── pacman_death.ogg ├── pacman_waka_ka.ogg ├── pacman_waka_wa.ogg ├── pacman_beginning.ogg └── pacman_eatghost.ogg ├── graphics ├── eyes.png ├── font.png ├── icon.png ├── logo.png ├── clock.png ├── field.png ├── ghost1.png ├── ghost2.png ├── ghost3.png ├── options.png ├── title.png ├── gameover.png ├── gamescore.png ├── highscore.png ├── logoblood.png ├── pacmanman.png ├── fieldoverlay.png ├── ghostscared1.png ├── ghostscared2.png ├── spinnyeyes.png └── superpellet.png ├── conf.lua ├── LICENSE.txt ├── intro.lua ├── menu.lua ├── highscoreentry.lua ├── main.lua ├── options.lua └── normal.lua /README.md: -------------------------------------------------------------------------------- 1 | # notpacman 2 | Runs on LÖVE 0.7.2 3 | -------------------------------------------------------------------------------- /sounds/stab.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stabyourself/notpacman/HEAD/sounds/stab.ogg -------------------------------------------------------------------------------- /sounds/win.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stabyourself/notpacman/HEAD/sounds/win.ogg -------------------------------------------------------------------------------- /graphics/eyes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stabyourself/notpacman/HEAD/graphics/eyes.png -------------------------------------------------------------------------------- /graphics/font.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stabyourself/notpacman/HEAD/graphics/font.png -------------------------------------------------------------------------------- /graphics/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stabyourself/notpacman/HEAD/graphics/icon.png -------------------------------------------------------------------------------- /graphics/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stabyourself/notpacman/HEAD/graphics/logo.png -------------------------------------------------------------------------------- /graphics/clock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stabyourself/notpacman/HEAD/graphics/clock.png -------------------------------------------------------------------------------- /graphics/field.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stabyourself/notpacman/HEAD/graphics/field.png -------------------------------------------------------------------------------- /graphics/ghost1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stabyourself/notpacman/HEAD/graphics/ghost1.png -------------------------------------------------------------------------------- /graphics/ghost2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stabyourself/notpacman/HEAD/graphics/ghost2.png -------------------------------------------------------------------------------- /graphics/ghost3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stabyourself/notpacman/HEAD/graphics/ghost3.png -------------------------------------------------------------------------------- /graphics/options.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stabyourself/notpacman/HEAD/graphics/options.png -------------------------------------------------------------------------------- /graphics/title.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stabyourself/notpacman/HEAD/graphics/title.png -------------------------------------------------------------------------------- /sounds/eat_ghost.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stabyourself/notpacman/HEAD/sounds/eat_ghost.ogg -------------------------------------------------------------------------------- /graphics/gameover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stabyourself/notpacman/HEAD/graphics/gameover.png -------------------------------------------------------------------------------- /graphics/gamescore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stabyourself/notpacman/HEAD/graphics/gamescore.png -------------------------------------------------------------------------------- /graphics/highscore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stabyourself/notpacman/HEAD/graphics/highscore.png -------------------------------------------------------------------------------- /graphics/logoblood.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stabyourself/notpacman/HEAD/graphics/logoblood.png -------------------------------------------------------------------------------- /graphics/pacmanman.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stabyourself/notpacman/HEAD/graphics/pacmanman.png -------------------------------------------------------------------------------- /graphics/fieldoverlay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stabyourself/notpacman/HEAD/graphics/fieldoverlay.png -------------------------------------------------------------------------------- /graphics/ghostscared1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stabyourself/notpacman/HEAD/graphics/ghostscared1.png -------------------------------------------------------------------------------- /graphics/ghostscared2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stabyourself/notpacman/HEAD/graphics/ghostscared2.png -------------------------------------------------------------------------------- /graphics/spinnyeyes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stabyourself/notpacman/HEAD/graphics/spinnyeyes.png -------------------------------------------------------------------------------- /graphics/superpellet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stabyourself/notpacman/HEAD/graphics/superpellet.png -------------------------------------------------------------------------------- /sounds/ghosts_runaway.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stabyourself/notpacman/HEAD/sounds/ghosts_runaway.ogg -------------------------------------------------------------------------------- /sounds/ghosts_siren.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stabyourself/notpacman/HEAD/sounds/ghosts_siren.ogg -------------------------------------------------------------------------------- /sounds/pacman_death.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stabyourself/notpacman/HEAD/sounds/pacman_death.ogg -------------------------------------------------------------------------------- /sounds/pacman_waka_ka.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stabyourself/notpacman/HEAD/sounds/pacman_waka_ka.ogg -------------------------------------------------------------------------------- /sounds/pacman_waka_wa.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stabyourself/notpacman/HEAD/sounds/pacman_waka_wa.ogg -------------------------------------------------------------------------------- /sounds/pacman_beginning.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stabyourself/notpacman/HEAD/sounds/pacman_beginning.ogg -------------------------------------------------------------------------------- /sounds/pacman_eatghost.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Stabyourself/notpacman/HEAD/sounds/pacman_eatghost.ogg -------------------------------------------------------------------------------- /conf.lua: -------------------------------------------------------------------------------- 1 | function love.conf(t) 2 | t.title = "Not Pacman" 3 | t.identity = "not_pacman" 4 | t.author = "Maurice" 5 | t.console = false 6 | t.screen.vsync = true 7 | t.screen.fsaa = 16 8 | t.screen.width = 640 9 | t.screen.height = 500 10 | end -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 2 | Version 2, December 2004 3 | 4 | Copyright (C) 2004 Sam Hocevar 5 | 6 | Everyone is permitted to copy and distribute verbatim or modified 7 | copies of this license document, and changing it is allowed as long 8 | as the name is changed. 9 | 10 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 11 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 12 | 13 | 0. You just DO WHAT THE FUCK YOU WANT TO. -------------------------------------------------------------------------------- /intro.lua: -------------------------------------------------------------------------------- 1 | function intro_load() 2 | gamestate = "intro" 3 | 4 | introduration = 2.5 5 | blackafterintro = 0.3 6 | introfadetime = 0.5 7 | introprogress = -0.2 8 | end 9 | 10 | function intro_update(dt) 11 | if introprogress < introduration+blackafterintro then 12 | introprogress = introprogress + dt 13 | if introprogress > introduration+blackafterintro then 14 | introprogress = introduration+blackafterintro 15 | end 16 | 17 | if introprogress > 0.5 and playedwilhelm == nil then 18 | stabsound:stop();stabsound:play() 19 | playedwilhelm = true 20 | end 21 | 22 | if introprogress == introduration + blackafterintro then 23 | menu_load() 24 | end 25 | end 26 | end 27 | 28 | function intro_draw() 29 | local s = 1 30 | if scale == 1 then 31 | s = 0.5 32 | end 33 | if introprogress >= 0 and introprogress < introduration then 34 | local a = 255 35 | if introprogress < introfadetime then 36 | a = introprogress/introfadetime * 255 37 | elseif introprogress >= introduration-introfadetime then 38 | a = (1-(introprogress-(introduration-introfadetime))/introfadetime) * 255 39 | end 40 | 41 | love.graphics.setColor(255, 255, 255, a) 42 | 43 | if introprogress > introfadetime+0.3 and introprogress < introduration - introfadetime then 44 | local y = (introprogress-0.2-introfadetime) / (introduration-introfadetime) * screenheight*5 45 | love.graphics.draw(logo, screenwidth/2, screenheight/2, 0, s, s, 142, 150) 46 | love.graphics.setScissor(0, screenheight - y, screenwidth, y) 47 | love.graphics.draw(logoblood, screenwidth/2, screenheight/2, 0, s, s, 142, 150) 48 | love.graphics.setScissor() 49 | elseif introprogress >= introduration - introfadetime then 50 | love.graphics.draw(logoblood, screenwidth/2, screenheight/2, 0, s, s, 142, 150) 51 | else 52 | love.graphics.draw(logo, screenwidth/2, screenheight/2, 0, s, s, 142, 150) 53 | end 54 | end 55 | end 56 | 57 | function intro_mousepressed() 58 | stabsound:stop() 59 | menu_load() 60 | end 61 | 62 | function intro_keypressed() 63 | stabsound:stop() 64 | menu_load() 65 | end 66 | -------------------------------------------------------------------------------- /menu.lua: -------------------------------------------------------------------------------- 1 | function menu_load(skip) 2 | gamestate = "menu" 3 | menutimer = love.timer.getTime() 4 | introdelay = 3 5 | menustarted = false 6 | menuselection = 1 7 | 8 | normal_stopgamesounds() 9 | 10 | if skip then 11 | menustarted = true 12 | end 13 | 14 | if controlmethod == "mouse" then 15 | love.mouse.setVisible(false) 16 | love.mouse.setGrab(true) 17 | elseif controlmethod == "mouse direction" then 18 | love.mouse.setGrab(true) 19 | love.mouse.setVisible(true) 20 | else 21 | love.mouse.setGrab(false) 22 | love.mouse.setVisible(true) 23 | end 24 | end 25 | 26 | function menu_update(dt) 27 | if menustarted == false then 28 | currenttime = love.timer.getTime() 29 | if currenttime - menutimer > introdelay then 30 | menustarted = true 31 | end 32 | end 33 | end 34 | 35 | function menu_draw() 36 | local yoffset = 0 37 | if menustarted == false then 38 | currenttime = love.timer.getTime() 39 | yoffset = math.floor(250*scale-250*((currenttime-menutimer)/introdelay)*scale) 40 | end 41 | 42 | love.graphics.draw(title, screenwidth/2-150*scale, screenheight/2-150*scale+yoffset, 0, scale, scale) 43 | 44 | if menuselection == 1 then 45 | love.graphics.setColor(255, 255, 255) 46 | love.graphics.print("> play", screenwidth/2-48*scale, 134*scale+yoffset, 0, scale) 47 | love.graphics.setColor(102, 102, 102) 48 | love.graphics.print("options", screenwidth/2-31*scale, 150*scale+yoffset, 0, scale) 49 | 50 | love.graphics.setColor(255, 255, 255) 51 | elseif menuselection == 2 then 52 | love.graphics.setColor(102, 102, 102) 53 | love.graphics.print("play", screenwidth/2-31*scale, 134*scale+yoffset, 0, scale) 54 | love.graphics.setColor(255, 255, 255) 55 | love.graphics.print("> options", screenwidth/2-48*scale, 150*scale+yoffset, 0, scale) 56 | end 57 | 58 | 59 | local gt = highscoreA[1][2] 60 | 61 | if math.mod(gt, 1) == 0 then 62 | gt = gt .. ".0" 63 | end 64 | 65 | love.graphics.setColor(255, 255, 255) 66 | love.graphics.print(highscoreA[1][3], 137*scale, 35*scale+yoffset, 0, scale) 67 | love.graphics.setColor(255, 255, 0) 68 | love.graphics.print(highscoreA[1][1], 125*scale, 45*scale+yoffset, 0, scale) 69 | love.graphics.rectangle("fill", 117*scale, 46*scale+yoffset, 4*scale, 4*scale) 70 | love.graphics.setColor(127, 127, 127) 71 | love.graphics.print(gt, 165*scale, 45*scale+yoffset, 0, scale) 72 | love.graphics.setColor(255, 255, 255) 73 | love.graphics.draw(clockimg, 155*scale, 45*scale+yoffset, 0, scale, scale) 74 | end 75 | 76 | function menu_keypressed(key) 77 | if key == "escape" then 78 | love.event.push("q") 79 | end 80 | 81 | if menustarted == false then 82 | menustarted = true 83 | elseif key == "return" then 84 | if menuselection == 1 then 85 | normal_load() 86 | else 87 | options_load() 88 | end 89 | elseif key == "up" or key == "down" then 90 | if menuselection == 1 then 91 | menuselection = 2 92 | else 93 | menuselection = 1 94 | end 95 | end 96 | end 97 | 98 | function menu_joystickpressed(joystick, button) 99 | if menustarted == false then 100 | menustarted = true 101 | else 102 | normal_load() 103 | end 104 | end -------------------------------------------------------------------------------- /highscoreentry.lua: -------------------------------------------------------------------------------- 1 | function highscoreentry_load(i) 2 | high = i 3 | gamestate = "highscoreentry" 4 | currentletter = 1 5 | cursortimer = 0 6 | timetimer = 0 7 | cursorblink = true 8 | timeblink = true 9 | end 10 | 11 | function highscoreentry_update(dt) 12 | cursortimer = cursortimer + dt 13 | if cursortimer >= 0.14 then 14 | cursortimer = 0 15 | cursorblink = not cursorblink 16 | end 17 | 18 | timetimer = timetimer + dt 19 | if timetimer >= 0.5 then 20 | timetimer = 0 21 | timeblink = not timeblink 22 | end 23 | end 24 | 25 | function highscoreentry_draw() 26 | love.graphics.translate(0, -20) 27 | local x = screenwidth/2 28 | if high ~= 0 then 29 | love.graphics.draw(highscoreimg, x, 50*scale, 0, 3*scale, 3*scale, 16, 9) 30 | love.graphics.setColor(120, 0, 0) 31 | love.graphics.print("number " .. high, x-35*scale, 75*scale, 0, scale) 32 | else 33 | love.graphics.draw(gameoverimg, x, 50*scale, 0, 3*scale, 3*scale, 16, 9) 34 | end 35 | love.graphics.setColor(255, 255, 255) 36 | love.graphics.print("pellets eaten:", x-125*scale, 100*scale, 0, scale) 37 | love.graphics.print("time taken:", x+25*scale, 100*scale, 0, scale) 38 | if timeblink then 39 | love.graphics.setColor(255, 255, 0) 40 | love.graphics.print(eatored, x-95*scale, 112*scale, 0, scale*2) 41 | 42 | local gt = gametime 43 | 44 | if math.mod(gt, 1) == 0 then 45 | gt = gt .. ".0" 46 | end 47 | 48 | love.graphics.setColor(127, 127, 127) 49 | love.graphics.print(gt, x+37*scale, 112*scale, 0, scale*2) 50 | love.graphics.setColor(255, 255, 255) 51 | end 52 | 53 | love.graphics.setColor(252, 152, 56) 54 | love.graphics.print("highscores:", x-50*scale, 160*scale, 0, scale) 55 | 56 | if high ~= 0 then 57 | love.graphics.setColor(255, 255, 255) 58 | if cursorblink then 59 | love.graphics.print("> " .. highscoreA[high][3] .. string.rep("_", 6-string.len(highscoreA[high][3])), x-55*scale, 137*scale, 0, scale*1.5) 60 | else 61 | love.graphics.print("> " .. highscoreA[high][3] .. " " .. string.rep("_", 5-string.len(highscoreA[high][3])), x-55*scale, 137*scale, 0, scale*1.5) 62 | end 63 | end 64 | for x = 1, 3 do 65 | for y = 1, 3 do 66 | local i = (x-1)*3+y 67 | love.graphics.setColor(255, 255, 255) 68 | love.graphics.print(i .. ":" .. highscoreA[i][3], (20+(y-1)*100)*scale, (175+(x-1)*30)*scale, 0, scale) 69 | love.graphics.setColor(255, 255, 0) 70 | love.graphics.print(highscoreA[i][1], (20+(y-1)*100)*scale, (183+(x-1)*30)*scale, 0, scale) 71 | love.graphics.rectangle("fill", (14+(y-1)*100)*scale, (185+(x-1)*30)*scale, 4*scale, 4*scale) 72 | love.graphics.setColor(127, 127, 127) 73 | love.graphics.print(highscoreA[i][2], (60+(y-1)*100)*scale, (183+(x-1)*30)*scale, 0, scale) 74 | love.graphics.setColor(255, 255, 255) 75 | love.graphics.draw(clockimg, (51+(y-1)*100)*scale, (183+(x-1)*30)*scale, 0, scale, scale) 76 | end 77 | end 78 | end 79 | 80 | function highscoreentry_joystickpressed(joy, button) 81 | 82 | end 83 | 84 | function highscoreentry_keypressed(key, unicode) 85 | if high == 0 then 86 | menu_load() 87 | return 88 | end 89 | 90 | local char 91 | for i = 1, #whitelist do 92 | if tonumber(unicode) and unicode >= 1 and unicode <= 256 and string.char(unicode) and string.char(unicode):lower() == whitelist:sub(i, i) then 93 | char = whitelist:sub(i, i) 94 | end 95 | end 96 | 97 | if char then 98 | if string.len(highscoreA[high][3]) < 6 then 99 | cursorblink = true 100 | highscoreA[high][3] = highscoreA[high][3] .. char 101 | local sound = _G["wakka" .. math.mod(#highscoreA[high][3], 2)+1] 102 | sound:stop() 103 | sound:play() 104 | else 105 | 106 | end 107 | elseif key == "return" then 108 | savehighscoresA() 109 | menu_load() 110 | elseif key == "backspace" then 111 | if highscoreA[high][3]:len() > 0 then 112 | cursorblink = true 113 | highscoreA[high][3] = string.sub(highscoreA[high][3], 1, highscoreA[high][3]:len()-1) 114 | end 115 | end 116 | end -------------------------------------------------------------------------------- /main.lua: -------------------------------------------------------------------------------- 1 | function love.load() 2 | 3 | require "normal" 4 | require "menu" 5 | require "highscoreentry" 6 | require "options" 7 | require "intro" 8 | 9 | ------------ 10 | --SETTINGS-- 11 | ------------ 12 | soundenabled = true 13 | fullscreen = false 14 | joystickdeadzone = 0.5 15 | 16 | numhighscores = 9 17 | 18 | gravitymul = 260 19 | 20 | scale = 2 21 | zoom = 1 22 | 23 | controlmethods = {"mouse", "keyboard", "mouse direction", "joystick", "wheel steering", "wheel direct"} 24 | controldescriptions = { mouse="move the mouse\n\nleft and right", 25 | keyboard="use arrow keys to\n\nrotate, shift to\n\nspeed up", 26 | ['mouse direction']="point with your\n\nmouse towards a\n\ndirection", 27 | joystick="point with your\n\njoystick", 28 | ['wheel steering']="drive like a car", 29 | ['wheel direct']="1:1 wheel to\n\ngame translation"} 30 | controlmethod = "mouse" 31 | 32 | pacfocus = false 33 | superpower = "normal" --clone, walls, normal 34 | powerupduration = 6 35 | superpelletblinkrate = 0.5 36 | wakkatimer = 0 37 | highscore = 0 38 | deathtime = 1.5 39 | deathdelay = 1 40 | mouse2rate = 0.05 41 | mouse2speed = 20 --50 for my macbook because who knows why, 20 else 42 | volume = 10 43 | 44 | pacmouthlimit = 0.25 45 | mouthduration = 0.22 46 | 47 | whitelist = "abcdefghijklmnopqrstuvwxyz 0123456789" 48 | 49 | scale = 2 50 | 51 | ----END---- 52 | 53 | loadhighscores() 54 | 55 | icon = love.graphics.newImage("graphics/icon.png");icon:setFilter("nearest", "nearest") 56 | changescale(scale) 57 | 58 | boardwidth = 220 59 | boardheight = 216 60 | 61 | --GRAPHICS-- 62 | 63 | mainfield = love.graphics.newImage("graphics/field.png");mainfield:setFilter("nearest", "nearest") 64 | mainfieldoverlay = love.graphics.newImage("graphics/fieldoverlay.png");mainfieldoverlay:setFilter("nearest", "nearest") 65 | superpellet = love.graphics.newImage("graphics/superpellet.png");superpellet:setFilter("nearest", "nearest") 66 | pacman = love.graphics.newImage("graphics/pacmanman.png") 67 | ghost1 = love.graphics.newImage("graphics/ghost1.png") 68 | ghost2 = love.graphics.newImage("graphics/ghost2.png") 69 | ghost3 = love.graphics.newImage("graphics/ghost3.png") 70 | ghostscared1 = love.graphics.newImage("graphics/ghostscared1.png") 71 | ghostscared2 = love.graphics.newImage("graphics/ghostscared2.png") 72 | ghosteyes = love.graphics.newImage("graphics/eyes.png") 73 | spinnyeyes = love.graphics.newImage("graphics/spinnyeyes.png") 74 | title = love.graphics.newImage("graphics/title.png");title:setFilter("nearest", "nearest") 75 | gamescoreimg = love.graphics.newImage("graphics/gamescore.png");gamescoreimg:setFilter("nearest", "nearest") 76 | highscoreimg = love.graphics.newImage("graphics/highscore.png");highscoreimg:setFilter("nearest", "nearest") 77 | gameoverimg = love.graphics.newImage("graphics/gameover.png");gameoverimg:setFilter("nearest", "nearest") 78 | clockimg = love.graphics.newImage("graphics/clock.png");clockimg:setFilter("nearest", "nearest") 79 | optionsimg = love.graphics.newImage("graphics/options.png");optionsimg:setFilter("nearest", "nearest") 80 | logo = love.graphics.newImage("graphics/logo.png") 81 | logoblood = love.graphics.newImage("graphics/logoblood.png") 82 | 83 | 84 | fontimage = love.graphics.newImage("graphics/font.png");fontimage:setFilter("nearest","nearest") 85 | pacmanfont = love.graphics.newImageFont(fontimage, "0123456789abcdefghijklmnopqrstuvwxyz.:/,'C-_> <") 86 | love.graphics.setFont(pacmanfont) 87 | 88 | --SOUNDS-- 89 | wakka1 = love.audio.newSource("sounds/pacman_waka_wa.ogg", "static") 90 | wakka2 = love.audio.newSource("sounds/pacman_waka_ka.ogg", "static") 91 | eatghost = love.audio.newSource("sounds/eat_ghost.ogg", "static"); eatghost:setVolume(0.5) 92 | ghostsiren = love.audio.newSource("sounds/ghosts_siren.ogg", "static"); ghostsiren:setVolume(0); ghostsiren:setLooping(true) 93 | ghostrunaway = love.audio.newSource("sounds/ghosts_runaway.ogg", "static"); ghostrunaway:setVolume(0); ghostrunaway:setLooping(true) 94 | beginning = love.audio.newSource("sounds/pacman_beginning.ogg", "static") 95 | gamewin = love.audio.newSource("sounds/win.ogg", "static") 96 | death = love.audio.newSource("sounds/pacman_death.ogg", "static") 97 | stabsound = love.audio.newSource("sounds/stab.ogg", "static") 98 | 99 | intro_load() 100 | end 101 | 102 | function love.update(dt) 103 | if skipupdate then 104 | skipupdate = false 105 | return 106 | end 107 | 108 | dt = math.min(dt, 1/30) 109 | if _G[gamestate .. "_update"] then 110 | _G[gamestate .. "_update"](dt) 111 | end 112 | end 113 | 114 | function love.draw() 115 | if _G[gamestate .. "_draw"] then 116 | _G[gamestate .. "_draw"]() 117 | end 118 | end 119 | 120 | function love.keypressed(key, unicode) 121 | if _G[gamestate .. "_keypressed"] then 122 | _G[gamestate .. "_keypressed"](key, unicode) 123 | end 124 | end 125 | 126 | function love.mousepressed(x, y, button) 127 | if _G[gamestate .. "_mousepressed"] then 128 | _G[gamestate .. "_mousepressed"](x, y, button) 129 | end 130 | end 131 | 132 | function love.joystickpressed(joystick, button) 133 | if _G[gamestate .. "_joystickpressed"] then 134 | _G[gamestate .. "_joystickpressed"](joystick, button) 135 | end 136 | end 137 | 138 | function string:split(delimiter) --Not by me 139 | local result = {} 140 | local from = 1 141 | local delim_from, delim_to = string.find( self, delimiter, from ) 142 | while delim_from do 143 | table.insert( result, string.sub( self, from , delim_from-1 ) ) 144 | from = delim_to + 1 145 | delim_from, delim_to = string.find( self, delimiter, from ) 146 | end 147 | table.insert( result, string.sub( self, from ) ) 148 | return result 149 | end 150 | 151 | function changescale(s) 152 | local grabbed = love.mouse.isGrabbed() 153 | scale = s 154 | 155 | windowwidth = 320*scale 156 | windowheight = 250*scale 157 | 158 | screenwidth = windowwidth 159 | screenheight = windowheight 160 | 161 | 162 | fsaa = 16 163 | vsync = true 164 | love.graphics.setLineWidth(5/3*scale) 165 | 166 | if gamestate == "options" then 167 | options_createdemoworld() 168 | end 169 | 170 | if love.graphics.getWidth() ~= windowwidth or love.graphics.getHeight() ~= windowheight then 171 | love.graphics.setMode(windowwidth, windowheight, fullscreen, vsync, fsaa) 172 | end 173 | 174 | love.graphics.setIcon(icon) 175 | 176 | love.mouse.setGrab(grabbed) 177 | end 178 | 179 | function print_r (t, indent) --Not by me 180 | local indent=indent or '' 181 | for key,value in pairs(t) do 182 | io.write(indent,'[',tostring(key),']') 183 | if type(value)=="table" then io.write(':\n') print_r(value,indent..'\t') 184 | else io.write(' = ',tostring(value),'\n') end 185 | end 186 | end 187 | 188 | function loadhighscores() 189 | if love.filesystem.exists("highscoreA") then 190 | local s = love.filesystem.read("highscoreA"):split("#") 191 | if #s < 2 then 192 | s[3] = s[1] 193 | else 194 | controlmethod = s[1] 195 | scale = tonumber(s[2]) 196 | end 197 | local t = s[3] 198 | highscoreA = t:split(";") 199 | for i = 1, #highscoreA do 200 | highscoreA[i] = highscoreA[i]:split(":") 201 | highscoreA[i][1] = tonumber(highscoreA[i][1]) 202 | highscoreA[i][2] = tonumber(highscoreA[i][2]) 203 | end 204 | else 205 | highscoreA = {} 206 | for i = 1, numhighscores do 207 | highscoreA[i] = {0, 0, "------"} 208 | end 209 | end 210 | 211 | savehighscoresA() 212 | end 213 | 214 | function savehighscoresA() 215 | local s = controlmethod .. "#" 216 | local s = s .. scale .. "#" 217 | for i = 1, numhighscores do 218 | if (highscoreA[i][1] and highscoreA[i][2] and highscoreA[i][3]) then 219 | s = s .. highscoreA[i][1] .. ":" .. highscoreA[i][2] .. ":" .. highscoreA[i][3] 220 | else 221 | s = s .. "------" .. ":0:0" 222 | end 223 | if i ~= numhighscores then 224 | s = s .. ";" 225 | end 226 | end 227 | 228 | love.filesystem.write("highscoreA", s) 229 | end 230 | 231 | function addzeros(s, i) 232 | for j = string.len(s)+1, i do 233 | s = "0" .. s 234 | end 235 | return s 236 | end -------------------------------------------------------------------------------- /options.lua: -------------------------------------------------------------------------------- 1 | function options_load() 2 | gamestate = "options" 3 | optionsselection = 1 4 | for i = 1, #controlmethods do 5 | if controlmethods[i] == controlmethod then 6 | optionsselection = i 7 | break 8 | end 9 | end 10 | 11 | options_createdemoworld() 12 | 13 | demorotation = 0 14 | demotargetrotation = 0 15 | options_updategravity(1) 16 | demoupdates = 0 17 | 18 | ghostx = windowwidth+500 19 | 20 | optionsmouth = pacmouthlimit 21 | mouthdir = -1 22 | 23 | if controlmethod == "mouse" then 24 | love.mouse.setVisible(false) 25 | love.mouse.setGrab(true) 26 | elseif controlmethod == "mouse direction" then 27 | love.mouse.setGrab(true) 28 | love.mouse.setVisible(true) 29 | else 30 | love.mouse.setGrab(false) 31 | love.mouse.setVisible(true) 32 | end 33 | end 34 | 35 | function options_createdemoworld() 36 | --demo world 37 | demoworld = love.physics.newWorld( 0, 0, screenwidth*2, screenheight*2, 0, 800, false) 38 | 39 | demofieldbody = love.physics.newBody(demoworld, screenwidth / 2, screenheight / 2, 0, 0) 40 | 41 | demoworldshapes = {} 42 | demoworldshapes[1] = love.physics.newRectangleShape(demofieldbody, -25*scale, 0*scale, 10*scale, 50*scale) 43 | demoworldshapes[2] = love.physics.newRectangleShape(demofieldbody, 0*scale, -25*scale, 50*scale, 10*scale) 44 | demoworldshapes[3] = love.physics.newRectangleShape(demofieldbody, 25*scale, 0*scale, 10*scale, 50*scale) 45 | demoworldshapes[4] = love.physics.newRectangleShape(demofieldbody, 0*scale, 25*scale, 50*scale, 10*scale) 46 | demoworldshapes[5] = love.physics.newRectangleShape(demofieldbody, 0*scale, 0*scale, 5*scale, 5*scale) 47 | 48 | demopacmanbody = love.physics.newBody(demoworld, screenwidth/2-4*scale, screenheight/2-10*scale, 0.1) 49 | demopacmanbody:setBullet(true) 50 | demopacmanbody:setInertia( 0.001 ) 51 | demopacmanshape = love.physics.newCircleShape(demopacmanbody, 0, 0, 6.5*scale) 52 | demopacmanshape:setFriction( 1000) 53 | demopacmanshape:setMask(3) 54 | end 55 | 56 | function options_update(dt) 57 | demoworld:update(dt) 58 | options_updategravity(dt) 59 | 60 | --Controls 61 | if controlmethod == "joystick" then 62 | x = love.joystick.getAxis( 0, 0 ) 63 | y = -love.joystick.getAxis( 0, 1 ) 64 | if math.abs(x) + math.abs(y) > joystickdeadzone then 65 | demotargetrotation = math.deg(math.atan2(x, y) ) 66 | end 67 | elseif controlmethod == "wheel steering" then 68 | x = love.joystick.getAxis( 0, 0) 69 | demotargetrotation = demotargetrotation+x*dt*400 70 | if demotargetrotation < 0 then 71 | demotargetrotation = demotargetrotation + 360 72 | elseif demotargetrotation > 360 then 73 | demotargetrotation = demotargetrotation - 360 74 | end 75 | elseif controlmethod == "wheel direct" then 76 | x = love.joystick.getAxis( 0, 0) 77 | demotargetrotation = x*180 78 | if demotargetrotation < 0 then 79 | demotargetrotation = demotargetrotation + 360 80 | end 81 | elseif controlmethod == "keyboard" then 82 | local multiplier = 100 83 | if love.keyboard.isDown( "rshift" ) or love.keyboard.isDown( "lshift" ) then 84 | multiplier = 300 85 | end 86 | if love.keyboard.isDown( "left" ) then 87 | demotargetrotation = demotargetrotation - multiplier*dt 88 | end 89 | if love.keyboard.isDown( "right" ) then 90 | demotargetrotation = demotargetrotation + multiplier*dt 91 | end 92 | elseif controlmethod == "mouse direction" then 93 | x, y = love.mouse.getPosition( ) 94 | x = x - (windowwidth/2+windowwidth/4.5) 95 | y = (windowheight/2-windowheight/5) - y 96 | demotargetrotation = math.deg(math.atan2(x, y)) 97 | elseif controlmethod == "mouse" then 98 | x, y = love.mouse.getPosition() 99 | 100 | if oldx then 101 | diff = x-oldx 102 | demotargetrotation = demotargetrotation+diff*dt*mouse2speed 103 | end 104 | 105 | oldx, oldy = x, y 106 | 107 | demoupdates = demoupdates + dt 108 | if demoupdates > mouse2rate then 109 | demoupdates = 0 110 | oldx = windowwidth/2 111 | love.mouse.setPosition(windowwidth/2, windowheight/2) 112 | end 113 | end 114 | 115 | optionsmouth = optionsmouth + dt*mouthdir*3 116 | 117 | if optionsmouth < 0 then 118 | optionsmouth = 0 119 | mouthdir = 1 120 | elseif optionsmouth > pacmouthlimit then 121 | optionsmouth = pacmouthlimit 122 | mouthdir = -1 123 | end 124 | 125 | ghostx = ghostx - dt*150*scale 126 | if ghostx < -1000 then 127 | ghostx = windowwidth + 500 128 | end 129 | end 130 | 131 | function options_draw() 132 | --options 133 | love.graphics.setColor(255, 255, 255) 134 | love.graphics.draw(optionsimg, windowwidth/2-32*scale, 14*scale, 0, scale, scale) 135 | 136 | 137 | love.graphics.rectangle("line", 5*scale, 63*scale, 140*scale, 160*scale) 138 | love.graphics.rectangle("line", 5*scale, 63*scale, 140*scale, 122*scale) 139 | love.graphics.setColor(164, 0, 0) 140 | love.graphics.print("control scheme", 8*scale, 53*scale, 0, scale) 141 | love.graphics.setColor(255, 255, 255) 142 | local controlmethods = {unpack(controlmethods)} 143 | 144 | 145 | local s = "scale: " 146 | if scale > 1 then 147 | s = s .. "<" 148 | else 149 | s = s .. " " 150 | end 151 | s = s .. " " .. scale .. " " 152 | if scale < 4 then 153 | s = s .. ">" 154 | end 155 | 156 | table.insert(controlmethods, s) 157 | 158 | 159 | local s = "volume: " 160 | if volume > 0 then 161 | s = s .. "<" 162 | else 163 | s = s .. " " 164 | end 165 | s = s .. " " .. volume .. " " 166 | if volume < 10 then 167 | s = s .. ">" 168 | end 169 | 170 | table.insert(controlmethods, s) 171 | 172 | for i = 1, #controlmethods do 173 | if optionsselection == i then 174 | love.graphics.setColor(255, 255, 255) 175 | else 176 | love.graphics.setColor(127, 127, 127) 177 | end 178 | love.graphics.print(controlmethods[i], 20*scale, ((i-1)*20+70)*scale, 0, scale) 179 | end 180 | 181 | local bla = 1 182 | for i = 1, #controlmethods do 183 | if controlmethods[i] == controlmethod then 184 | bla = i 185 | break 186 | end 187 | end 188 | 189 | love.graphics.setColor(252, 116, 96) 190 | love.graphics.print(">", 8*scale, ((bla-1)*20+70)*scale, 0, scale) 191 | love.graphics.setColor(255, 255, 255) 192 | if optionsselection < #controlmethods-1 then 193 | love.graphics.print(controldescriptions[controlmethods[optionsselection]], 153*scale, 150*scale, 0, scale) 194 | elseif optionsselection < #controlmethods then 195 | love.graphics.print("change the size\n\nof the window", 153*scale, 150*scale, 0, scale) 196 | else 197 | love.graphics.print("change volume", 153*scale, 150*scale, 0, scale) 198 | end 199 | love.graphics.rectangle("line", 150*scale, 145*scale, 165*scale, 53*scale) 200 | love.graphics.setColor(164, 0, 0) 201 | love.graphics.print("description", 153*scale, 135*scale, 0, scale) 202 | love.graphics.setColor(255, 255, 255) 203 | 204 | --Silly ghosts 205 | for i = 1, 3 do 206 | love.graphics.draw(ghostscared1, ghostx + i*25*scale, windowheight-20*scale, 0, scale/40, scale/40) 207 | end 208 | 209 | local x = ghostx + 120*scale 210 | local y = windowheight-13*scale 211 | 212 | coords = {} 213 | table.insert(coords, x) --add center 214 | table.insert(coords, y) 215 | 216 | for ang = 360*(optionsmouth/2), 360 - 360*(optionsmouth/2) do 217 | table.insert(coords, math.sin(math.rad(ang-90))*6.5*scale+x) 218 | table.insert(coords, -math.cos(math.rad(ang-90))*6.5*scale+y) 219 | end 220 | 221 | if #coords > 6 then 222 | love.graphics.setColor(255, 255, 50) 223 | love.graphics.polygon("fill", unpack(coords)) 224 | love.graphics.setColor(255, 255, 255) 225 | end 226 | 227 | love.graphics.setColor(0, 0, 255) 228 | love.graphics.rectangle("line", -10, windowheight-22*scale, windowwidth+20, 18*scale) 229 | 230 | --Rotate da worl 231 | love.graphics.push() 232 | love.graphics.translate(windowwidth/2, windowheight/2) 233 | love.graphics.translate(windowwidth/4.5, -windowheight/5) 234 | love.graphics.rotate(math.rad(demorotation)) 235 | love.graphics.translate(-windowwidth/2, -windowheight/2) 236 | 237 | --Demo Pacman 238 | local x = demopacmanbody:getX() 239 | local y = demopacmanbody:getY() 240 | coords = {} 241 | table.insert(coords, x) --add center 242 | table.insert(coords, y) 243 | 244 | for ang = 360*(pacmouthlimit/2), 360 - 360*(pacmouthlimit/2) do 245 | table.insert(coords, math.sin(math.rad(ang-90) + demopacmanbody:getAngle())*6.5*scale+x) 246 | table.insert(coords, -math.cos(math.rad(ang-90) + demopacmanbody:getAngle())*6.5*scale+y) 247 | end 248 | 249 | if #coords > 6 then 250 | love.graphics.setColor(255, 255, 50) 251 | love.graphics.polygon("fill", unpack(coords)) 252 | love.graphics.setColor(255, 255, 255) 253 | end 254 | 255 | love.graphics.setColor(0, 0, 255) 256 | love.graphics.rectangle("line", windowwidth/2-21*scale, windowheight/2-21*scale, 42*scale, 42*scale) 257 | love.graphics.rectangle("line", windowwidth/2-24*scale, windowheight/2-24*scale, 48*scale, 48*scale) 258 | love.graphics.rectangle("line", windowwidth/2-2*scale, windowheight/2-2*scale, 4*scale, 4*scale) 259 | love.graphics.pop() 260 | end 261 | 262 | function options_updategravity(dt) --"rotates" the world. (It actually only changes the gravity "direction" because actually rotating the world caused centrifugalforces to be a bitch) 263 | --smooth targetrotation into rotation 264 | 265 | demotargetrotation = math.mod(demotargetrotation+360, 360) 266 | 267 | if demotargetrotation > demorotation + 180 then 268 | demorotation = demorotation + 360 269 | elseif demotargetrotation < demorotation - 180 then 270 | demorotation = demorotation - 360 271 | end 272 | 273 | if demotargetrotation > demorotation then 274 | demorotation = demorotation + (demotargetrotation-demorotation)*dt*20 275 | else 276 | demorotation = demorotation + (demotargetrotation-demorotation)*dt*20 277 | end 278 | 279 | demogravityX = math.sin(math.rad(demorotation)) 280 | demogravityY = math.cos(math.rad(demorotation)) 281 | demoworld:setGravity( demogravityX*gravitymul*scale, demogravityY*gravitymul*scale ) 282 | end 283 | 284 | function options_keypressed(key, uni) 285 | if key == "escape" then 286 | savehighscoresA() 287 | menu_load(true) 288 | end 289 | 290 | if key == "return" then 291 | if optionsselection <= #controlmethods then 292 | controlmethod = controlmethods[optionsselection] 293 | 294 | if controlmethod == "mouse" then 295 | love.mouse.setVisible(false) 296 | love.mouse.setGrab(true) 297 | elseif controlmethod == "mouse direction" then 298 | love.mouse.setGrab(true) 299 | love.mouse.setVisible(true) 300 | else 301 | love.mouse.setGrab(false) 302 | love.mouse.setVisible(true) 303 | end 304 | end 305 | end 306 | 307 | if optionsselection == #controlmethods + 1 then 308 | if key == "right" then 309 | if scale < 4 then 310 | changescale(scale+1) 311 | end 312 | elseif key == "left" then 313 | if scale > 1 then 314 | changescale(scale-1) 315 | end 316 | end 317 | elseif optionsselection == #controlmethods + 2 then 318 | if key == "right" then 319 | if volume < 10 then 320 | volume = volume + 1 321 | love.audio.setVolume(volume/10) 322 | local sound = _G["wakka" .. math.mod(volume, 2)+1] 323 | sound:stop() 324 | sound:play() 325 | end 326 | elseif key == "left" then 327 | if volume > 0 then 328 | volume = volume - 1 329 | love.audio.setVolume(volume/10) 330 | local sound = _G["wakka" .. math.mod(volume, 2)+1] 331 | sound:stop() 332 | sound:play() 333 | end 334 | end 335 | end 336 | 337 | if key == "up" then 338 | optionsselection = math.max(optionsselection - 1, 1) 339 | elseif key == "down" then 340 | optionsselection = math.min(optionsselection + 1, #controlmethods+2) 341 | end 342 | end -------------------------------------------------------------------------------- /normal.lua: -------------------------------------------------------------------------------- 1 | function normal_load() --initializes all variables 2 | updates = 0 3 | gamestate = "normal" 4 | gamestarted = false 5 | 6 | if controlmethod == "mouse" then 7 | love.mouse.setVisible(false) 8 | love.mouse.setGrab(true) 9 | elseif controlmethod == "mouse direction" then 10 | love.mouse.setPosition(screenwidth/2, screenheight/4) 11 | love.mouse.setGrab(true) 12 | end 13 | 14 | normal_createworld() 15 | 16 | if soundenabled then 17 | love.audio.stop(beginning) 18 | love.audio.play(beginning) 19 | end 20 | 21 | waorka = 1 22 | prevghostpos = false 23 | ghostmove = {} 24 | ghostvolume = 0 25 | gametime = 0 26 | eatored = 0 27 | score = 0 28 | lives = 3 29 | superpellettimer = 0 30 | superpelletblink = false 31 | powerup = false 32 | starttimer = love.timer.getTime() 33 | deathtimer = deathtime+deathdelay 34 | pacmouthopenness = pacmouthlimit 35 | 36 | ghosttimer = {} 37 | for i = 1, 3 do 38 | ghosttimer[i] = 0 39 | end 40 | ghostdeadstartx = {} 41 | ghostdeadstarty = {} 42 | ghostdeadendx = {} 43 | ghostdeadendy = {} 44 | ghostdeadr = {} 45 | 46 | ghosttime = 1 47 | blinktime = 2 48 | blinkrate = 0.3 49 | 50 | rotation = 0 51 | targetrotation = 0 52 | normal_updategravity(1) 53 | 54 | pelletmap ={{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, --shit man 55 | {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}, --26x29 56 | {2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2}, --1 = pellet 57 | {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}, --2 = super pellet 58 | {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, --244 total (240 normal + 4 super) 59 | {1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1}, --It's [y][x]! 60 | {1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1}, 61 | {1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1}, 62 | {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}, 63 | {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}, 64 | {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}, 65 | {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}, 66 | {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}, 67 | {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}, 68 | {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}, 69 | {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}, 70 | {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}, 71 | {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}, 72 | {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}, 73 | {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 74 | {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}, 75 | {2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2}, 76 | {1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1}, 77 | {0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0}, 78 | {0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0}, 79 | {1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1}, 80 | {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, 81 | {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, 82 | {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}} 83 | 84 | 85 | if mousecontrol2 then 86 | love.mouse.setPosition(windowwidth/2, windowheight/2) 87 | end 88 | --skipupdate = true 89 | end 90 | 91 | function normal_afterdeath() 92 | if lives > 1 then 93 | lives = lives - 1 94 | 95 | superpellettimer = 0 96 | superpelletblink = false 97 | powerup = false 98 | starttimer = love.timer.getTime() 99 | deathtimer = deathtime+deathdelay 100 | pacmouthopenness = pacmouthlimit 101 | 102 | rotation = 0 103 | targetrotation = 0 104 | normal_updategravity(1) 105 | gamestarted = false 106 | normal_createworld() 107 | waorka = 1 108 | prevghostpos=false 109 | 110 | ghosttimer = {} 111 | for i = 1, 3 do 112 | ghosttimer[i] = 0 113 | end 114 | 115 | if controlmethod == "mouse direction" or controlmethod == "mouse" then 116 | love.mouse.setPosition(screenwidth/2, screenheight/4) 117 | end 118 | else 119 | normal_gamefinished() 120 | end 121 | end 122 | 123 | function normal_update(dt) 124 | if gamestarted and eatored > 0 then 125 | gametime = gametime + dt 126 | end 127 | currenttime = love.timer.getTime() 128 | 129 | normal_updategravity(dt) 130 | if gamestarted == false then 131 | if currenttime - starttimer > 0 then 132 | normal_start() 133 | end 134 | elseif deathtimer < deathtime+deathdelay then 135 | deathtimer = deathtimer + dt 136 | 137 | if deathtimer > deathtime then 138 | pacmouthopenness = 1 139 | else 140 | pacmouthopenness = pacmouthlimit + (1-pacmouthlimit) * (deathtimer/deathtime) 141 | end 142 | 143 | if deathtimer > deathtime + deathdelay then 144 | deathtimer = deathtime + deathdelay 145 | normal_afterdeath() 146 | end 147 | else 148 | --wakka animation 149 | if currenttime - wakkatimer < mouthduration then 150 | if currenttime - wakkatimer < mouthduration/2 then 151 | pacmouthopenness = pacmouthlimit-pacmouthlimit*((currenttime-wakkatimer)/(mouthduration/2)) 152 | else 153 | pacmouthopenness = pacmouthlimit*((currenttime-wakkatimer-mouthduration/2)/(mouthduration/2)) 154 | end 155 | else 156 | pacmouthopenness = pacmouthlimit 157 | end 158 | 159 | --powerup runout 160 | if powerup then 161 | if currenttime - poweruptimer > powerupduration then 162 | powerup = false 163 | if superpower == "walls" then 164 | pacmanshape:setMask() 165 | elseif superpower == "clone" then 166 | clonebody:destroy() 167 | cloneshape:destroy() 168 | pacmanshape:setMask() 169 | end 170 | end 171 | end 172 | 173 | --superpellet blink 174 | if currenttime - superpellettimer > superpelletblinkrate then 175 | superpelletblink = not superpelletblink 176 | superpellettimer = currenttime 177 | end 178 | 179 | --joystick 180 | if controlmethod == "joystick" then 181 | x = love.joystick.getAxis( 0, 0 ) 182 | y = -love.joystick.getAxis( 0, 1 ) 183 | if math.abs(x) + math.abs(y) > joystickdeadzone then 184 | targetrotation = math.deg(math.atan2(x, y) ) 185 | end 186 | elseif controlmethod == "wheel steering" then 187 | x = love.joystick.getAxis( 0, 0) 188 | targetrotation = targetrotation+x*dt*400 189 | if targetrotation < 0 then 190 | targetrotation = targetrotation + 360 191 | elseif targetrotation > 360 then 192 | targetrotation = targetrotation - 360 193 | end 194 | elseif controlmethod == "wheel direct" then 195 | x = love.joystick.getAxis( 0, 0) 196 | targetrotation = x*180 197 | if targetrotation < 0 then 198 | targetrotation = targetrotation + 360 199 | end 200 | elseif controlmethod == "keyboard" then 201 | local multiplier = 100 202 | if love.keyboard.isDown( "rshift" ) or love.keyboard.isDown( "lshift" ) then 203 | multiplier = 300 204 | end 205 | if love.keyboard.isDown( "left" ) then 206 | targetrotation = targetrotation - multiplier*dt 207 | normal_updategravity(dt) 208 | end 209 | if love.keyboard.isDown( "right" ) then 210 | targetrotation = targetrotation + multiplier*dt 211 | normal_updategravity(dt) 212 | end 213 | elseif controlmethod == "mouse direction" then 214 | x, y = love.mouse.getPosition( ) 215 | x = x - screenwidth/2 216 | y = (screenheight - y) - screenheight/2 217 | targetrotation = math.deg(math.atan2(x, y)) 218 | normal_updategravity(dt) 219 | elseif controlmethod == "mouse" then 220 | x, y = love.mouse.getPosition() 221 | 222 | if oldx then 223 | diff = x-oldx 224 | targetrotation = targetrotation+diff*dt*mouse2speed 225 | end 226 | 227 | oldx, oldy = x, y 228 | 229 | updates = updates + dt 230 | if updates > mouse2rate then 231 | updates = 0 232 | oldx = windowwidth/2 233 | love.mouse.setPosition(windowwidth/2, windowheight/2) 234 | end 235 | end 236 | 237 | --pacman stuff 238 | x, y = normal_pacmangetposition(pacmanbody:getX(), pacmanbody:getY()) 239 | normal_checkpellet(x, y) 240 | 241 | --check for death 242 | for i = 1, 3 do 243 | if ghosttimer[i] == 0 then 244 | local dist = math.sqrt((pacmanbody:getX()-ghostbody[i]:getX())^2 + (pacmanbody:getY()-ghostbody[i]:getY())^2) 245 | if dist < 12*2 then 246 | if powerup then 247 | --kill ghost 248 | ghostbody[i]:setLinearVelocity(0, 0) 249 | ghostbody[i]:setAngularVelocity(0) 250 | ghosttimer[i] = ghosttime 251 | ghostdeadstartx[i] = ghostbody[i]:getX() 252 | ghostdeadstarty[i] = ghostbody[i]:getY() 253 | ghostdeadendx[i] = (screenwidth/2 + (i-2)*15*2) 254 | ghostdeadendy[i] = (screenheight/2-(boardheight*0.125)*2) 255 | ghostbody[i]:setX(screenwidth/2) 256 | ghostbody[i]:setY(screenheight/2) 257 | ghostdeadr[i] = ghostbody[i]:getAngle() 258 | eatghost:stop() 259 | eatghost:play() 260 | else 261 | gamestarted = false 262 | superpelletblink = false 263 | deathtimer = 0 264 | normal_stopgamesounds() 265 | death:play() 266 | end 267 | end 268 | end 269 | end 270 | 271 | for i = 1, 3 do 272 | if ghosttimer[i] > 0 then 273 | ghosttimer[i] = ghosttimer[i] - dt 274 | if ghosttimer[i] <= 0 then 275 | ghostbody[i]:setX(screenwidth/2 + (i-2)*15*2) 276 | ghostbody[i]:setY(screenheight/2-(boardheight*0.125)*2) 277 | ghostbody[i]:setLinearVelocity(0, 0) 278 | ghostbody[i]:setAngularVelocity(0) 279 | ghosttimer[i] = 0 280 | else 281 | ghostbody[i]:setX(screenwidth/2) 282 | ghostbody[i]:setY(screenheight/2) 283 | ghostbody[i]:setLinearVelocity(0, 0) 284 | ghostbody[i]:setAngularVelocity(0) 285 | end 286 | end 287 | end 288 | 289 | 290 | --Teleport 291 | if y == 14 and x < 2 then 292 | pacmanbody:setX(screenwidth/2+11.5*8*2) 293 | elseif y == 14 and x > 25 then 294 | pacmanbody:setX(screenwidth/2-11.5*8*2) 295 | end 296 | 297 | for i = 1, 3 do 298 | x, y = normal_pacmangetposition(ghostbody[i]:getX(), ghostbody[i]:getY()) 299 | --Teleport 300 | if y == 14 and x < 2 then 301 | ghostbody[i]:setX(screenwidth/2+11.5*8*2) 302 | elseif y == 14 and x > 25 then 303 | ghostbody[i]:setX(screenwidth/2-11.5*8*2) 304 | end 305 | end 306 | 307 | if gamestarted and prevghostpos then 308 | for i = 1, 3 do 309 | ghostmovediag = (ghostbody[i]:getX() - prevghostpos[i][1])+(ghostbody[i]:getY()- prevghostpos[i][2]) 310 | if ghostmovediag < 0 then ghostmovediag = -ghostmovediag end 311 | ghostmove[i] = math.sqrt(ghostmovediag) 312 | prevghostpos[i] = {ghostbody[i]:getX(), ghostbody[i]:getY()} 313 | end 314 | calcghostvolume = (ghostmove[1]+ghostmove[2]+ghostmove[3])/3-0.15 315 | if calcghostvolume < 0 then calcghostvolume = 0 end 316 | if calcghostvolume > ghostvolume then 317 | ghostvolume = ghostvolume + 0.02 318 | elseif calcghostvolume == 0 then 319 | ghostvolume = ghostvolume - 0.06 320 | elseif calcghostvolume < ghostvolume then 321 | ghostvolume = ghostvolume - 0.02 322 | end 323 | if ghostvolume > 0.6 then ghostvolume = 0.6 end 324 | 325 | else 326 | prevghostpos = {} 327 | ghostvolume = 0 328 | end 329 | 330 | if powerup then 331 | ghostrunaway:setVolume(ghostvolume+0.3) 332 | ghostsiren:setVolume(0) 333 | else 334 | ghostrunaway:setVolume(0) 335 | ghostsiren:setVolume(ghostvolume) 336 | end 337 | 338 | 339 | 340 | 341 | --wake up ghosts so they don't get stuck. Fucking box2d, how does it work 342 | for i = 1, 3 do 343 | ghostbody[i]:wakeUp() 344 | prevghostpos[i] = {ghostbody[i]:getX(), ghostbody[i]:getY()} 345 | end 346 | 347 | world:update(dt) 348 | end 349 | end 350 | 351 | function normal_stopgamesounds() 352 | ghostrunaway:setVolume(0) 353 | ghostsiren:setVolume(0) 354 | ghostvolume = 0 355 | beginning:stop() 356 | eatghost:stop() 357 | wakka1:stop() 358 | wakka2:stop() 359 | death:stop() 360 | love.audio.stop() 361 | end 362 | 363 | function normal_draw() 364 | --pac lives 365 | for i = 1, lives do 366 | love.graphics.draw( pacman, screenwidth/2-136*scale, screenheight/2+98*scale - (i-1)*17*scale, math.pi, scale/41, scale/41, 256, 256) 367 | end 368 | 369 | --score 370 | love.graphics.draw(gamescoreimg, screenwidth/2-151*scale, screenheight/2-107*scale, 0, scale, scale) 371 | 372 | score = math.floor(gametime*10)/10 373 | if score == math.floor(score) then 374 | score = score .. ".0" 375 | end 376 | for i = 1, 5 do 377 | if string.len(tostring(score)) >= 6 - i then 378 | love.graphics.print(string.sub(tostring(score), i-(5-string.len(tostring(score))), i-(5-string.len(tostring(score)))), screenwidth/2-141*scale, screenheight/2-94*scale+9*i*scale, 0, scale) 379 | else 380 | love.graphics.print("0", screenwidth/2-141*scale, screenheight/2-94*scale+9*i*scale, 0, scale) 381 | end 382 | end 383 | 384 | --guideline for joystick 385 | if joystickcontrol and deathtimer == deathtime+deathdelay then 386 | x = love.joystick.getAxis( 0, 0 ) 387 | y = love.joystick.getAxis( 0, 1 ) 388 | love.graphics.line(screenwidth/2, screenheight/2, screenwidth/2+x*(screenheight/2), screenheight/2+y*(screenheight/2)) 389 | end 390 | 391 | --Rotate 392 | love.graphics.translate(screenwidth/2, screenheight/2) 393 | love.graphics.rotate(math.rad(rotation)) 394 | love.graphics.translate(-screenwidth/2, -screenheight/2) 395 | 396 | --Change focus on pacman if pacfocus == true, also scale. 397 | if pacfocus then 398 | love.graphics.scale(zoom) 399 | love.graphics.translate(-pacmanbody:getX()+screenwidth/2/zoom, -pacmanbody:getY()+screenheight/2/zoom) 400 | end 401 | 402 | --Background, Pacman, clone and background overlay. 403 | love.graphics.draw( mainfield, fieldbody:getX()+1, fieldbody:getY()+1, 0, scale, scale, boardwidth/2, boardheight/2) 404 | 405 | --pellets! 406 | love.graphics.setColor(255, 255, 0) 407 | for y = 1, 29 do 408 | for x = 1, 26 do 409 | 410 | if pelletmap[y][x] == 1 then 411 | love.graphics.rectangle( "fill", math.floor(screenwidth/2+((x-13.5)*8-0.4)*scale), math.floor(screenheight/2+((y-15)*7-0.4)*scale), 2*scale, 2*scale) 412 | elseif pelletmap[y][x] == 2 and superpelletblink == false then 413 | love.graphics.draw(superpellet, math.floor(screenwidth/2+((x-13.5)*8-2.5)*scale), math.floor(screenheight/2+((y-15)*7-2.5)*scale), 0, scale, scale) 414 | end 415 | 416 | end 417 | end 418 | 419 | love.graphics.setColor(255, 255, 255, 255) 420 | --pac: 421 | local x = (pacmanbody:getX()-screenwidth/2)*(scale/2)+screenwidth/2 422 | local y = (pacmanbody:getY()-screenheight/2)*(scale/2)+screenheight/2 423 | coords = {} 424 | table.insert(coords, x) --add center 425 | table.insert(coords, y) 426 | 427 | for ang = 360*(pacmouthopenness/2), 360 - 360*(pacmouthopenness/2) do 428 | table.insert(coords, math.sin(math.rad(ang-90) + pacmanbody:getAngle())*6.5*scale+x) 429 | table.insert(coords, -math.cos(math.rad(ang-90) + pacmanbody:getAngle())*6.5*scale+y) 430 | end 431 | 432 | if #coords > 6 then 433 | love.graphics.setColor(255, 255, 50) 434 | love.graphics.polygon("fill", unpack(coords)) 435 | love.graphics.setColor(255, 255, 255) 436 | end 437 | 438 | 439 | --ghosties: 440 | if deathtimer == deathtime+deathdelay then 441 | for i = 1, 3 do 442 | if ghosttimer[i] == 0 then 443 | if powerup then 444 | --powerup blink 445 | local timeleft = powerupduration - (love.timer.getTime() - poweruptimer) 446 | 447 | if timeleft < blinktime and math.mod((timeleft), blinkrate*2) rotation + 180 then 570 | rotation = rotation + 360 571 | elseif targetrotation < rotation - 180 then 572 | rotation = rotation - 360 573 | end 574 | 575 | if targetrotation > rotation then 576 | rotation = rotation + (targetrotation-rotation)*dt*20 577 | else 578 | rotation = rotation + (targetrotation-rotation)*dt*20 579 | end 580 | 581 | gravityX = math.sin(math.rad(rotation)) 582 | gravityY = math.cos(math.rad(rotation)) 583 | world:setGravity( gravityX*gravitymul*2, gravityY*gravitymul*2 ) 584 | end 585 | 586 | function normal_pacmangetposition(worldx, worldy) --returns position of world coordinates converted to the pelletgrid 587 | local scale = 2 588 | worldx = worldx - (screenwidth/2 - boardwidth*scale/2) - 3*scale 589 | worldy = worldy - (screenheight/2 - boardheight*scale/2) - 3*scale 590 | x = math.floor((worldx-4*scale)/(8*scale)+1) 591 | y = math.floor((worldy-3.5*scale)/(7*scale)+1) 592 | return x, y 593 | end 594 | 595 | function normal_checkpellet(x, y) --checks a coordinate if it contains a pellet and does stuff 596 | if pelletmap[y] then 597 | if pelletmap[y][x] == 1 then 598 | pelletmap[y][x] = 0 599 | if currenttime - wakkatimer > 0.09 then --0.11 600 | if soundenabled then 601 | if waorka == 1 then 602 | love.audio.stop(wakka2) 603 | love.audio.play(wakka2) 604 | waorka = 0 605 | else 606 | love.audio.stop(wakka1) 607 | love.audio.play(wakka1) 608 | waorka = 1 609 | end 610 | end 611 | wakkatimer = currenttime 612 | end 613 | 614 | score = score + 10 615 | 616 | eatored = eatored + 1 617 | if eatored == 244 then 618 | normal_gamefinished() 619 | end 620 | 621 | elseif pelletmap[y][x] == 2 then 622 | pelletmap[y][x] = 0 623 | currenttime = love.timer.getTime() 624 | if currenttime - wakkatimer > 0.11 then 625 | if soundenabled then 626 | if waorka then 627 | love.audio.stop(wakka2) 628 | love.audio.play(wakka2) 629 | waorka = 0 630 | else 631 | love.audio.stop(wakka1) 632 | love.audio.play(wakka1) 633 | waorka = 1 634 | end 635 | end 636 | wakkatimer = currenttime 637 | end 638 | 639 | --SUPER POWERS OMG 640 | poweruptimer = currenttime 641 | powerup = true 642 | 643 | score = score + 50 644 | 645 | eatored = eatored + 1 646 | if eatored == 244 then 647 | normal_gamefinished() 648 | end 649 | end 650 | end 651 | end 652 | 653 | function normal_keypressed(key) 654 | 655 | if key == "escape" then 656 | menu_load() 657 | end 658 | 659 | end 660 | 661 | function normal_mousepressed(x, y, button) 662 | 663 | end 664 | 665 | function normal_gamefinished() 666 | normal_stopgamesounds() 667 | love.mouse.setGrab(false) 668 | love.mouse.setVisible(true) 669 | if eatored == 244 then 670 | gamewin:play() 671 | end 672 | local high = 0 673 | for i = 1, 9 do 674 | if eatored > highscoreA[i][1] then 675 | high = i 676 | break 677 | elseif eatored == highscoreA[i][1] then 678 | if gametime < highscoreA[i][2] then 679 | high = i 680 | break 681 | end 682 | end 683 | end 684 | 685 | gametime = math.floor(gametime*10+0.5)/10 686 | 687 | if high ~= 0 then 688 | for i = numhighscores, high+1, -1 do 689 | highscoreA[i] = {highscoreA[i-1][1], highscoreA[i-1][2], highscoreA[i-1][3]} 690 | end 691 | highscoreA[high] = {eatored, gametime, ""} 692 | highscoreentry_load(high) 693 | else 694 | highscoreentry_load(0) 695 | end 696 | end --------------------------------------------------------------------------------