commit 685a0ef9f6d3408ab6e97867991bbd5a50af55bb Author: madiwka3 Date: Sun Jun 21 21:26:53 2020 +0600 First commit diff --git a/Madi.png b/Madi.png new file mode 100644 index 0000000..c9e9bbd Binary files /dev/null and b/Madi.png differ diff --git a/TSerial.lua b/TSerial.lua new file mode 100644 index 0000000..4ca5da4 --- /dev/null +++ b/TSerial.lua @@ -0,0 +1,46 @@ +--- TSerial v1.3, a simple table serializer which turns tables into Lua script +-- @author Taehl (SelfMadeSpirit@gmail.com) +TSerial = {} + +--- Serializes a table into a string, in form of Lua script. +-- @param t table to be serialized (may not contain any circular reference) +-- @param drop if true, unserializable types will be silently dropped instead of raising errors +-- if drop is a function, it will be called to serialize unsupported types +-- @param indent if true, output "human readable" mode with newlines and indentation (for debug) +-- @return string recreating given table +function TSerial.pack(t, drop, indent) + assert(type(t) == "table", "Can only TSerial.pack tables.") + local s, indent = "{"..(indent and "\n" or ""), indent and math.max(type(indent)=="number" and indent or 0,0) + for k, v in pairs(t) do + local tk, tv, skip = type(k), type(v) + if tk == "boolean" then k = k and "[true]" or "[false]" + elseif tk == "string" then if string.format("%q",k) ~= '"'..k..'"' then k = '['..string.format("%q",k)..']' end + elseif tk == "number" then k = "["..k.."]" + elseif tk == "table" then k = "["..TSerial.pack(k, drop, indent and indent+1).."]" + elseif type(drop) == "function" then k = "["..string.format("%q",drop(k)).."]" + elseif drop then skip = true + else error("Attempted to TSerial.pack a table with an invalid key: "..tostring(k)) + end + if tv == "boolean" then v = v and "true" or "false" + elseif tv == "string" then v = string.format("%q", v) + elseif tv == "number" then -- no change needed + elseif tv == "table" then v = TSerial.pack(v, drop, indent and indent+1) + elseif type(drop) == "function" then v = "["..string.format("%q",drop(v)).."]" + elseif drop then skip = true + else error("Attempted to TSerial.pack a table with an invalid value: "..tostring(v)) + end + if not skip then s = s..string.rep("\t",indent or 0)..k.."="..v..","..(indent and "\n" or "") end + end + return s..string.rep("\t",(indent or 1)-1).."}" +end + +--- Loads a table into memory from a string (like those output by Tserial.pack) +-- @param s a string of Lua defining a table, such as "{2,4,8,ex="ample"}" +-- @return a table recreated from the given string +function TSerial.unpack(s) + assert(type(s) == "string", "Can only TSerial.unpack strings.") + assert(loadstring("TSerial.table="..s))() + local t = TSerial.table + TSerial.table = nil + return t +end \ No newline at end of file diff --git a/audio/bomb.wav b/audio/bomb.wav new file mode 100644 index 0000000..9cf577b Binary files /dev/null and b/audio/bomb.wav differ diff --git a/audio/hi2.wav b/audio/hi2.wav new file mode 100644 index 0000000..ab3e094 Binary files /dev/null and b/audio/hi2.wav differ diff --git a/audio/hit1.mp3 b/audio/hit1.mp3 new file mode 100644 index 0000000..7adbd2b Binary files /dev/null and b/audio/hit1.mp3 differ diff --git a/audio/hit2.wav b/audio/hit2.wav new file mode 100644 index 0000000..d3b0569 Binary files /dev/null and b/audio/hit2.wav differ diff --git a/audio/score.wav b/audio/score.wav new file mode 100644 index 0000000..71083c2 Binary files /dev/null and b/audio/score.wav differ diff --git a/audio/superhit.aiff b/audio/superhit.aiff new file mode 100644 index 0000000..b2c938e Binary files /dev/null and b/audio/superhit.aiff differ diff --git a/audio/superhit.wav b/audio/superhit.wav new file mode 100644 index 0000000..983636d Binary files /dev/null and b/audio/superhit.wav differ diff --git a/audio/theme1.mp3 b/audio/theme1.mp3 new file mode 100644 index 0000000..6337232 Binary files /dev/null and b/audio/theme1.mp3 differ diff --git a/audio/theme2.mp3 b/audio/theme2.mp3 new file mode 100644 index 0000000..8b579c8 Binary files /dev/null and b/audio/theme2.mp3 differ diff --git a/audio/theme3.mp3 b/audio/theme3.mp3 new file mode 100644 index 0000000..fac94d8 Binary files /dev/null and b/audio/theme3.mp3 differ diff --git a/audio/theme4.mp3 b/audio/theme4.mp3 new file mode 100644 index 0000000..ad3b425 Binary files /dev/null and b/audio/theme4.mp3 differ diff --git a/audio/time.wav b/audio/time.wav new file mode 100644 index 0000000..b88932c Binary files /dev/null and b/audio/time.wav differ diff --git a/buttonManager.lua b/buttonManager.lua new file mode 100644 index 0000000..3c6e00f --- /dev/null +++ b/buttonManager.lua @@ -0,0 +1,47 @@ +mainMenu = Class{} +function resolutionButtons(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, buttons) + + if (gameState == 'windowsettings') then + + local ev_button_width = VIRTUAL_WIDTH * (1/3) + local ev_BUTTON_HEIGHT = 50 + local margin = 16 + local hot = false + local cursor_y = 0 + local total_height = (ev_BUTTON_HEIGHT + margin) * #settings + for i, button in ipairs(buttons) do + button.last = button.now + local ev_bx = (VIRTUAL_WIDTH*0.8) - (ev_button_width * 0.5) + local ev_by = (VIRTUAL_HEIGHT * 0.5) - (total_height * 0.5) + cursor_y + local color = {255, 255, 255, 255} + local mx, my = love.mouse.getPosition() + local mx = mx * DIFFERENCE_X + local my = my * DIFFERENCE_Y + local hot = (mx > ev_bx and mx < ev_bx + ev_button_width and my > ev_by and my < ev_by + ev_BUTTON_HEIGHT) and i + if (hot == i) then + color = {10, 10, 0, 255} + end + button.now = love.mouse.isDown(1) + if button.now and not button.last and hot == i then + love.graphics.setColor(0,0,0,1) + love.graphics.rectangle("fill", 0, 0, VIRTUAL_WIDTH, VIRTUAL_HEIGHT) + -- sounds['wallhit']:play() + button.fn() + end + love.graphics.setColor(unpack(color)) + love.graphics.rectangle("fill", ev_bx,ev_by, ev_button_width, ev_BUTTON_HEIGHT) + love.graphics.setColor(0, 0, 0, 255) + local textW = smallfont:getWidth(button.text) + local textH = smallfont:getHeight(button.text) + love.graphics.print(button.text, smallfont, VIRTUAL_WIDTH*0.8 - textW*0.5, ev_by+textH*0.5) + + love.graphics.setColor(255, 255, 255, 255) + cursor_y = cursor_y + (ev_BUTTON_HEIGHT + margin) + + end + + + end + + + end diff --git a/class.lua b/class.lua new file mode 100644 index 0000000..484b776 --- /dev/null +++ b/class.lua @@ -0,0 +1,94 @@ +--[[ +Copyright (c) 2010-2013 Matthias Richter +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. +Except as contained in this notice, the name(s) of the above copyright holders +shall not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +]]-- + +local function include_helper(to, from, seen) + if from == nil then + return to + elseif type(from) ~= 'table' then + return from + elseif seen[from] then + return seen[from] + end + + seen[from] = to + for k,v in pairs(from) do + k = include_helper({}, k, seen) -- keys might also be tables + if to[k] == nil then + to[k] = include_helper({}, v, seen) + end + end + return to +end + +-- deeply copies `other' into `class'. keys in `other' that are already +-- defined in `class' are omitted +local function include(class, other) + return include_helper(class, other, {}) +end + +-- returns a deep copy of `other' +local function clone(other) + return setmetatable(include({}, other), getmetatable(other)) +end + +local function new(class) + -- mixins + class = class or {} -- class can be nil + local inc = class.__includes or {} + if getmetatable(inc) then inc = {inc} end + + for _, other in ipairs(inc) do + if type(other) == "string" then + other = _G[other] + end + include(class, other) + end + + -- class implementation + class.__index = class + class.init = class.init or class[1] or function() end + class.include = class.include or include + class.clone = class.clone or clone + + -- constructor call + return setmetatable(class, {__call = function(c, ...) + local o = setmetatable({}, c) + o:init(...) + return o + end}) +end + +-- interface for cross class-system compatibility (see https://github.com/bartbes/Class-Commons). +if class_commons ~= false and not common then + common = {} + function common.class(name, prototype, parent) + return new{__includes = {prototype, parent}} + end + function common.instance(class, ...) + return class(...) + end +end + + +-- the module +return setmetatable({new = new, include = include, clone = clone}, + {__call = function(_,...) return new(...) end}) \ No newline at end of file diff --git a/config.lua b/config.lua new file mode 100644 index 0000000..e69de29 diff --git a/eball.lua b/eball.lua new file mode 100644 index 0000000..f64aff1 --- /dev/null +++ b/eball.lua @@ -0,0 +1,96 @@ +eball = Class{} + +function eball:init(x, y, width, height) + + self.x = x + self.y = y + self.width = width + self.height = height + + self.dy = math.random(-1, 1) + self.dx = 1 +end + +function eball:collides(paddle) + if paddle.player == 2 and gameMode == 'practice' then return false + else + if self.x > paddle.x + paddle.width or paddle.x > self.x + self.width then + return false + end + + if self.y > paddle.y + paddle.height or paddle.y > self.y + self.height then + return false + end + return true +end +end +function eball:reset(ballnum) + if (gameMode == 'practice') then + if (self.x < 1) then + --love.window.setTitle(self.x) + self.x = VIRTUAL_WIDTH /2 - 2 + self.y = VIRTUAL_HEIGHT /2 - 2 + self.dy = math.random(-1, 1) + self.dx = math.random(-1,1) +else self.x = self.x self.y = self.y self.dx = -1 end +else + if (ballnum == 2) then + self.dx = ball_DIR * -1 + else + self.dx = ball_DIR + end +self.x = VIRTUAL_WIDTH /2 - 2 + self.y = VIRTUAL_HEIGHT /2 - 2 + self.dy = math.random(-1, 1) + + --love.window.setTitle("LMAOOOOOO") +end +end + + +function eball:update(dt) + if player1nukescore > 20 then + potentialstrike1 = 1 + else + potentialstrike1 = 0 + end + if player1nukescore > 140 then + player1reverbav = 1 + else + player1reverbav = 0 + end + if player1nukescore > 200 then + potentialnuke1 = 1 + else + potentialnuke1 = 0 + end + if player2nukescore > 20 then + potentialstrike2 = 1 + else + potentialstrike2 = 0 + end + if player2nukescore > 140 then + player2reverbav = 1 + else + player2reverbav = 0 + end + if player2nukescore > 200 then + potentialnuke2 = 1 + else + potentialnuke2 = 0 + end + self.x = self.x + ballSpeed * self.dx * dt + self.y = self.y + ballSpeed * self.dy * dt +end + +function eball:render(color) + if color == 'black' then + love.graphics.setColor(0,0,0,1) + love.graphics.rectangle('fill', self.x, self.y, self.width, self.height) + elseif color == 'controlled' then + love.graphics.rectangle('fill', self.x, self.y, self.width, self.height) + else + love.graphics.setColor(1,1,1,1) + love.graphics.rectangle('fill', self.x, self.y, self.width, self.height) + end +end \ No newline at end of file diff --git a/font.ttf b/font.ttf new file mode 100644 index 0000000..fe4328b Binary files /dev/null and b/font.ttf differ diff --git a/fullScreener.lua b/fullScreener.lua new file mode 100644 index 0000000..156a7e7 --- /dev/null +++ b/fullScreener.lua @@ -0,0 +1,33 @@ +fullScreener = Class{} +function fullScreener:init(a,b,c,d) + self.a = a + self.b = b + self.c = c + self.d = d +end +function fullScreener:toggle(vh, vw) + self.a = self.a + 1 + if (self.a > 1) then + self.a = 0 + end + if (self.a == 0 ) then + if (self.b == 1) then + self.c = 1 + self.d = 1 + simpleScale.updateWindow(WINDOW_WIDTH, WINDOW_HEIGHT,{fullscreen = false}) + self.b = 0 + end + + end + if (self.a == 1) then + if (self.b == 0) then + simpleScale.updateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, {fullscreen = true}) + local newWidth = love.graphics.getWidth() + local newHeight = love.graphics.getHeight() + self.c = VIRTUAL_WIDTH / newWidth + self.d = VIRTUAL_HEIGHT / newHeight + self.b = 1 + + end +end +end diff --git a/main.lua b/main.lua new file mode 100644 index 0000000..2282314 --- /dev/null +++ b/main.lua @@ -0,0 +1,1904 @@ + +Class = require 'class' +require 'paddle' +require 'simpleScale' +require 'TSerial' +require 'eball' +require 'fullScreener' +require 'mainMenu' +require 'music' +local serialize = require 'ser' +local shader_code = [[ +vec4 effect(vec4 color, Image image, vec2 uvs, vec2 screen_coords) { + vec4 pixel = Texel(image,uvs); + return pixel * color; +} +]] +timeIsSlow = false +timeIsSlow2 = false +originalSpeed = 200 +explosionRange = 0 +blockinput = false +wall1width = 30 +nuclearanimation = 3 +easternum = 0 +ball_DIR = 0 +RED = 255 +hitNum = {} +hitNum[1] = 0 +hitNum[2] = 0 +hitNum[3] = 0 +hitNum[4] = 0 +p1bonus = 0 +p2bonus = 0 +hitNum[5] = 0 +hitNum[6] = 0 +GREEN = 255 +BLUE = 255 +updateTEXT = 'Chalkboard Update' +maxBalls = 1 +playerCount = 1 +WINDOW_WIDTH = 1280 +WINDOW_HEIGHT = 720 +player1reverbav = 0 +playertext = '1v1' +player2reverbav = 0 +elapsed = 0 +rotation = 0 +TEXT = 'Nuclear Pong' +VIRTUAL_WIDTH = 1280 +VIRTUAL_HEIGHT = 720 +currentKey = " " +ptw = 10 +danger = 'none' +danger2 = 'none' +nuckemodactive = 0 +maxspeed = 700 +DIFFERENCE_X = 1 +DIFFERENCE_Y = 1 +paddle_SPEED = 20 +textamount = 15 +AI_STRIKEMOD = 1000 +resolutionWin = 0 +AGAINST_AI = 0 +RESOLUTION_SET = 0 +AI_NUKEMOD = 1000 +animstart = true +AI_SPEED = 30 +craz = 0 +AI_LEVEL = 500 +isFullscreen = 0 +prtext = 'Easy' +MAP_TYPE = 2 +difficultyl = 300 +req = 'pp' +ballSet = 200 +p1control = {up = 'a', down = 'z', super = 's', counter = 'x'} +p2control = {up = ';', down = '.', super = 'l', counter = ','} +synctext = "Independent" +synctype = 0 +function newButton(text, fn) + return { + text = text, + fn = fn, + now = false, + last = false + } +end +function love.keyboard.mouseWasReleased() + return love.keyboard.mouseisReleased +end +function autoSave(dt) + autoTimer = autoTimer + dt +end + +function balancer() + if (player2score == 9 or player1score == 9) then + shakeDuration = 10 + -- love.window.setTitle("ALMOST WIN") + end + if (player1score < player2score) then + p1bonus = (player2score - player1score) * 5 + else + p1bonus = 0 + end + if (player2score < player1score) then + p2bonus = (player1score - player2score) * 5 + else + p2bonus = 0 + end + + + end +function newWall(wallx, wally, wallwidth, wallheight) + return { + wallx = wallx, + wally = wally, + walwidth = wallwidth, + wallheight = wallheight + } +end +speedParameters = {} +buttons = {} +difbuttons = {} +settings = {} +walls = {} +editorpicks = {} +controlSettings = {} +modeSelectorButtons= {} +pracdiff = {} +playerCountButtons = {} +function controlChanger() + if (gameState == 'assign') then + love.graphics.clear(50/255,50/255,50/255,255) + love.graphics.printf('SELECT BUTTON',0,VIRTUAL_HEIGHT / 2,VIRTUAL_WIDTH,'center') + end +end +function love.load() + simpleScale.setWindow(VIRTUAL_WIDTH, VIRTUAL_HEIGHT, WINDOW_WIDTH, WINDOW_HEIGHT) + configfile = io.open('config.lua', "r") + configsave = io.open('config.lua', "w") + shader = love.graphics.newShader(shader_code) + time_1 = 0 + +--load + +testwalls = love.filesystem.load('save.lua')() +if testwalls ~= nil then + walls = love.filesystem.load('save.lua')() +end + + + + light = 0 + image = love.graphics.newImage("Madi.png") + table.insert(editorpicks, newButton("C", function() for k in pairs (walls) do walls[k] = nil end end)) + table.insert(editorpicks, newButton("S", function() love.filesystem.write('save.lua', serialize(walls)) end)) + table.insert(editorpicks, newButton("L", function() walls = love.filesystem.load('save.lua')() end)) + table.insert(buttons, newButton("Singleplayer", function() gameState = 'gameMode' end)) + table.insert(buttons, newButton("Multiplayer", function() gameState = 'multiMode' end)) + table.insert(buttons, newButton("Settings", function() AGAINST_AI = 0 gameState = 'windowsettings' end)) + table.insert(buttons, newButton("Exit", function() love.event.quit(0) end)) + table.insert(difbuttons, newButton("Easy", function() hardmanager('easy') end)) + table.insert(difbuttons, newButton("Normal", function() hardmanager('normal') end)) + table.insert(difbuttons, newButton("Hard", function() hardmanager('hard') end)) + table.insert(settings, newButton("Change Map", function() MAP_TYPE = MAP_TYPE + 1 end)) + table.insert(settings, newButton("Toggle Fullscreen", function() myscreen:toggle(VIRTUAL_HEIGHT, VIRTUAL_WIDTH) DIFFERENCE_X = myscreen.c DIFFERENCE_Y = myscreen.d end)) + table.insert(settings, newButton("Editor", function() gameState = 'editor' end)) + table.insert(settings, newButton("Speed Settings", function() gameState = 'speedSettings' end)) + table.insert(settings, newButton("Control Settings", function() gameState = 'controlSettings' end)) + table.insert(settings, newButton("Back to Menu", function() gameState = 'menu' end)) + table.insert(speedParameters, newButton("Back to Menu", function() gameState = 'windowsettings' end)) + --table.insert(speedParameters, newButton("Ball Speed: ", function() speedSetter('ball') end)) + table.insert(playerCountButtons, newButton("Ball Speed: ", function() speedSetter('ball') end)) + --table.insert(speedParameters, newButton("snc", function() speedSetter('snc') end)) + table.insert(playerCountButtons, newButton("snc", function() speedSetter('snc') end)) + table.insert(speedParameters, newButton("NUCLEAR MODE", function() speedSetter('nuclearmod') end)) + table.insert(controlSettings, newButton("1up", function() gameState = 'assign' req = 'p1up' end)) + table.insert(controlSettings, newButton("1down", function() gameState = 'assign' req = 'p1down' end)) + table.insert(controlSettings, newButton("1special",function() gameState = 'assign' req = 'p1super' end)) + table.insert(controlSettings, newButton("1ct", function() gameState = 'assign' req = 'p1ct' end)) + table.insert(controlSettings, newButton("2up", function() gameState = 'assign' req = 'p2up' end)) + table.insert(controlSettings, newButton("2down", function() gameState = 'assign' req = 'p2down' end)) + table.insert(controlSettings, newButton("2special", function() gameState = 'assign' req = 'p2super' end)) + table.insert(controlSettings, newButton("2ct", function() gameState = 'assign' req = 'p2ct' end)) + table.insert(controlSettings, newButton("Default", function() p1control = {up = 'a', down = 'z', super = 's', counter = 'x'} p2control = {up = ';', down = '.', super = 'l', counter = ','} end)) + table.insert(controlSettings, newButton("Return", function() gameState = 'windowsettings' end)) + table.insert(modeSelectorButtons, newButton("Nuclear Pong", function() gameState = 'difficulty' end)) + table.insert(modeSelectorButtons, newButton("Nuclear Practice", function() gameState = 'prdiff' end)) + table.insert(modeSelectorButtons, newButton("Main Menu", function() gameState = 'menu' end)) + table.insert(pracdiff, newButton("Silverblade", function() speedSetter('practice') end)) + table.insert(pracdiff, newButton("Return", function() speedSetter('reset') gameState = 'gameMode' end)) + table.insert(pracdiff, newButton("Go!", function() gameMode = 'practice' hardmanager('practice') end)) + --table.insert(playerCountButtons, newButton("1v1", function() speedSetter('pc') end)) + table.insert(playerCountButtons, newButton("ballCount", function() speedSetter('ballz') end)) + table.insert(playerCountButtons, newButton("Return", function() speedSetter('reset') gameState = 'menu' end)) + table.insert(playerCountButtons, newButton("ptw", function() speedSetter('ptw') end)) + table.insert(playerCountButtons, newButton("Play", function() AGAINST_AI = 0 gameState = '1serve' end)) + + + + --table.insert(speedParameters, newButton("Ball Speed: ", function() speedSetter() end)) + + + love.window.setTitle('NUCLEAR PONG') + textphrases = { + "Amazing", "Superb", "Absolutely beautiful!", "Awesome", "Look at That!", "Great", "Nice", "Boom!", "Dangerous!", "Astonishing!", "u/ebernerd saved me", "Absolutely Wonderful!", "Exsquisite", "Delicate", "Pow!", "Great Hit", "all hail nazarbayev" + } + sounds = { + ['updateMusic'] = love.audio.newSource("audio/theme1.mp3", "static"), + ['gayTheme'] = love.audio.newSource("audio/theme2.mp3", "static"), + ['gayTheme2'] = love.audio.newSource("audio/theme3.mp3", "static"), + ['gayTheme3'] = love.audio.newSource("audio/theme4.mp3", "static"), + ['beep'] = love.audio.newSource("audio/hit1.mp3", "static"), + ['wallhit'] = love.audio.newSource("audio/hit2.wav", "static"), + ['win'] = love.audio.newSource("win.wav", "static"), + ['score'] = love.audio.newSource("audio/score.wav", "static"), + ['nuke'] = love.audio.newSource("audio/bomb.wav", "static"), + ['striking'] = love.audio.newSource("audio/superhit.wav", "static"), + ['nuclearhit'] = love.audio.newSource("audio/hit1.mp3", "static"), + ['time'] = love.audio.newSource("audio/time.wav", "static") + } + love.graphics.setDefaultFilter('nearest', 'nearest') + --comic sans lmao + math.randomseed(os.time()) + smallfont = love.graphics.newFont('font.ttf', 30) + scorefont = love.graphics.newFont('font.ttf', 90) + love.graphics.setFont(smallfont) + + --push:setupScreen(VIRTUAL_WIDTH, VIRTUAL_HEIGHT, WINDOW_WIDTH, WINDOW_HEIGHT, { + -- fullscreen = isFullscreen, + -- resizable = true, + -- vsync = true, + --}) +player1score = 0 +player2score = 0 +areanuclear = 0 +player1nukescore = 0 +player2nukescore = 0 +striken = 0 +soundtype = 1 +soundturn = 1 +potentialstrike1 = 0 +potentialstrike2 = 0 +potentialnuke1 = 0 +potentialnuke2 = 0 +player1striken = 0 +player2striken = 0 +randomtext = 0 +selecting = 0 +number = 0 +elec = 1 +INDIC = { + '', '', '', '' +} +--playe1nuke +player1 = paddle(0,30,10,100, 1) +player2 = paddle(VIRTUAL_WIDTH * 0.99, VIRTUAL_HEIGHT * 0.88, 10, 100, 2) +player3 = paddle(5000, 5000, 10, 100) +player4 = paddle(5000, 5000, 10, 100) +ball = {} +ball[1] = eball(VIRTUAL_WIDTH / 2 , VIRTUAL_HEIGHT / 2 - 2, 16, 16) +ball[2] = eball(VIRTUAL_WIDTH / 1.9 , VIRTUAL_HEIGHT / 2 - 2, 16, 16) +ball[3] = eball(VIRTUAL_WIDTH / 1.8, VIRTUAL_HEIGHT / 2 - 2, 16, 16) +ball[4] = eball(VIRTUAL_WIDTH / 2.2, VIRTUAL_HEIGHT / 2 - 2, 16, 16) +ball[5] = eball(VIRTUAL_WIDTH / 2.1, VIRTUAL_HEIGHT / 2 - 2, 16, 16) +myscreen = fullScreener(RESOLUTION_SET, isFullscreen, DIFFERENCE_X, DIFFERENCE_Y) +mymenu = mainMenu() + +ballSpeed = 200 + + +ballDX = math.random(2) == 1 and 100 or -100 +ballDY = math.random(-50, 50) + +gameState = 'animation' +end +t = 0 +shakeDuration = 0 +shakeMagnitude = 1 +function startShake(duration, magnitude) + t, shakeDuration, shakeMagnitude = 0, duration or 1, magnitude or 5 +end +function displayFPS() +--love.window.setTitle(maxBalls) +end + +function speedControl() + if (ballSpeed > maxspeed and gameState == 'play') then + ballSpeed = maxspeed + end +end + +function love.update(dt) + displayFPS() + if areanuclear == 1 then + if nuclearanimation > 0 then + gameState = 'nuclearExplosion' + nuclearanimation = nuclearanimation - dt + explosionRange = explosionRange + dt*24 + elseif (gameState ~= 'play') then + gameState = 'play' + explosionRange = 0 + end + end + if player1nukescore > 300 then + player1nukescore = 300 end + if player2nukescore > 300 then + player2nukescore = 300 end + speedControl() + balancer() + dangerChecker() + musicController('norm', 1) + palleteController() + if (gameState == 'animation') then + animator(dt) + end + if t < shakeDuration then + t = t + dt + end + elapsed = elapsed + dt + rotation = math.sin(elapsed * 2.5) * 0.7 + -- if (gameState == 'quickanim') then + -- time_1 = time_1 + dt + -- light = 255 - time_1 * 150 + -- if (light < 0) then + -- time_1 = 0 + -- light = 0 + -- gameState = 'play' + --end + -- end + for i=1, maxBalls do + if (AGAINST_AI == 1 or gameState == 'start') then + for i = 1, maxBalls do + if (ball[i].y - player2.y >= 50 and player2.x - ball[i].x < AI_LEVEL) then + player2.dy = AI_SPEED + elseif (player2.y - ball[i].y >= -20 and player2.x - ball[i].x < AI_LEVEL) then + player2.dy = -AI_SPEED + else + player2.dy = 0 + end + if difficultyl == 350 and player2reverbav == true and VIRTUAL_WIDTH - ball[i].x < 90 and math.abs(ball[i].y - player2.y) > 150 then + sounds["time"]:play() player2reverbav = false timeIsSlow2 = true originalPaddle = paddle_SPEED originalSpeed = ballSpeed player2reverbav = 0 potentialnuke2 = 0 potentialstrike2 = 0 + end + + if (player2nukescore > AI_STRIKEMOD and striken == 0) + then + player2striken = 1 + elseif (player2nukescore > AI_NUKEMOD and striken == 1) + then + if (areanuclear == 1) then maxspeed = maxspeed + 50 end + sounds['nuke']:play() + potentialstrike2 = 0 + areanuclear = 1 + ballSpeed = ballSpeed * 2 + if (synctype == 0) + then + paddle_SPEED = paddle_SPEED * 2 end + if (synctype == 1) + then + paddle_SPEED = ballSpeed/10 + + end + if (synctype == 0) + then + AI_SPEED = AI_SPEED * 2.2 end + if (synctype == 1) + then + AI_SPEED = ballSpeed * 1.1 /10 + end + player2nukescore = 0 + player2reverbav = 0 + potentialnuke2 = 0 + end + end + + + + end + if (ball[i].x < 0 - ballSpeed*0.5) then + if (gameMode ~= 'practice') then + sounds['score']:play() + end + if (nuckemodactive == 0) then + areanuclear = 0 + nuclearanimation = 3 +end + striken = 0 + player1striken = 0 + player2striken = 0 + + ballSpeed = ballSet + if (synctype == 0) + then + paddle_SPEED = ballSet/10 end + if (synctype == 1) + then + paddle_SPEED = ballSpeed/10 + end + + AI_SPEED = difficultyl/10 + player2score = player2score + 1 + if (player2score ==ptw and gameMode ~= 'practice') then + for i = 1, maxBalls do + ball[i]:reset(i) + end + sounds['win']:play() + gameState = 'done' + TEXT = 'Player 2 Won!' + else + gameState = '1serve' + serveBot() + for i = 1, maxBalls do + ball[i]:reset(i) + end + end + end + if (ball[i].x > VIRTUAL_WIDTH + ballSpeed*0.5) then + + sounds['score']:play() + if (nuckemodactive == 0) then + areanuclear = 0 + nuclearanimation = 3 +end + striken = 0 + player1striken = 0 + player2striken = 0 + ballSpeed = ballSet + + if (synctype == 0) + then + paddle_SPEED = ballSet/10 + AI_SPEED = ballSet/10 end + if (synctype == 1) + then + paddle_SPEED = ballSpeed/10 + AI_SPEED = ballSpeed/10 + end + + AI_SPEED = difficultyl/10 + player1score = player1score + 1 + if (player1score == ptw) then + + ball[i]:reset(i) + + sounds['win']:play() + gameState = 'done' + TEXT = 'Player 1 Won!' + else + + gameState = '2serve' + + serveBot() + + ball[i]:reset(i) + +end + end + end + + if (player1nukescore >= 20 and player1nukescore < 140) then + potentialstrike1 = 1 + if (love.keyboard.isDown(p1control.super)) then + player1striken = 1 + player1reverbav = 0 + --player1nukescore = 0 + end + end + if (player1nukescore >= 140) and timeIsSlow2 == false and timeIsSlow == false and maxBalls == 1 and ball[1].x < VIRTUAL_WIDTH/2 then player1reverbav = 1 if love.keyboard.isDown(p1control.counter) then powerControl(1, 'special') end end + if (player1nukescore >= 200) then + --sounds['nukeready']:play() + potentialnuke1 = 1 + if (love.keyboard.isDown(p1control.super)) then + sounds['nuke']:play() + if areanuclear == 1 then maxspeed = maxspeed + 50 end + areanuclear = 1 + potentialstrike1 = 0 + striken = 0 + ballSpeed = ballSpeed * 2 + if (synctype == 0) + then + paddle_SPEED = paddle_SPEED * 2 end + if (synctype == 1) + then + paddle_SPEED = ballSpeed/10 + end + if (synctype == 0) + then + AI_SPEED = AI_SPEED * 2.2 end + if (synctype == 1) + then + AI_SPEED = ballSpeed * 1.1 /10 + end + player1nukescore = 0 + player1reverbav = 0 + potentialnuke1 = 0 + end + end + + if (player2nukescore >= 20 and player2nukescore <= 140) then + potentialstrike2 = 1 + if (AGAINST_AI == 0) then + if (love.keyboard.isDown(p2control.super)) then + player2striken = 1 + player2reverbav = 0 + + end + end + end + if (player2nukescore >= 140) and timeIsSlow == false and timeIsSlow2 == false and maxBalls == 1 and ball[1].x > VIRTUAL_WIDTH/2 then player2reverbav = 1 + if love.keyboard.isDown(p2control.counter) then sounds["time"]:play() player2reverbav = false timeIsSlow2 = true originalPaddle = paddle_SPEED originalSpeed = ballSpeed player2reverbav = 0 potentialnuke2 = 0 potentialstrike2 = 0 end end + if (player2nukescore >= 200) then + -- sounds['nukeready']:play() + potentialnuke2 = 1 + if (love.keyboard.isDown(p2control.super) and AGAINST_AI == 0) then + sounds['nuke']:play() + if areanuclear == 1 then maxspeed = maxspeed + 50 end + potentialstrike2 = 0 + areanuclear = 1 + player2reverbav = 0 + --player2nukescore = 0 + ballSpeed = ballSpeed * 2 + if (synctype == 0) + then + paddle_SPEED = paddle_SPEED * 2 end + if (synctype == 1) + then + paddle_SPEED = ballSpeed/10 + end + if (synctype == 0) + then + AI_SPEED = AI_SPEED * 2.2 end + if (synctype == 1) + then + AI_SPEED = ballSpeed * 1.1 / 10 + end + player2nukescore = 0 + potentialnuke2 = 0 + end + end + + + if (love.keyboard.isDown(p1control.up)) + then + player1.dy = (paddle_SPEED + p1bonus) * -1 + elseif (love.keyboard.isDown(p1control.down)) + then + player1.dy = paddle_SPEED + p1bonus + + else + player1.dy = 0 + end + if (AGAINST_AI == 0) then + if (love.keyboard.isDown(p2control.up)) + then + player2.dy = (paddle_SPEED + p2bonus) * -1 + elseif (love.keyboard.isDown(p2control.down)) + then + player2.dy = paddle_SPEED + p2bonus + else + player2.dy = 0 + end + end + if gameState == 'play' then + --love.window.setTitle('VOID') + for i = 1, maxBalls do + if ball[i]:collides(player1) then + --gameState = 'quickanim' + if gameMode == 'practice' then + player1score = player1score + 1 + end + t = 0 + if (ballSpeed > 200) then + shakeMagnitude = ballSpeed/200 + else shakeMagnitude = 0 end + shakeDuration = 1 + randomtext = love.math.random(1, #textphrases) + TEXT = textphrases[randomtext] + soundtype = love.math.random(1, 1.2) + + + + if (player1striken == 1) then + TEXT = 'PLAYER 1 STRIKES' + ballSpeed = ballSpeed + player1nukescore + potentialnuke1 = 0 + player1striken = 0 + player1nukescore = 0 + potentialstrike1 = 0 + striken = 1 + if areanuclear == 0 then + sounds['striking']:setPitch(ballSpeed/250) + sounds['striking']:play() + else + sounds['nuclearhit']:setPitch(1) + sounds['nuclearhit']:play() + end + else + if areanuclear == 0 then + sounds['beep']:setPitch(ballSpeed/250) + sounds['beep']:play() + else + sounds['nuclearhit']:setPitch(1) + sounds['nuclearhit']:play() + end + end + if (striken == 1) then + player1nukescore = player1nukescore * 1.2 + if (synctype == 0) + then + paddle_SPEED = paddle_SPEED * 1.10 + elseif (synctype == 1) + then + paddle_SPEED = ballSpeed / 10 + end + if (synctype == 0) + then + AI_SPEED = AI_SPEED * 1.10 end + if (synctype == 1) + then + AI_SPEED = ballSpeed * 1.1/10 + end + ballSpeed = ballSpeed * 1.10 + end + player1nukescore = player1nukescore + 10 + ball[i].dx = -ball[i].dx + ball[i].x = player1.x + 30 + + if (love.keyboard.isDown(p1control.up)) then + select = math.random(1,5) + if select == 1 then + ball[i].dy = -1 + elseif select == 2 then + ball[i].dy = -1.2 + elseif select == 3 then + ball[i].dy = -1.5 + elseif select == 4 then + ball[i].dy = -1.8 + elseif select == 5 then + ball[i].dy = -2 + end + elseif love.keyboard.isDown(p1control.down) then + select = math.random(1,5) + if select == 1 then + ball[i].dy = 1 + elseif select == 2 then + ball[i].dy = 1.2 + elseif select == 3 then + ball[i].dy = 1.5 + elseif select == 4 then + ball[i].dy = 1.8 + elseif select == 5 then + ball[i].dy = 2 + end + else + if ball[i].dy < 0 then + + select = math.random(1,5) + if select == 1 then + ball[i].dy = -1 + elseif select == 2 then + ball[i].dy = -1.2 + elseif select == 3 then + ball[i].dy = -1.5 + elseif select == 4 then + ball[i].dy = -1.8 + elseif select == 5 then + ball[i].dy = -2 + end + else + select = math.random(1,5) + if select == 1 then + ball[i].dy = 1 + elseif select == 2 then + ball[i].dy = 1.2 + elseif select == 3 then + ball[i].dy = 1.5 + elseif select == 4 then + ball[i].dy = 1.8 + elseif select == 5 then + ball[i].dy = 2 + end + end + end + end + if ball[i]:collides(player3) then + --gameState = 'quickanim' + if gameMode == 'practice' then + player1score = player1score + 1 + end + t = 0 + if (ballSpeed > 200) then + shakeMagnitude = ballSpeed/200 + else shakeMagnitude = 0 end + shakeDuration = 1 + randomtext = love.math.random(1, #textphrases) + TEXT = textphrases[randomtext] + soundtype = love.math.random(1, 1.2) + + + + if (player1striken == 1) then + TEXT = 'PLAYER 1 STRIKES' + ballSpeed = ballSpeed + player1nukescore + potentialnuke1 = 0 + player1striken = 0 + player1nukescore = 0 + potentialstrike1 = 0 + striken = 1 + if areanuclear == 0 then + sounds['striking']:setPitch(ballSpeed/250) + sounds['striking']:play() + else + sounds['nuclearhit']:setPitch(1) + sounds['nuclearhit']:play() + end + else + if areanuclear == 0 then + sounds['beep']:setPitch(ballSpeed/250) + sounds['beep']:play() + else + sounds['nuclearhit']:setPitch(1) + sounds['nuclearhit']:play() + end + end + if (striken == 1) then + player1nukescore = player1nukescore * 1.5 + if (synctype == 0) + then + paddle_SPEED = paddle_SPEED * 1.10 + elseif (synctype == 1) + then + paddle_SPEED = ballSpeed /10 + end + if (synctype == 0) + then + AI_SPEED = AI_SPEED * 1.10 end + if (synctype == 1) + then + AI_SPEED = ballSpeed * 1.1 /10 + end + ballSpeed = ballSpeed * 1.10 + end + player1nukescore = player1nukescore + 10 + ball[i].dx = -ball[i].dx + ball[i].x = player1.x + 30 + + if (love.keyboard.isDown(p1control.up)) then + ball[i].dy = math.random(-2, -1) + elseif love.keyboard.isDown(p1control.down) then + ball[i].dy = math.random(1, 2) + else + if ball[i].dy < 0 then + + ball[i].dy = math.random(-2, -1) + else + ball[i].dy = math.random(1, 2) + end + end + end + if ball[i]:collides(player2) then + --ameState = 'quickanim' + t = 0 + shakeDuration = 1 + if (ballSpeed > 200) then + shakeMagnitude = ballSpeed/200 + else + shakeMagnitude = 0 end + randomtext = love.math.random(1, #textphrases) + TEXT = textphrases[randomtext] + soundtype = love.math.random(1, 1.2) + + + + if (player2striken == 1) then + TEXT = 'PLAYER 2 STRIKES' + ballSpeed = ballSpeed + player2nukescore + striken=1 + player2striken = 0 + potentialnuke2 = 0 + player2nukescore = 0 + potentialstrike2 = 0 + + if areanuclear == 0 then + sounds['striking']:setPitch(ballSpeed/250) + sounds['striking']:play() + else + sounds['nuclearhit']:setPitch(1) + sounds['nuclearhit']:play() + end + elseif (striken == 1) then + player2nukescore = player2nukescore * 1.5 + if (synctype == 0) then paddle_SPEED = paddle_SPEED * 1.10 end + if (synctype == 1) then paddle_SPEED = ballSpeed/10 end + if (synctype == 0) + then + AI_SPEED = AI_SPEED * 1.10 end + if (synctype == 1) + then + AI_SPEED = ballSpeed * 1.1 / 10 + end + ballSpeed = ballSpeed * 1.10 + if areanuclear == 0 then + sounds['beep']:setPitch(ballSpeed/250) + sounds['beep']:play() + else + sounds['nuclearhit']:setPitch(1) + sounds['nuclearhit']:play() + end + else + if areanuclear == 0 then + sounds['beep']:setPitch(ballSpeed/250) + sounds['beep']:play() + else + sounds['nuclearhit']:setPitch(1) + sounds['nuclearhit']:play() + end + end + player2nukescore = player2nukescore + 10 + ball[i].dx = -ball[i].dx + ball[i].x = player2.x - 30 + + if (love.keyboard.isDown(p2control.up) or AI_SPEED < 0) then + select = math.random(1,5) + if select == 1 then + ball[i].dy = -1 + elseif select == 2 then + ball[i].dy = -1.2 + elseif select == 3 then + ball[i].dy = -1.5 + elseif select == 4 then + ball[i].dy = -1.8 + elseif select == 5 then + ball[i].dy = -2 + end + elseif love.keyboard.isDown(p2control.down) or AI_SPEED > 0 then + select = math.random(1,5) + if select == 1 then + ball[i].dy = 1 + elseif select == 2 then + ball[i].dy = 1.2 + elseif select == 3 then + ball[i].dy = 1.5 + elseif select == 4 then + ball[i].dy = 1.8 + elseif select == 5 then + ball[i].dy = 2 + end + else + if ball[i].dy < 0 then + + select = math.random(1,5) + if select == 1 then + ball[i].dy = -1 + elseif select == 2 then + ball[i].dy = -1.2 + elseif select == 3 then + ball[i].dy = -1.5 + elseif select == 4 then + ball[i].dy = -1.8 + elseif select == 5 then + ball[i].dy = -2 + end + else + select = math.random(1,5) + if select == 1 then + ball[i].dy = 1 + elseif select == 2 then + ball[i].dy = 1.2 + elseif select == 3 then + ball[i].dy = 1.5 + elseif select == 4 then + ball[i].dy = 1.8 + elseif select == 5 then + ball[i].dy = 2 + end + end + end + end + if ball[i]:collides(player4) then + --ameState = 'quickanim' + t = 0 + shakeDuration = 1 + if (ballSpeed > 200) then + shakeMagnitude = ballSpeed/200 + else + shakeMagnitude = 0 end + randomtext = love.math.random(1, #textphrases) + TEXT = textphrases[randomtext] + soundtype = love.math.random(1, 1.2) + + + + if (player2striken == 1) then + TEXT = 'PLAYER 2 STRIKES' + ballSpeed = ballSpeed + player2nukescore + striken=1 + player2striken = 0 + potentialnuke2 = 0 + player2nukescore = 0 + potentialstrike2 = 0 + + if areanuclear == 0 then + sounds['striking']:setPitch(ballSpeed/250) + sounds['striking']:play() + else + sounds['nuclearhit']:setPitch(1) + sounds['nuclearhit']:play() + end + elseif (striken == 1) then + player2nukescore = player2nukescore * 1.5 + if (synctype == 0) then paddle_SPEED = paddle_SPEED * 1.10 end + if (synctype == 1) then paddle_SPEED = ballSpeed/10 end + if (synctype == 0) + then + AI_SPEED = AI_SPEED * 1.10 end + if (synctype == 1) + then + AI_SPEED = ballSpeed * 1.1 / 10 + + end + ballSpeed = ballSpeed * 1.10 + if areanuclear == 0 then + sounds['beep']:setPitch(ballSpeed/250) + sounds['beep']:play() + else + sounds['nuclearhit']:setPitch(1) + sounds['nuclearhit']:play() + end + else + if areanuclear == 0 then + sounds['beep']:setPitch(ballSpeed/250) + sounds['beep']:play() + else + sounds['nuclearhit']:setPitch(1) + sounds['nuclearhit']:play() + end + end + player2nukescore = player2nukescore + 10 + ball[i].dx = -ball[i].dx + ball[i].x = player2.x - 30 + + if (love.keyboard.isDown(p2control.up) or AI_SPEED < 0) then + select = math.random(1,5) + if select == 1 then + ball[i].dy = -1 + elseif select == 2 then + ball[i].dy = -1.2 + elseif select == 3 then + ball[i].dy = -1.5 + elseif select == 4 then + ball[i].dy = -1.8 + elseif select == 5 then + ball[i].dy = -2 + end + elseif love.keyboard.isDown(p2control.down) or AI_SPEED > 0 then + select = math.random(1,5) + if select == 1 then + ball[i].dy = 1 + elseif select == 2 then + ball[i].dy = 1.2 + elseif select == 3 then + ball[i].dy = 1.5 + elseif select == 4 then + ball[i].dy = 1.8 + elseif select == 5 then + ball[i].dy = 2 + end + else + if ball[i].dy < 0 then + + select = math.random(1,5) + if select == 1 then + ball[i].dy = -1 + elseif select == 2 then + ball[i].dy = -1.2 + elseif select == 3 then + ball[i].dy = -1.5 + elseif select == 4 then + ball[i].dy = -1.8 + elseif select == 5 then + ball[i].dy = -2 + end + else + select = math.random(1,5) + if select == 1 then + ball[i].dy = 1 + elseif select == 2 then + ball[i].dy = 1.2 + elseif select == 3 then + ball[i].dy = 1.5 + elseif select == 4 then + ball[i].dy = 1.8 + elseif select == 5 then + ball[i].dy = 2 + end + end + end + end + if ball[i].y <= 0 then + soundtype = love.math.random(1, 5) + sounds['wallhit']:setPitch(ballSpeed/250) + sounds['wallhit']:play() + ball[i].y = 0 + ball[i].dy = -ball[i].dy + + end + + -- -4 to account for the ball's size + if ball[i].y >= VIRTUAL_HEIGHT - 40 then + soundtype = love.math.random(1, 5) + sounds['wallhit']:setPitch(ballSpeed/250) + sounds['wallhit']:play() + ball[i].y = VIRTUAL_HEIGHT - 40 + ball[i].dy = -ball[i].dy + end + --love.window.setTitle('Trying to update the ball') + if timeIsSlow then + if ballSpeed > originalSpeed/3 then + paddle_SPEED = 30 + ballSpeed = ballSpeed / (1+(dt*2)) + end + player1nukescore = player1nukescore - (dt*50) + if player1nukescore < 1 or ball[1].dx > 0 then + timeIsSlow = false + player1reverbav = false + ballSpeed = originalSpeed + sounds["time"]:stop() + paddle_SPEED = originalPaddle + end + end + if timeIsSlow2 then + if ballSpeed > originalSpeed/3 then + ballSpeed = ballSpeed / (1+(dt*2)) + end + player2nukescore = player2nukescore - (dt*50) + if player2nukescore < 1 or ball[1].dx < 0 then + paddle_SPEED = 30 + timeIsSlow2 = false + player2reverbav = false + ballSpeed = originalSpeed + sounds["time"]:stop() + paddle_SPEED = originalPaddle + end + end + ball[i]:update(dt) + end + end + + player1:update(dt) + player2:update(dt) + player3:update(dt) + player4:update(dt) + + end + function wallbreaker(x,y) + if (gameState == 'editor') then + for i, wall in ipairs(walls) do + + + if math.abs(wall.wallx - x) < 10 and math.abs(wall.wally - y) < 10 + then + table.remove(walls, i) + end + end +end +end +function editor() + if (gameState == 'editor') + then + local mx, my = love.mouse.getPosition() + mx = mx * DIFFERENCE_X + my = my * DIFFERENCE_Y + if not blockinput then + love.graphics.setColor(1,0,0,1) + love.graphics.rectangle('fill',mx, my, 10, wall1width) + love.graphics.setColor(1,1,1,1) + end + if (love.mouse.isDown(2)) then + wallbreaker(mx, my) + end + if (love.mouse.isDown(3)) then + table.insert(walls, newWall(mx,my, 10, wall1width)) + end + + for i, wall in ipairs(walls) do + love.graphics.setColor(1,1,1,1) + love.graphics.rectangle("fill", wall.wallx, wall.wally, 10, wall.wallheight) + end + end +end +function hardmanager(diff) + selecting = 1 + if (diff == 'easy') + then + INDIC[1] = '>' + AGAINST_AI = 1 + AI_SPEED = ballSet/10 + AI_STRIKEMOD = 100 + AI_NUKEMOD = 1000 + difficultyl = 200 + selecting = 0 + gameState = '1serve' +end + if (diff == 'normal') + then + INDIC[2] = '>' + AI_SPEED = ballSet/10 + AI_LEVEL = 500 + AI_NUKEMOD = 250 + AI_STRIKEMOD = 60 + AGAINST_AI = 1 + difficultyl = 300 + selecting = 0 + gameState = '1serve' +end + if (diff == 'hard') + then + INDIC[3] = '>' + AI_SPEED = ballSpeed * 1.1 + 50 + AI_SPEED = AI_SPEED / 10 + AI_LEVEL = 700 + AI_NUKEMOD = 200 + AI_STRIKEMOD = 20 + selecting = 0 + difficultyl = 350 + AGAINST_AI = 1 + gameState = '1serve' +end +if (diff == 'practice') then + INDIC[3] = '>' + AI_SPEED = ballSpeed * 500 + 50 + AI_SPEED = AI_SPEED / 10 + AI_LEVEL = 700 + AI_NUKEMOD = 9000000000 + AI_STRIKEMOD = 90000000 + selecting = 0 + difficultyl = 350 + AGAINST_AI = 1 + gameState = '1serve' + end +end + + +function dangerChecker() +if (p1control.up == p1control.down) then danger = '1up' danger2 = '1down' +elseif (p1control.up == p1control.super) then danger = '1up' danger2 = '1special' +elseif (p1control.up == p1control.counter) then danger = '1up' danger2 = '1ct' +elseif (p1control.down == p1control.super) then danger = '1down' danger2 = '1special' +elseif (p1control.down == p1control.counter) then danger = '1ct' danger2 = '1down' +elseif (p1control.super == p1control.counter) then danger = '1special' danger2 = '1ct' +elseif (p2control.down == p2control.up) then danger = '2down' danger2 = '2up' +elseif (p2control.down == p2control.super) then danger = '2down' danger2 = '2special' +elseif (p2control.down == p2control.counter) then danger = '2down' danger2 = '2ct' +elseif (p2control.up == p2control.super) then danger = '2up' danger2 = '2special' +elseif (p2control.up == p2control.counter) then danger = '2ct' danger2 = '2up' +elseif (p2control.super == p2control.counter) then danger = '2special' danger2 = '2ct' + +else + danger = "none" + danger2 = "none" +end + + +end +function love.keypressed(key) + if gameState == 'assign' then + if (req == 'p1up') then p1control.up = key + currentKey = key + --love.window.setTitle(key) + gameState = 'controlSettings' +end + if (req == 'p2up') then p2control.up = key + currentKey = key + --love.window.setTitle(key) + gameState = 'controlSettings' +end + if (req == 'p1down') then p1control.down = key + currentKey = key + --love.window.setTitle(key) + gameState = 'controlSettings' +end + if (req == 'p2down') then p2control.down = key + currentKey = key + -- love.window.setTitle(key) + gameState = 'controlSettings' +end + if (req == 'p1super') then p1control.super = key + currentKey = key + -- love.window.setTitle(key) + gameState = 'controlSettings' +end + if (req == 'p2super') then p2control.super = key + currentKey = key + -- love.window.setTitle(key) + gameState = 'controlSettings' +end + if (req == 'p1ct') then p1control.counter = key + currentKey = key + -- love.window.setTitle(key) + gameState = 'controlSettings' +end + if (req == 'p2ct') then p2control.counter = key + currentKey = key + --love.window.setTitle(key) + gameState = 'controlSettings' +end + end + if key == 'escape' then + TEXT = 'Escape Key' + love.event.quit() + elseif key == 'enter' or key == 'return' then + + if gameState == 'start' then + resettinggenius() + gameState = 'menu' + hardmanager() +elseif (gameState == 'done') then + if (player1score > player2score) then + gameState = '2serve' + potentialnuke1 = 0 + potentialnuke2 = 0 + striken = 0 + if (nuckemodactive == 0) then + areanuclear = 0 + nuclearanimation = 3 +end + potentialstrike1 = 0 + potentialstrike2 = 0 + player1nukescore = 0 + player2nukescore = 0 + else + gameState = '1serve' + resettinggenius() + for i = 1, maxBalls do + ball[i]:reset(i) +end + end + else + gameState = 'menu' + if (love.math.random(0, 10) == 1) + then + TEXT = "Nuclear Ching Chong" + else + TEXT = 'Nuclear Pong' + end + resettinggenius() + for i = 1, maxBalls do + ball[i]:reset(i) + end + end +end + +end + +function love.keyreleased(key) + currentKey = " " + + end +function speedSetter(requesttype) + if (requesttype == 'ball') then + if (ballSet > 550) then + ballSet = 0 + paddle_SPEED = 0 + + else + ballSet = ballSet + 50 + paddle_SPEED = paddle_SPEED + 5 + end + ballSpeed = ballSet + end + if (requesttype == 'snc') then + synctype = synctype + 1 + if (synctype > 1) then + synctype = 0 + end + + if synctype == 0 then synctext = 'Independent' end + if synctype == 1 then synctext = 'Synchronised' end + end + if (requesttype == 'nuclearmod') + then + + nuckemodactive = nuckemodactive + 1 + if (nuckemodactive > 1) then + + nuckemodactive = 0 + end + if (nuckemodactive == 0) + then + areanuclear = 0 + nuclearanimation = 3 + ballSet = 200 + TEXT = "Nuclear Pong" + + synctype = 0 + maxspeed = 700 + synctext = 'Independent' + paddle_SPEED = ballSet/10 + AI_SPEED = ballSet/10 + + end + if (nuckemodactive == 1) + then + areanuclear = 1 + ballSet = 2000 + maxspeed = 2000 + paddle_SPEED = ballSet/10 + AI_SPEED = ballSet/10 + synctext = "death is imminent" + end + ballSpeed = ballSet + end + if (requesttype == 'practice') then + if (ballSpeed > 999) then + ballSpeed = 200 + ballSet = 200 + end + if (ballSpeed > 799) then + prtext = 'Insane' + maxBalls = 5 +elseif ballSpeed > 599 then + prtext = 'Hard' + maxBalls = 4 +elseif ballSpeed > 399 then + prtext = 'Normal' + maxBalls = 3 +elseif ballSpeed > 199 then + prtext = 'Easy' + maxBalls = 3 +end + ballSpeed = ballSpeed + 200 + ballSet = ballSet + 200 + end + if (requesttype == 'reset') + then + ballSpeed = 200 + ballSet = 200 + synctype = 0 + prtext = 'Easy' + maxBalls = 1 + end + if (requesttype == 'pc') then + if (playerCount == 2) then + playerCount = 1 + playertext = '1v1' + elseif (playerCount == 1) then + playerCount = playerCount + 1 + player3.x = player1.x + VIRTUAL_WIDTH / 2 + player3.y = player3.y + playertext = '2v2' +end + + + end + if (requesttype == 'ballz') then +if (maxBalls > 1) then + maxBalls = 1 + --love.window.setTitle("more than 4") + else + maxBalls = maxBalls + 1 +end + + end + if requesttype == 'ptw' then + if ptw == 10 then + ptw = 1 + else + ptw = ptw + 1 + end + end + + end + +function gameModeChanger() +if (gameState == 'gameMode') then + local button_width = VIRTUAL_WIDTH * (1/3) + local BUTTON_HEIGHT = 50 + local margin = 20 + local hot = false + local cursor_y = 0 + local total_height = (BUTTON_HEIGHT + margin) * #buttons + for i, button in ipairs(modeSelectorButtons) do + button.last = button.now + local bx = (VIRTUAL_WIDTH*0.5) - (button_width * 0.5) + local by = (VIRTUAL_HEIGHT * 0.5) - (total_height * 0.5) + cursor_y + local color = {255, 255, 255, 255} + local mx, my = love.mouse.getPosition() + mx = mx * DIFFERENCE_X + my = my * DIFFERENCE_Y + hot = (mx > bx and mx < bx + button_width and my > by and my < by + BUTTON_HEIGHT) and i + if (hot == i) then + color = {10, 10, 0, 255} + end + button.now = love.mouse.isDown(1) + if button.now and not button.last and hot == i then + love.graphics.setColor(0,0,0,1) + love.graphics.rectangle("fill", 0, 0, VIRTUAL_WIDTH, VIRTUAL_HEIGHT) + sounds['wallhit']:play() + button.fn() + end + love.graphics.setColor(unpack(color)) + love.graphics.rectangle("fill", bx, by, button_width, BUTTON_HEIGHT) + love.graphics.setColor(0, 0, 0, 255) + local textW = smallfont:getWidth(button.text) + local textH = smallfont:getHeight(button.text) + love.graphics.print(button.text, smallfont, VIRTUAL_WIDTH*0.5 - textW*0.5, by+textH*0.5) + love.graphics.setColor(255, 255, 255, 255) + cursor_y = cursor_y + (BUTTON_HEIGHT + margin) + + end + end +if (gameState == 'multiMode') + then + local button_width = VIRTUAL_WIDTH * (1/3) + local BUTTON_HEIGHT = 50 + local margin = 20 + local hot = false + local cursor_y = 0 + local total_height = (BUTTON_HEIGHT + margin) * #buttons + for i, button in ipairs(playerCountButtons) do + button.last = button.now + + local bx = (VIRTUAL_WIDTH*0.5) - (button_width * 0.5) + + local by = (VIRTUAL_HEIGHT * 0.3) - (total_height * 0.5) + cursor_y + if (button.text == 'Play') then + by = by + by/1.8 + end + local color = {255, 255, 255, 255} + local mx, my = love.mouse.getPosition() + mx = mx * DIFFERENCE_X + my = my * DIFFERENCE_Y + hot = (mx > bx and mx < bx + button_width and my > by and my < by + BUTTON_HEIGHT) and i + if (hot == i) then + if (button.text == 'Play') then color = {0/255, 255/255, 0/255, 255} else + color = {10, 10, 0, 255} + end + end + button.now = love.mouse.isDown(1) + if button.now and not button.last and hot == i then + love.graphics.setColor(0,0,0,1) + love.graphics.rectangle("fill", 0, 0, VIRTUAL_WIDTH, VIRTUAL_HEIGHT) + sounds['wallhit']:play() + if button.text == "Ball Speed: " and nuckemodactive == 1 then + else + + button.fn() + + end + end + love.graphics.setColor(unpack(color)) + love.graphics.rectangle("fill", bx, by, button_width, BUTTON_HEIGHT) + love.graphics.setColor(0, 0, 0, 255) + local textW = smallfont:getWidth(button.text) + local textH = smallfont:getHeight(button.text) + if (button.text == '1v1') then love.graphics.print(playertext, smallfont, VIRTUAL_WIDTH*0.5 - textW*0.5, by+textH*0.5) + elseif button.text == 'snc' then + if (nuckemodactive == 1) then + love.graphics.setColor(1,0,0,1) + love.graphics.print(synctext, smallfont, VIRTUAL_WIDTH*0.5 - textW*0.5, by+textH*0.5) + love.graphics.setColor(1,1,1,1) + love.graphics.print(synctext, smallfont, VIRTUAL_WIDTH*0.5 - textW*0.5, by+textH*0.5) + love.graphics.setColor(0,0,0,1) + else + -- + love.graphics.print(synctext, smallfont, VIRTUAL_WIDTH*0.45 - textW*0.5, by+textH*0.5) + end + elseif (button.text == 'ballCount') then love.graphics.print("Ball Count: " .. maxBalls, smallfont, VIRTUAL_WIDTH*0.5 - textW*0.5, by+textH*0.5) + elseif (button.text == "Ball Speed: ") then + if (nuckemodactive == 1) then + love.graphics.setColor(1,0,0,1) + love.graphics.print("shaitan machina", smallfont, VIRTUAL_WIDTH*0.5 - textW*0.5, by+textH*0.5) + love.graphics.setColor(1,1,1,1) + love.graphics.print("shaitan machina", smallfont, VIRTUAL_WIDTH*0.5 - textW*0.5, by+textH*0.5) + love.graphics.setColor(0,0,0,1) + + else + love.graphics.print(button.text .. ballSet, smallfont, VIRTUAL_WIDTH*0.5 - textW*0.5, by+textH*0.5) + end + elseif button.text == 'ptw' then love.graphics.print("Points to Win: " .. ptw, smallfont,VIRTUAL_WIDTH*0.5 - textW * 1.5, by+textH*0.5) + else + love.graphics.print(button.text, smallfont, VIRTUAL_WIDTH*0.5 - textW*0.5, by+textH*0.5) + end + love.graphics.setColor(255, 255, 255, 255) + cursor_y = cursor_y + (BUTTON_HEIGHT + margin) + + end + + + end + + +end +function love.draw() + simpleScale.set() + -- resolutionChanger() + --love.graphics.scale( 1.5, 1.5 ) + -- love.graphics.translate( (WINDOW_WIDTH*1.5 - WINDOW_WIDTH), WINDOW_HEIGHT*1.5 - WINDOW_HEIGHT ) +-- push:apply('start') + --resolutionButtons() + if gameState == 'nuclearExplosion' then + love.graphics.setColor(1,1,1,1) + love.graphics.circle("fill", ball[1].x, ball[1].y , explosionRange*100, 100) + player1.RED, player1.GREEN, player1.BLUE, player2.RED, player2.GREEN, player2.BLUE = nuclearanimation/3,nuclearanimation/3,nuclearanimation/3,nuclearanimation/3,nuclearanimation/3,nuclearanimation/3 + for i = 1, maxBalls do + love.graphics.setColor(nuclearanimation/3,nuclearanimation/3,nuclearanimation/3,1) + ball[i]:render('controlled') + end + player1:render() + player2:render() + elseif gameState == 'animation' then + callAnimator() + else + mapChanger() + if t < shakeDuration then + --love.window.setTitle("lamo") + local dx = love.math.random(-shakeMagnitude, shakeMagnitude) + local dy = love.math.random(-shakeMagnitude, shakeMagnitude) + love.graphics.translate(dx, dy) + end + if (gameState == 'menu') then + updateTEXT = '0.7 Chalkboard Update' + end + serveBot() + hardmanager() + + if (areanuclear == 1) then + love.graphics.setShader(shader) + love.graphics.clear(1,1,1,1) + else + love.graphics.setShader() + love.graphics.clear(40/255, 40/255, 40/255, 1) --BACKGROUND COLOR + end + if (gameMode == 'practice') then + love.graphics.rectangle('fill', VIRTUAL_WIDTH, 0, 10, VIRTUAL_HEIGHT) + end + if (MAP_TYPE == 1) then + love.graphics.setColor(1, 0, 0.20, 1) + love.graphics.rectangle('fill', VIRTUAL_WIDTH *0.5, 0, 10, VIRTUAL_HEIGHT * 0.3) + love.graphics.rectangle('fill', VIRTUAL_WIDTH *0.5, VIRTUAL_HEIGHT * 0.7, 10, VIRTUAL_HEIGHT * 0.3) + love.graphics.setColor(1, 1, 1, 1) + end + love.graphics.setFont(scorefont) + if gameState == 'play' or gameState == '1serve' or gameState == '2serve' then + love.graphics.setFont(smallfont) + end + + love.graphics.printf(TEXT,0,20,VIRTUAL_WIDTH,'center') + love.graphics.setFont(smallfont) + love.graphics.printf(updateTEXT,0,VIRTUAL_HEIGHT * 0.95,VIRTUAL_WIDTH,'left') + love.graphics.setFont(scorefont) + love.graphics.print(tostring(math.floor(player1score)), VIRTUAL_WIDTH / 2 - 500, VIRTUAL_HEIGHT / 12) + if (gameMode ~= 'practice') then + love.graphics.print(tostring(math.floor(player2score)), VIRTUAL_WIDTH / 2 + 400, VIRTUAL_HEIGHT / 12) + end + love.graphics.setFont(smallfont) + + if (potentialstrike1 == 1 and potentialnuke1 == 0 and player1reverbav == 0) then + if (player1striken == 0) then + love.graphics.print(tostring(math.floor(player1nukescore) .. '['..p1control.super..']'), VIRTUAL_WIDTH / 2 - 500, VIRTUAL_HEIGHT / 60) + else + love.graphics.print(tostring('READY'), VIRTUAL_WIDTH / 2 - 500, VIRTUAL_HEIGHT / 60) + end + elseif (player1reverbav == 1 and potentialnuke1 == 0) then + love.graphics.print(tostring(math.floor(player1nukescore) ..'[' ..p1control.super .. ']' .. " ["..p1control.counter..']'), VIRTUAL_WIDTH / 2 - 500, VIRTUAL_HEIGHT / 60) + elseif (potentialnuke1 == 1) then + love.graphics.setColor(255, 0, 0, 255) + love.graphics.print(tostring(math.floor(player1nukescore) .. '[' .. p1control.super .. ']' .. " ["..p1control.counter .. ']'), VIRTUAL_WIDTH / 2 - 500, VIRTUAL_HEIGHT / 60) + love.graphics.setColor(255, 255, 255, 255) + else + love.graphics.print(tostring(math.floor(player1nukescore)), VIRTUAL_WIDTH / 2 - 500, VIRTUAL_HEIGHT / 60) + end + if (potentialstrike2 == 1 and player2reverbav == 0) then + if (player2striken == 0 and gameMode ~= 'practice') then + love.graphics.print(tostring(math.floor(player2nukescore) .. '['..p2control.super..']'), VIRTUAL_WIDTH / 2 + 430, VIRTUAL_HEIGHT / 60) + elseif (gameMode ~= 'practice') then + love.graphics.print(tostring('READY'), VIRTUAL_WIDTH / 2 + 430, VIRTUAL_HEIGHT / 60) + end + elseif (potentialnuke2 == 1 and gameMode ~= 'practice') then + love.graphics.setColor(255, 0, 0, 255) + love.graphics.print(tostring(math.floor(player2nukescore) .. '['..p2control.super..']'), VIRTUAL_WIDTH / 2 + 430, VIRTUAL_HEIGHT / 60) + love.graphics.setColor(255, 255, 255, 255) + elseif (player2reverbav == 1 and potentialnuke2 == 0) then + love.graphics.print(tostring(math.floor(player2nukescore) .. '['..p2control.super .. "] [" .. p2control.counter..']'), VIRTUAL_WIDTH / 2 + 430, VIRTUAL_HEIGHT / 60) + elseif (gameMode ~= 'practice') then + love.graphics.print(tostring(math.floor(player2nukescore)), VIRTUAL_WIDTH / 2 + 430, VIRTUAL_HEIGHT / 60) + end + if (MAP_TYPE == 2) then + for i, wall in ipairs(walls) do + + love.graphics.setColor(1,1,1,1) + love.graphics.rectangle("fill", wall.wallx, wall.wally, 10, wall.wallheight) + end + end + if gameState ~= 'assign' then + player1:render() + player3:render() + if gameMode ~= 'practice' then + player2:render() + player4:render() + end + for i = 1, maxBalls do + if areanuclear == 1 then + ball[i]:render('black') + --love.window.setTitle('rendering black') + else + ball[i]:render(' ') + --love.window.setTitle('rendering white') + end + end + if gameState == 'windowsettings' then + mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, settings, sounds, 'right') + love.keyboard.mouseisReleased = false + end + if gameState == 'editor' then + mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, editorpicks, sounds, 'right') + love.keyboard.mouseisReleased = false + end + if gameState == 'speedSettings' then + mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, speedParameters, sounds, 'middle') + love.keyboard.mouseisReleased = false + end + if gameState == 'controlSettings' then + mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, controlSettings, sounds, 'control') + love.keyboard.mouseisReleased = false + end + if gameState == 'gameMode' then + mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, modeSelectorButtons, sounds, 'middle') + love.keyboard.mouseisReleased = false + end + if gameState == 'menu' then + mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, buttons, sounds, 'middle') + love.keyboard.mouseisReleased = false + end + if gameState == 'difficulty' then + mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, difbuttons, sounds, 'middle') + love.keyboard.mouseisReleased = false + end + if gameState == 'multiMode' then + mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, playerCountButtons, sounds, 'playercount') + love.keyboard.mouseisReleased = false + end + if gameState == 'prdiff' then + mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, pracdiff, sounds, 'playercount') + love.keyboard.mouseisReleased = false + end + end + editor() + if (gameState == 'start') then + love.graphics.push() + love.graphics.translate( + VIRTUAL_WIDTH * 0.4, + VIRTUAL_HEIGHT * 0.5 + ) + love.graphics.rotate(rotation) + love.graphics.setFont(smallfont) + love.graphics.print("Press Enter to Start", WINDOW_WIDTH / -10 , VIRTUAL_HEIGHT / 8) + love.graphics.setColor(255,255,255,255) + love.graphics.pop() + + + end + end + if gameState == 'assign' then + controlChanger() + end + simpleScale.unSet() +end + -- push:apply('end') + function controllerSer() + for i = 1, maxBalls do + if (ball[i].dy == 0) then + hitNum[i] = hitNum[i] +1 + --love.window.setTitle(hitNum[i]) + if hitNum[i] >= 10 then + ball[i].dy = 1 + hitNum[i] = 0 + end + else + hitNum[i] = 0 + end +end + + end + function palleteController() + if (areanuclear == 0) then player1.RED = 1 player1.GREEN = 1 player1.BLUE = 1 end + if (areanuclear == 0) then player2.RED = 1 player2.GREEN = 1 player2.BLUE = 1 end + if (areanuclear == 1) then player1.RED = 0 player1.GREEN = 0 player1.BLUE = 0 end + if (areanuclear == 1) then player2.RED = 0 player2.GREEN = 0 player2.BLUE = 0 end + end + + + + + +function love.wheelmoved(x, y) +if (y < 0 and wall1width > 0) then + wall1width = wall1width - 5 +elseif y > 0 and wall1width < 900 then wall1width = wall1width + 5 +end + + end + +function serveBot() +if (gameState == '1serve') then + updateTEXT = '' + if (gameMode ~= 'practice') then + TEXT = 'PLAYER 1, serve!(q)' +end + if (love.keyboard.isDown('q') or gameMode == 'practice') then + TEXT = 'Lets Begin!' + ball_DIR = 1 + for i = 1, maxBalls do + ball[i]:reset(i) + +end + --love.window.setTitle("An atttttttt") + gameState = 'play' + end +end +if (gameState == '2serve') then + TEXT = 'PLAYER 2, serve!(p)' + if (AGAINST_AI == 1) then + TEXT = '' + ball_DIR = -1 + for i = 1, maxBalls do + ball[i]:reset(i) +end + --love.window.setTitle("An atttttttt") + gameState = 'play' + end + if (love.keyboard.isDown('p') and AGAINST_AI == 0) then + TEXT = 'Lets Begin' + ball_DIR = -1 + for i = 1, maxBalls do + ball[i]:reset(i) +end + --love.window.setTitle("An atttttttt") + gameState = 'play' + end +end +end +function mapChanger() + for i = 1, maxBalls do + if (gameState == 'editor') then MAP_TYPE = 2 end + if (MAP_TYPE > 2) then + MAP_TYPE = 0 + end + if (gameMode == 'practice') then + MAP_TYPE = 0 + if ball[i].x > VIRTUAL_WIDTH * 0.99 then + soundtype = love.math.random(1, 5) + sounds['wallhit']:setPitch(ballSpeed/250) + sounds['wallhit']:play() + if (ball[i].dx > 0) + then ball[i].x = ball[i].x - 20 + else ball[i].x = ball[i].x + 20 + end + ball[i].dx = -ball[i].dx + + end + + end + if (MAP_TYPE == 1) + then + if ball[i].y < VIRTUAL_HEIGHT * 0.3 and ball[i].x > VIRTUAL_WIDTH * 0.5 and ball[i].x < VIRTUAL_WIDTH * 0.5 + 5 then + soundtype = love.math.random(1, 5) + sounds['wallhit']:setPitch(ballSpeed/250) + sounds['wallhit']:play() + if (ball[i].dx > 0) + then ball[i].x = ball[i].x - 20 + else ball[i].x = ball[i].x + 20 + end + ball[i].dx = -ball[i].dx + + end + if ball[i].y > VIRTUAL_HEIGHT * 0.7 and ball[i].x > VIRTUAL_WIDTH * 0.5 and ball[i].x < VIRTUAL_WIDTH * 0.5 + 5 then + soundtype = love.math.random(1, 5) + sounds['wallhit']:setPitch(ballSpeed/250) + sounds['wallhit']:play() + if (ball[i].dx > 0) + then ball[i].x = ball[i].x - 20 + else ball[i].x = ball[i].x + 20 + end + ball[i].dx = -ball[i].dx + + end + end + if (MAP_TYPE == 2) then + for i, wall in ipairs(walls) do + + if (ball[1].y > wall.wally and ball[1].y < wall.wally+wall.wallheight and ball[1].x > wall.wallx - ballSpeed/200 and ball[1].x < wall.wallx + 10 + ballSpeed/200) then + controllerSer() + soundtype = love.math.random(1, 5) + sounds['wallhit']:setPitch(ballSpeed/250) + sounds['wallhit']:play() + if (ball[1].dx > 0) + then ball[1].x = ball[1].x - 1 + else ball[1].x = ball[1].x + 1 + end + ball[1].dx = -ball[1].dx + + elseif (ball[1].y > wall.wally-15 and ball[1].y < wall.wally+wall.wallheight+10 and ball[1].x > wall.wallx and ball[1].x < wall.wallx + 10) then + controllerSer() + soundtype = love.math.random(1, 5) + sounds['wallhit']:setPitch(ballSpeed/250) + sounds['wallhit']:play() + if (ball[1].dy > 0) + then ball[1].y = ball[1].y - 1 + else ball[1].y = ball[1].y + 1 + end + ball[1].dy = -ball[1].dy + end + end + end + end + +end +function resolutionChanger() + if (RESOLUTION_SET > 1) then + RESOLUTION_SET = 0 + end + if (RESOLUTION_SET == 0 ) then + if (isFullscreen == 1) then + DIFFERENCE_X = 1 + DIFFERENCE_Y = 1 + simpleScale.updateWindow(WINDOW_WIDTH, WINDOW_HEIGHT,{fullscreen = false}) + isFullscreen = 0 + end + + end + if (RESOLUTION_SET == 1) then + if (isFullscreen == 0) then + simpleScale.updateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, {fullscreen = true}) + local newWidth = love.graphics.getWidth() + local newHeight = love.graphics.getHeight() + DIFFERENCE_X = VIRTUAL_WIDTH / newWidth + DIFFERENCE_Y = VIRTUAL_HEIGHT / newHeight + isFullscreen = 1 + + end +end + + +end +function resettinggenius() + maxBalls = 1 + for i =1, maxBalls do + ball[i]:reset(i) + end + paddle_SPEED = 20 + nuclearanimation = 3 + timeIsSlow =false + timeIsSlow2 = false + originalSpeed = 200 + gameState = 'menu' + gameMode = 'notpracticd' + ballSet = 200 + ballSpeed = ballSet + player2.GREEN = 255 + player2.BLUE = 255 + player1.GREEN = 255 + player1.BLUE = 255 + player1score = 0 + player2score = 0 + potentialnuke1 = 0 + potentialnuke2 = 0 + striken = 0 + areanuclear = 0 + potentialstrike1 = 0 + potentialstrike2 = 0 + player1nukescore = 0 + player2nukescore = 0 + player1reverbav = 0 + player2reverbav = 0 + selecting = 0 + AGAINST_AI = 0 + end + +function animator(dt) + if (gameState == 'animation') then + time_1 = time_1 + dt + light = 255 - time_1 * 85 + if (light < 0) then + time_1 = 0 + light = 0 + gameState = 'start' + end +end + + +end +function callAnimator() + love.graphics.setColor(255,255,255,light/255) + love.graphics.draw(image,0,0) + end +function love.mousereleased(x, y, button) +love.keyboard.mouseisReleased = true + if (gameState == 'editor') then + if (#walls < 1000 and button == 1 and blockinput ~= true) then + table.insert(walls, newWall(x*DIFFERENCE_X,y*DIFFERENCE_Y, 10, wall1width)) + end + end +end \ No newline at end of file diff --git a/mainMenu.lua b/mainMenu.lua new file mode 100644 index 0000000..62a6976 --- /dev/null +++ b/mainMenu.lua @@ -0,0 +1,219 @@ +mainMenu = Class{} +function mainMenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, buttons, sounds, location) + if (gameState == 'editor') + then + ev_button_width = VIRTUAL_WIDTH * (1/72) + ev_BUTTON_HEIGHT = VIRTUAL_WIDTH * (1/72) + local margin = 16 + local hot = false + local cursor_y = 0 + blockinput = false + local total_height = (ev_BUTTON_HEIGHT + margin) * #buttons + for i, button in ipairs(buttons) do + button.last = button.now + ev_bx = (VIRTUAL_WIDTH*0.05) - (ev_button_width * 0.5) + ev_by = (VIRTUAL_HEIGHT * 0.1) - (total_height * 0.5) + cursor_y + local color = {255, 255, 255, 255} + local mx, my = love.mouse.getPosition() + mx = mx * DIFFERENCE_X + my = my * DIFFERENCE_Y + hot = (mx > ev_bx and mx < ev_bx + ev_button_width and my > ev_by and my < ev_by + ev_BUTTON_HEIGHT) and i + if (hot == i) then + blockinput = blockinput or true + color = {10, 10, 0, 255} + end + + button.now = love.keyboard.mouseWasReleased() + + if button.now and not button.last and hot == i then + + love.graphics.setColor(0,0,0,1) + love.graphics.rectangle("fill", 0, 0, VIRTUAL_WIDTH, VIRTUAL_HEIGHT) + sounds['wallhit']:play() + button.fn() + end + love.graphics.setColor(unpack(color)) + love.graphics.rectangle("fill", ev_bx,ev_by, ev_button_width, ev_BUTTON_HEIGHT) + love.graphics.setColor(0, 0, 0, 255) + local textW = smallfont:getWidth(button.text) + local textH = smallfont:getHeight(button.text) + love.graphics.print(button.text, smallfont, VIRTUAL_WIDTH*0.05 - textW*0.5, ev_by*0.9+textH*0.01) + love.graphics.setColor(255, 255, 255, 255) + cursor_y = cursor_y + (ev_BUTTON_HEIGHT + margin) + + end + else + if location == 'middle' then + locationx = (VIRTUAL_WIDTH * 0.5) + locationy = (VIRTUAL_HEIGHT* 0.5) + elseif location == 'right' then + locationx = (VIRTUAL_WIDTH * 0.8) + locationy = (VIRTUAL_HEIGHT* 0.5) + elseif location == 'control' then + locationx = (VIRTUAL_WIDTH * 0.2) + locationy = (VIRTUAL_HEIGHT* 0.5) + end + local ev_button_width = VIRTUAL_WIDTH * (1/3) + local ev_BUTTON_HEIGHT = 50 + local margin = 16 + local hot = false + local cursor_y = 0 + local total_height = (ev_BUTTON_HEIGHT + margin) * #buttons + local ev_bx, ev_by + for i, button in ipairs(buttons) do + button.last = button.now + if (location == 'control') then + + if string.sub(button.text, 1, 1) == '2' then + ev_bx = (VIRTUAL_WIDTH*0.2) - (ev_button_width * 0.5) + ev_by = locationy - (total_height * 0.5) + cursor_y + elseif string.sub(button.text, 1, 1) == '1' then + ev_bx = (VIRTUAL_WIDTH*0.8) - (ev_button_width * 0.5) + ev_by = locationy - (total_height * 0.5) + cursor_y + else + ev_bx = (VIRTUAL_WIDTH*0.5) - (ev_button_width * 0.5) + ev_by = locationy - (total_height * 0.5) + cursor_y + end + elseif button.text == 'NUCLEAR MODE' and easternum < 11 then + ev_bx = -400 + ev_by = -400 + else + ev_bx = locationx - (ev_button_width * 0.5) + ev_by = locationy - (total_height * 0.5) + cursor_y + end + if (button.text == 'Play') and location == 'playercount' then color = {0/255, 255/255, 0/255, 255} else + color = {10, 10, 0, 255} + end + local color = {255, 255, 255, 255} + if (button.text == 'NUCLEAR MODE' and easternum > 10) then + color = {0,0,0,1} + else + color = {1,1,1,1} + end + local mx, my = love.mouse.getPosition() + local mx = mx * DIFFERENCE_X + local my = my * DIFFERENCE_Y + local hot = (mx > ev_bx and mx < ev_bx + ev_button_width and my > ev_by and my < ev_by + ev_BUTTON_HEIGHT) and i + if (hot == i) then + color = {10, 10, 0, 255} + end + button.now = love.keyboard.mouseWasReleased() + if button.now and not button.last and hot == i then + love.graphics.setColor(0,0,0,1) + love.graphics.rectangle("fill", 0, 0, VIRTUAL_WIDTH, VIRTUAL_HEIGHT) + sounds['wallhit']:play() + button.fn() + end + love.graphics.setColor(unpack(color)) + love.graphics.rectangle("fill", ev_bx,ev_by, ev_button_width, ev_BUTTON_HEIGHT) + love.graphics.setColor(0, 0, 0, 255) + local textW = smallfont:getWidth(button.text) + local textH = smallfont:getHeight(button.text) + if (location == 'control') then + if (button.text == "1up") then + love.graphics.print("Player 1 UP: " .. string.upper(p1control.up), smallfont, ev_bx + (ev_button_width * 0.1), ev_by+textH*0.5) + elseif button.text == '2up' then + love.graphics.print("Player 2 UP: " .. string.upper(p2control.up), smallfont, ev_bx + (ev_button_width * 0.1), ev_by+textH*0.5) + elseif button.text == '1down' then + love.graphics.print("Player 1 DOWN: " .. string.upper(p1control.down), smallfont, ev_bx + (ev_button_width * 0.1), ev_by+textH*0.5) + elseif button.text == '2down' then + love.graphics.print("Player 2 DOWN: " .. string.upper(p2control.down), smallfont, ev_bx + (ev_button_width * 0.1), ev_by+textH*0.5) + elseif button.text == '1special' then + love.graphics.print("Player 1 SPECIAL: " .. string.upper(p1control.super), smallfont, ev_bx + (ev_button_width * 0.1), ev_by+textH*0.5) + elseif button.text == '2special' then + love.graphics.print("Player 2 SPECIAL: " .. string.upper(p2control.super), smallfont, ev_bx + (ev_button_width * 0.1), ev_by+textH*0.5) + elseif button.text == '1ct' then + love.graphics.print("Player 1 COUNTER: " .. string.upper(p1control.counter), smallfont, ev_bx + (ev_button_width * 0.1), ev_by+textH*0.5) + elseif button.text == '2ct' then + love.graphics.print("Player 2 COUNTER: " .. string.upper(p2control.counter), smallfont, ev_bx + (ev_button_width * 0.1), ev_by+textH*0.5) + else + love.graphics.print(button.text, smallfont, ev_bx + (ev_button_width * 0.1), ev_by+textH*0.5) + + end + cursor_y = cursor_y + (ev_BUTTON_HEIGHT + margin) + else + if (button.text == '1v1') then + love.graphics.print(playertext, smallfont, VIRTUAL_WIDTH*0.5 - textW*0.5, by+textH*0.5) + elseif button.text == 'snc' then + if (nuckemodactive == 1) then + love.graphics.setColor(1,0,0,1) + love.graphics.print(synctext, smallfont, VIRTUAL_WIDTH*0.5 - textW*0.5, ev_by+textH*0.5) + love.graphics.setColor(1,1,1,1) + love.graphics.print(synctext, smallfont, VIRTUAL_WIDTH*0.5 - textW*0.5, ev_by+textH*0.5) + love.graphics.setColor(0,0,0,1) + else + love.graphics.print(synctext, smallfont, VIRTUAL_WIDTH*0.45 - textW*0.5, ev_by+textH*0.5) + end + elseif (button.text == 'ballCount') then + love.graphics.print("Ball Count: " .. maxBalls, smallfont, VIRTUAL_WIDTH*0.5 - textW*0.5, ev_by+textH*0.5) + elseif (button.text == "Ball Speed: ") then + if (nuckemodactive == 1) then + + love.graphics.setColor(1,0,0,1) + love.graphics.print("shaitan machina", smallfont, VIRTUAL_WIDTH*0.5 - textW*0.5, ev_by+textH*0.5) + love.graphics.setColor(1,1,1,1) + love.graphics.print("shaitan machina", smallfont, VIRTUAL_WIDTH*0.5 - textW*0.5, ev_by+textH*0.5) + love.graphics.setColor(0,0,0,1) + + else + love.graphics.print(button.text .. ballSet, smallfont, VIRTUAL_WIDTH*0.5 - textW*0.5, ev_by+textH*0.5) + end + elseif button.text == 'ptw' then + love.graphics.print("Points to Win: " .. ptw, smallfont,VIRTUAL_WIDTH*0.5 - textW * 1.5, ev_by+textH*0.5) + elseif (button.text == 'Silverblade') then + love.graphics.print("Difficulty: " .. prtext, smallfont, VIRTUAL_WIDTH*0.5 - textW , ev_by+textH*0.5) + else + love.graphics.print(button.text, smallfont, locationx - textW*0.5, ev_by+textH*0.5) + end + love.graphics.setColor(255, 255, 255, 255) + cursor_y = cursor_y + (ev_BUTTON_HEIGHT + margin) + end + end + end + end +function mainMenu:addButton(text, fn) + return { + text = text, + fn = fn, + now = false, + last = false + } +end +function menuButtons() + +local button_width = VIRTUAL_WIDTH * (1/3) +local BUTTON_HEIGHT = 50 +local margin = 16 +local hot = false +local cursor_y = 0 +local total_height = (BUTTON_HEIGHT + margin) * #buttons +for i, button in ipairs(buttons) do +button.last = button.now +local bx = (VIRTUAL_WIDTH*0.5) - (button_width * 0.5) +local by = (VIRTUAL_HEIGHT * 0.8) - (total_height * 0.5) + cursor_y +local color = {255, 255, 255, 255} +local mx, my = love.mouse.getPosition() +mx = mx * DIFFERENCE_X +my = my * DIFFERENCE_Y +hot = (mx > bx and mx < bx + button_width and my > by and my < by + BUTTON_HEIGHT) and i +if (hot == i) then + color = {10, 10, 0, 255} +end +button.now = love.keyboard.mouseWasReleased() +if button.now and not button.last and hot == i then + love.graphics.setColor(0,0,0,1) + love.graphics.rectangle("fill", 0, 0, VIRTUAL_WIDTH, VIRTUAL_HEIGHT) + sounds['wallhit']:play() + button.fn() +end +love.graphics.setColor(unpack(color)) +love.graphics.rectangle("fill", bx, by, button_width, BUTTON_HEIGHT) +love.graphics.setColor(0, 0, 0, 255) +local textW = smallfont:getWidth(button.text) +local textH = smallfont:getHeight(button.text) +love.graphics.print(button.text, smallfont, VIRTUAL_WIDTH*0.5 - textW*0.5, by+textH*0.5) +love.graphics.setColor(255, 255, 255, 255) +cursor_y = cursor_y + (BUTTON_HEIGHT + margin) + +end +end diff --git a/mmm.jpg b/mmm.jpg new file mode 100644 index 0000000..277edbb Binary files /dev/null and b/mmm.jpg differ diff --git a/music.lua b/music.lua new file mode 100644 index 0000000..c3171c0 --- /dev/null +++ b/music.lua @@ -0,0 +1,39 @@ +function musicController(orders, toggling) + if (orders == 'norm') then + if (gameState ~= 'play' and gameState ~= '1serve' and gameState ~= '2serve' and areanuclear == 0) then + sounds['gayTheme']:stop() + sounds['gayTheme2']:stop() + sounds['updateMusic']:play() + elseif (areanuclear == 1) then + sounds['gayTheme']:setVolume(0) + sounds['gayTheme2']:setVolume(0) + + elseif ((gameState == 'play' or gameState == '1serve' or gameState == '2serve') and player1score <= 7 and player2score <= 7 and areanuclear == 0) then + sounds['updateMusic']:stop() + sounds['gayTheme']:setPitch(1) + sounds['gayTheme']:setLooping(true) + sounds['gayTheme']:setVolume(0.5) + sounds['gayTheme']:play() + elseif gameState == 'play' and player1score > 7 or player2score > 7 and areanuclear == 0 then + sounds['gayTheme']:stop() + sounds['updateMusic']:stop() + sounds['gayTheme2']:setPitch(1) + sounds['gayTheme2']:setLooping(true) + sounds['gayTheme2']:setVolume(0.5) + sounds['gayTheme2']:play() + else + + end + elseif order ~= nil then + + sounds[orders]:setPitch(1) + sounds[orders]:setLooping(true) + sounds[orders]:setVolume(0.9) + sounds[orders]:play() + if (toggling == 1) then + sounds[orders]:setVolume(0.9) + else + sounds[orders]:setVolume(0) + end + end +end \ No newline at end of file diff --git a/paddle.lua b/paddle.lua new file mode 100644 index 0000000..fd36b0c --- /dev/null +++ b/paddle.lua @@ -0,0 +1,69 @@ +paddle = Class{} + +function paddle:init(x, y, width, height, player) + self.RED = 255 + self.GREEN = 255 + self.BLUE = 255 + self.x = x + self.y = y + self.width = width + self.height = height + self.dy = 0 + self.xy = x + self.yx = y + self.velocity = 0 + self.shadowbonus = 0 + self.player = player +end + +function paddle:update(dt) + if ((self.player == 1 and timeIsSlow2) or self.player == 2 and timeIsSlow) then + self.dy = self.dy / 2 + end + if (self.dy == 0) then + self.velocity = self.velocity / 1.1 + if (self.velocity < 1 and self.velocity > -1) then + self.velocity = 0 + end + else + self.velocity = self.velocity + self.dy*dt + end + if (self.velocity < 0) then + if (self.y > 0) then + self.y = self.y + self.velocity + else + self.velocity = 0 + end + elseif (self.velocity > 0) then + if (self.y < VIRTUAL_HEIGHT - 80) then + self.y = self.y + self.velocity + else + self.velocity = 0 + end + else + self.velocity = 0 + end + + if ((timeIsSlow == false and self.player == 1) or (timeIsSlow2 == false and self.player == 2)) then + if (math.abs(self.yx - self.y) < 11) then + self.yx = self.y + end + if (self.yx < self.y) then + self.yx = self.yx + math.abs(paddle_SPEED/1.7) + elseif (self.yx > self.y) then + self.yx = self.yx - math.abs(paddle_SPEED/1.7) + end +end + + +end + + + +function paddle:render() + love.graphics.setColor(self.RED, self.GREEN, self.BLUE, 60/255) + love.graphics.rectangle('fill', self.xy, self.yx, self.width, self.height, 20, 20) + love.graphics.setColor(self.RED, self.GREEN, self.BLUE, 255) + love.graphics.rectangle('fill', self.x, self.y, self.width, self.height, 20, 20) + love.graphics.setColor(255, 255, 255, 255) +end \ No newline at end of file diff --git a/push.lua b/push.lua new file mode 100644 index 0000000..5c94d9f --- /dev/null +++ b/push.lua @@ -0,0 +1,272 @@ +local love11 = love.getVersion() == 11 +local getDPI = love11 and love.window.getDPIScale or love.window.getPixelScale +local windowUpdateMode = love11 and love.window.updateMode or function(width, height, settings) + local _, _, flags = love.window.getMode() + for k, v in pairs(settings) do flags[k] = v end + love.window.setMode(width, height, flags) +end + +local push = { + + defaults = { + fullscreen = false, + resizable = false, + pixelperfect = false, + highdpi = true, + canvas = true, + stencil = true + } + +} +setmetatable(push, push) + +function push:applySettings(settings) + for k, v in pairs(settings) do + self["_" .. k] = v + end +end + +function push:resetSettings() return self:applySettings(self.defaults) end + +function push:setupScreen(WWIDTH, WHEIGHT, RWIDTH, RHEIGHT, settings) + + settings = settings or {} + + self._WWIDTH, self._WHEIGHT = WWIDTH, WHEIGHT + self._RWIDTH, self._RHEIGHT = RWIDTH, RHEIGHT + + self:applySettings(self.defaults) --set defaults first + self:applySettings(settings) --then fill with custom settings + + windowUpdateMode(self._RWIDTH, self._RHEIGHT, { + fullscreen = self._fullscreen, + resizable = self._resizable, + highdpi = self._highdpi + }) + + self:initValues() + + if self._canvas then + self:setupCanvas({ "default" }) --setup canvas + end + + self._borderColor = {0, 0, 0} + + self._drawFunctions = { + ["start"] = self.start, + ["end"] = self.finish + } + + return self +end + +function push:setupCanvas(canvases) + table.insert(canvases, { name = "_render", private = true }) --final render + + self._canvas = true + self.canvases = {} + + for i = 1, #canvases do + push:addCanvas(canvases[i]) + end + + return self +end +function push:addCanvas(params) + table.insert(self.canvases, { + name = params.name, + private = params.private, + shader = params.shader, + canvas = love.graphics.newCanvas(self._WWIDTH, self._WHEIGHT), + stencil = params.stencil or self._stencil + }) +end + +function push:setCanvas(name) + if not self._canvas then return true end + return love.graphics.setCanvas(self:getCanvasTable(name).canvas) +end +function push:getCanvasTable(name) + for i = 1, #self.canvases do + if self.canvases[i].name == name then + return self.canvases[i] + end + end +end +function push:setShader(name, shader) + if not shader then + self:getCanvasTable("_render").shader = name + else + self:getCanvasTable(name).shader = shader + end +end + +function push:initValues() + self._PSCALE = (not love11 and self._highdpi) and getDPI() or 1 + + self._SCALE = { + x = self._RWIDTH/self._WWIDTH * self._PSCALE, + y = self._RHEIGHT/self._WHEIGHT * self._PSCALE + } + + if self._stretched then --if stretched, no need to apply offset + self._OFFSET = {x = 0, y = 0} + else + local scale = math.min(self._SCALE.x, self._SCALE.y) + if self._pixelperfect then scale = math.floor(scale) end + + self._OFFSET = {x = (self._SCALE.x - scale) * (self._WWIDTH/2), y = (self._SCALE.y - scale) * (self._WHEIGHT/2)} + self._SCALE.x, self._SCALE.y = scale, scale --apply same scale to X and Y + end + + self._GWIDTH = self._RWIDTH * self._PSCALE - self._OFFSET.x * 2 + self._GHEIGHT = self._RHEIGHT * self._PSCALE - self._OFFSET.y * 2 +end + +function push:apply(operation, shader) + self._drawFunctions[operation](self, shader) +end + +function push:start() + if self._canvas then + love.graphics.push() + love.graphics.setCanvas({ self.canvases[1].canvas, stencil = self.canvases[1].stencil }) + + else + love.graphics.translate(self._OFFSET.x, self._OFFSET.y) + love.graphics.setScissor(self._OFFSET.x, self._OFFSET.y, self._WWIDTH*self._SCALE.x, self._WHEIGHT*self._SCALE.y) + love.graphics.push() + love.graphics.scale(self._SCALE.x, self._SCALE.y) + end +end + +function push:applyShaders(canvas, shaders) + local _shader = love.graphics.getShader() + if #shaders <= 1 then + love.graphics.setShader(shaders[1]) + love.graphics.draw(canvas) + else + local _canvas = love.graphics.getCanvas() + + local _tmp = self:getCanvasTable("_tmp") + if not _tmp then --create temp canvas only if needed + self:addCanvas({ name = "_tmp", private = true, shader = nil }) + _tmp = self:getCanvasTable("_tmp") + end + + love.graphics.push() + love.graphics.origin() + local outputCanvas + for i = 1, #shaders do + local inputCanvas = i % 2 == 1 and canvas or _tmp.canvas + outputCanvas = i % 2 == 0 and canvas or _tmp.canvas + love.graphics.setCanvas(outputCanvas) + love.graphics.clear() + love.graphics.setShader(shaders[i]) + love.graphics.draw(inputCanvas) + love.graphics.setCanvas(inputCanvas) + end + love.graphics.pop() + + love.graphics.setCanvas(_canvas) + love.graphics.draw(outputCanvas) + end + love.graphics.setShader(_shader) +end + +function push:finish(shader) + love.graphics.setBackgroundColor(unpack(self._borderColor)) + if self._canvas then + local _render = self:getCanvasTable("_render") + + love.graphics.pop() + + local white = love11 and 1 or 255 + love.graphics.setColor(white, white, white) + + --draw canvas + love.graphics.setCanvas(_render.canvas) + for i = 1, #self.canvases do --do not draw _render yet + local _table = self.canvases[i] + if not _table.private then + local _canvas = _table.canvas + local _shader = _table.shader + self:applyShaders(_canvas, type(_shader) == "table" and _shader or { _shader }) + end + end + love.graphics.setCanvas() + + --draw render + love.graphics.translate(self._OFFSET.x, self._OFFSET.y) + local shader = shader or _render.shader + love.graphics.push() + love.graphics.scale(self._SCALE.x, self._SCALE.y) + self:applyShaders(_render.canvas, type(shader) == "table" and shader or { shader }) + love.graphics.pop() + + --clear canvas + for i = 1, #self.canvases do + love.graphics.setCanvas(self.canvases[i].canvas) + love.graphics.clear() + end + + love.graphics.setCanvas() + love.graphics.setShader() + else + love.graphics.pop() + love.graphics.setScissor() + end +end + +function push:setBorderColor(color, g, b) + self._borderColor = g and {color, g, b} or color +end + +function push:toGame(x, y) + x, y = x - self._OFFSET.x, y - self._OFFSET.y + local normalX, normalY = x / self._GWIDTH, y / self._GHEIGHT + + x = (x >= 0 and x <= self._WWIDTH * self._SCALE.x) and normalX * self._WWIDTH or nil + y = (y >= 0 and y <= self._WHEIGHT * self._SCALE.y) and normalY * self._WHEIGHT or nil + + return x, y +end + +--doesn't work - TODO +function push:toReal(x, y) + return x + self._OFFSET.x, y + self._OFFSET.y +end + +function push:switchFullscreen(winw, winh) + self._fullscreen = not self._fullscreen + local windowWidth, windowHeight = love.window.getDesktopDimensions() + + if self._fullscreen then --save windowed dimensions for later + self._WINWIDTH, self._WINHEIGHT = self._RWIDTH, self._RHEIGHT + elseif not self._WINWIDTH or not self._WINHEIGHT then + self._WINWIDTH, self._WINHEIGHT = windowWidth * .5, windowHeight * .5 + end + + self._RWIDTH = self._fullscreen and windowWidth or winw or self._WINWIDTH + self._RHEIGHT = self._fullscreen and windowHeight or winh or self._WINHEIGHT + + self:initValues() + + love.window.setFullscreen(self._fullscreen, "desktop") + if not self._fullscreen and (winw or winh) then + windowUpdateMode(self._RWIDTH, self._RHEIGHT) --set window dimensions + end +end + +function push:resize(w, h) + if self._highdpi then w, h = w / self._PSCALE, h / self._PSCALE end + self._RWIDTH = w + self._RHEIGHT = h + self:initValues() +end + +function push:getWidth() return self._WWIDTH end +function push:getHeight() return self._WHEIGHT end +function push:getDimensions() return self._WWIDTH, self._WHEIGHT end + +return push \ No newline at end of file diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..e7f9a04 --- /dev/null +++ b/readme.md @@ -0,0 +1,26 @@ +

NuclearPong!

+Pong reimagined. Poorly reimagined. + +

The basics:

+

As easy as riding a bike

+
*if you can ride a bike
+
+
+

Default controls for player 1:

+
    +
  • [A] for up
  • +
  • [Z] for down
  • +
  • [S] while your counter says [S] and is white for a strong attack
  • +
  • [S] while your counter says [S] and is red to drop a NUKE
  • +
  • [X] while your counter says [X] to slow down time
  • +
+

Default controls for player 2:

+
    +
  • [;] for up
  • +
  • [.] for down
  • +
  • [L] while your counter says [L] and is white for a strong attack
  • +
  • [L] while your counter says [L] and is red to drop a NUKE
  • +
  • [,] while your counter says [,] to slow down time
  • +
+ +
\ No newline at end of file diff --git a/save.lua b/save.lua new file mode 100644 index 0000000..e69de29 diff --git a/ser.lua b/ser.lua new file mode 100644 index 0000000..0c6cc7b --- /dev/null +++ b/ser.lua @@ -0,0 +1,121 @@ +local pairs, ipairs, tostring, type, concat, dump, floor, format = pairs, ipairs, tostring, type, table.concat, string.dump, math.floor, string.format + +local function getchr(c) + return "\\" .. c:byte() +end + +local function make_safe(text) + return ("%q"):format(text):gsub('\n', 'n'):gsub("[\128-\255]", getchr) +end + +local oddvals = {[tostring(1/0)] = '1/0', [tostring(-1/0)] = '-1/0', [tostring(-(0/0))] = '-(0/0)', [tostring(0/0)] = '0/0'} +local function write(t, memo, rev_memo) + local ty = type(t) + if ty == 'number' then + t = format("%.17g", t) + return oddvals[t] or t + elseif ty == 'boolean' or ty == 'nil' then + return tostring(t) + elseif ty == 'string' then + return make_safe(t) + elseif ty == 'table' or ty == 'function' then + if not memo[t] then + local index = #rev_memo + 1 + memo[t] = index + rev_memo[index] = t + end + return '_[' .. memo[t] .. ']' + else + error("Trying to serialize unsupported type " .. ty) + end +end + +local kw = {['and'] = true, ['break'] = true, ['do'] = true, ['else'] = true, + ['elseif'] = true, ['end'] = true, ['false'] = true, ['for'] = true, + ['function'] = true, ['goto'] = true, ['if'] = true, ['in'] = true, + ['local'] = true, ['nil'] = true, ['not'] = true, ['or'] = true, + ['repeat'] = true, ['return'] = true, ['then'] = true, ['true'] = true, + ['until'] = true, ['while'] = true} +local function write_key_value_pair(k, v, memo, rev_memo, name) + if type(k) == 'string' and k:match '^[_%a][_%w]*$' and not kw[k] then + return (name and name .. '.' or '') .. k ..'=' .. write(v, memo, rev_memo) + else + return (name or '') .. '[' .. write(k, memo, rev_memo) .. ']=' .. write(v, memo, rev_memo) + end +end + +-- fun fact: this function is not perfect +-- it has a few false positives sometimes +-- but no false negatives, so that's good +local function is_cyclic(memo, sub, super) + local m = memo[sub] + local p = memo[super] + return m and p and m < p +end + +local function write_table_ex(t, memo, rev_memo, srefs, name) + if type(t) == 'function' then + return '_[' .. name .. ']=loadstring' .. make_safe(dump(t)) + end + local m = {} + local mi = 1 + for i = 1, #t do -- don't use ipairs here, we need the gaps + local v = t[i] + if v == t or is_cyclic(memo, v, t) then + srefs[#srefs + 1] = {name, i, v} + m[mi] = 'nil' + mi = mi + 1 + else + m[mi] = write(v, memo, rev_memo) + mi = mi + 1 + end + end + for k,v in pairs(t) do + if type(k) ~= 'number' or floor(k) ~= k or k < 1 or k > #t then + if v == t or k == t or is_cyclic(memo, v, t) or is_cyclic(memo, k, t) then + srefs[#srefs + 1] = {name, k, v} + else + m[mi] = write_key_value_pair(k, v, memo, rev_memo) + mi = mi + 1 + end + end + end + return '_[' .. name .. ']={' .. concat(m, ',') .. '}' +end + +return function(t) + local memo = {[t] = 0} + local rev_memo = {[0] = t} + local srefs = {} + local result = {} + + -- phase 1: recursively descend the table structure + local n = 0 + while rev_memo[n] do + result[n + 1] = write_table_ex(rev_memo[n], memo, rev_memo, srefs, n) + n = n + 1 + end + + -- phase 2: reverse order + for i = 1, n*.5 do + local j = n - i + 1 + result[i], result[j] = result[j], result[i] + end + + -- phase 3: add all the tricky cyclic stuff + for i, v in ipairs(srefs) do + n = n + 1 + result[n] = write_key_value_pair(v[2], v[3], memo, rev_memo, '_[' .. v[1] .. ']') + end + + -- phase 4: add something about returning the main table + if result[n]:sub(1, 5) == '_[0]=' then + result[n] = 'return ' .. result[n]:sub(6) + else + result[n + 1] = 'return _[0]' + end + + -- phase 5: just concatenate everything + result = concat(result, '\n') + return n > 1 and 'local _={}\n' .. result or result +end diff --git a/simpleScale.lua b/simpleScale.lua new file mode 100644 index 0000000..c417843 --- /dev/null +++ b/simpleScale.lua @@ -0,0 +1,123 @@ +simpleScale = {} +--Your Game's Aspect Ratio +local gAspectRatio +--The Window's Aspect Ratio +local wAspectRatio +--The scale between the game and the window's aspect ratio +simpleScale.scale = 1 + +local xt, yt = 0, 0, 1 +local gameW, gameH, windowW, windowH = 800, 600, 800, 600 + +-- Declares your game's width and height, and sets the window size/settings +-- To be used instead of love.window.setMode +-- [gw] and [gh] are the width and height of the initial game +-- [sw] and [sh] (optional) are the width and height of the final window +-- [settings] (optional) are settings for love.window.setMode +function simpleScale.setWindow(gw, gh, sw, sh, settings) + sw = sw or gw + sh = sh or gh + gAspectRatio = gw/gh + gameW = gw + gameH = gh + simpleScale.updateWindow(sw, sh, settings) +end + +-- Updates the Window size/settings +-- To be used instead of love.window.setMode +-- [sw] and [sh] are the width and height of the new Window +-- [settings] (optional) are settings for love.window.setMode +function simpleScale.updateWindow(sw, sh, settings) + love.window.setMode(sw, sh, settings) + windowW, windowH = love.graphics.getWidth(), love.graphics.getHeight() + wAspectRatio = windowW/windowH + + --Window aspect ratio is TALLER than game + if gAspectRatio > wAspectRatio then + scale = windowW/gameW + xt = 0 + yt = windowH/2 - (scale*gameH)/2 + + --Window aspect ratio is WIDER than game + elseif gAspectRatio < wAspectRatio then + scale = windowH/gameH + xt = windowW/2 - (scale*gameW)/2 + yt = 0 + + --Window and game aspect ratios are EQUAL + else + scale = windowW/gameW + + xt = 0 + yt = 0 + end + simpleScale.scale = scale +end + +-- If you screen is resizable on drag, you'll need to call this to make sure +-- the appropriate screen values stay updated +-- You can call it on love.update() with no trouble +function simpleScale.resizeUpdate() + windowW, windowH = love.graphics.getWidth(), love.graphics.getHeight() + wAspectRatio = windowW/windowH + + --Window aspect ratio is TALLER than game + if gAspectRatio > wAspectRatio then + scale = windowW/gameW + xt = 0 + yt = windowH/2 - (scale*gameH)/2 + + --Window aspect ratio is WIDER than game + elseif gAspectRatio < wAspectRatio then + scale = windowH/gameH + xt = windowW/2 - (scale*gameW)/2 + yt = 0 + + --Window and game aspect ratios are EQUAL + else + scale = windowW/gameW + + xt = 0 + yt = 0 + end + simpleScale.scale = scale +end + +-- Transforms the game's window relative to the entire window +-- Call this at the beginning of love.draw() +function simpleScale.set() + love.graphics.push() + love.graphics.translate(xt, yt) + love.graphics.scale(scale, scale) +end + +-- Untransforms the game's window +-- Call this at the end of love.draw +-- You can optionally make the letterboxes a specific color by passing +-- [color] (optional) a table of color values +function simpleScale.unSet(color) + love.graphics.scale(1/scale, 1/scale) + love.graphics.translate(-xt, -yt) + love.graphics.pop() + + --Draw the Letterboxes + local r,g,b,a = love.graphics.getColor() + local originalColor = love.graphics.getColor() + local boxColor + if color == nil then + boxColor = {0,0,0} + else + boxColor = color + end + love.graphics.setColor(boxColor) + --Horizontal bars + if gAspectRatio > wAspectRatio then + love.graphics.rectangle("fill", 0, 0, windowW, math.abs((gameH*scale - (windowH))/2)) + love.graphics.rectangle("fill", 0, windowH, windowW, -math.abs((gameH*scale - (windowH))/2)) + --Vertical bars + elseif gAspectRatio < wAspectRatio then + love.graphics.rectangle("fill", 0, 0, math.abs((gameW*scale - (windowW))/2),windowH) + love.graphics.rectangle("fill", windowW, 0, -math.abs((gameW*scale - (windowW))/2),windowH) + end + love.graphics.setColor(r,g,b,a) +end \ No newline at end of file diff --git a/superPowerControl.lua b/superPowerControl.lua new file mode 100644 index 0000000..8f3e2b9 --- /dev/null +++ b/superPowerControl.lua @@ -0,0 +1,8 @@ +function powerControl(initiate, type) + if initiate == 1 and type == 'special' then + sounds["time"]:play() player1reverbav = false timeIsSlow = true originalSpeed = ballSpeed originalPaddle = paddle_SPEED player1reverbav = 0 potentialnuke1 = 0 potentialstrike1 = 0 + end +end +function powerUpdate() + +end \ No newline at end of file diff --git a/win.wav b/win.wav new file mode 100644 index 0000000..b8af816 Binary files /dev/null and b/win.wav differ