diff --git a/TSerial.lua b/TSerial.lua deleted file mode 100644 index 4ca5da4..0000000 --- a/TSerial.lua +++ /dev/null @@ -1,46 +0,0 @@ ---- 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/animator.lua b/animator.lua index acf4958..e591424 100644 --- a/animator.lua +++ b/animator.lua @@ -17,6 +17,7 @@ function superanimator(type, param) end end function staticanimatorcounter(dt) + backgroundScroll = (backgroundScroll + background_scroll_speed * dt) % background_looping_point if (gameState == 'animation') then time_1 = time_1 + dt light = 255 - time_1 * 85 @@ -50,7 +51,7 @@ function staticanimatorcounter(dt) end end if player1animend then - --print("DISEffect range: " .. diseffectRange[0]) + print("DISEffect range: " .. diseffectRange[0]) diseffectRange[0] = diseffectRange[0] + dt*24 if diseffectRange[0] > 50 then effectRange[0] = 0 @@ -67,7 +68,7 @@ function staticanimatorcounter(dt) end end if player2animend then - --print("DISEffect range: " .. diseffectRange[1]) + print("DISEffect range: " .. diseffectRange[1]) diseffectRange[1] = diseffectRange[1] + dt*24 if diseffectRange[1] > 50 then effectRange[1] = 0 @@ -78,22 +79,15 @@ function staticanimatorcounter(dt) end end function staticanimator() - if player1anim then - love.graphics.setColor(140/255,70/255,70/255,1) + if player1anim or player1animend then + love.graphics.setColor(140/255,70/255,70/255,(50-diseffectRange[0])/100) love.graphics.circle("fill", player1.x, player1.y , effectRange[0]*100, 100) end - if player1animend then - love.graphics.setColor(40/255,40/255,40/255,1) - love.graphics.circle("fill", player1.x, player1.y , diseffectRange[0]*100, 100) - end - if player2anim then - love.graphics.setColor(70/255,70/255,140/255,1) + if player2anim or player2animend then + love.graphics.setColor(70/255,70/255,140/255,(50-diseffectRange[1])/100) love.graphics.circle("fill", player2.x, player2.y , effectRange[1]*100, 100) end - if player2animend then - love.graphics.setColor(40/255,40/255,40/255,1) - love.graphics.circle("fill", player2.x, player2.y , diseffectRange[1]*100, 100) - end + end function animateExplosion(x, y, v, color) love.graphics.setColor(color) diff --git a/eball.lua b/eball.lua index a291c62..34215fb 100644 --- a/eball.lua +++ b/eball.lua @@ -14,8 +14,6 @@ function eball:init(x, y, width, height) 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 @@ -25,7 +23,6 @@ function eball:collides(paddle) end return true end -end function eball:reset(ballnum, player) if (gameMode == 'practice') then if (self.x < 1) then diff --git a/gifload.lua b/gifload.lua new file mode 100644 index 0000000..28a35c7 --- /dev/null +++ b/gifload.lua @@ -0,0 +1,519 @@ +--[===================================================================[-- + Copyright © 2016, 2018 Pedro Gimeno Fortea. All rights reserved. + + Permission is hereby granted to everyone to copy and use this file, + for any purpose, in whole or in part, free of charge, provided this + single condition is met: The above copyright notice, together with + this permission grant and the disclaimer below, should be included + in all copies of this software or of a substantial portion of it. + + THIS SOFTWARE COMES WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. +--]===================================================================]-- + +-- GIF(sm) image decoder for the love2d framework, using LuaJIT + FFI. +-- Includes LZW decompression. + + +local ffi = require 'ffi' +local bit = require 'bit' + +-- We have a "double buffer" coroutine-based consumer-producer system +-- requiring the consumer to not request large chunks at a time +-- otherwise the buffer would overflow (this is detected but it will +-- cause an assertion error). + +local bytearray = ffi.typeof('uint8_t[?]') +local intarray = ffi.typeof('int[?]') +local int32ptr = ffi.typeof('int32_t *') + +-- Interlaced mode table. Format: +-- {initial value for pass 1, increment for pass 1, +-- initial value for pass 2, increment for pass 2, ...} +local intertable = {0, 8, 4, 8, 2, 4, 1, 2, false} + +-- Utility function for error propagation +local function coresume(co, ...) + local ok, err = coroutine.resume(co, ...) + if not ok then + error(err) + end +end + +-- Consumer +local function gifread(self, length) + while self.ptr + length >= self.buflen do + coroutine.yield() -- wait for more input + end + local tmp = self.ptr + self.ptr = self.ptr + length + if tmp >= 24576 then -- this leaves 8192 as max read length (768 would probably suffice) + ffi.copy(self.buffer, self.buffer + tmp, self.buflen - tmp) + self.buflen = self.buflen - tmp + self.ptr = self.ptr - tmp + tmp = 0 + end + return tmp, length +end + +-- Producer - prepare the data for the consumer +local function gifupdate(self, s) + if #s > 32768 then + -- Creating a Lua string object is an expensive operation. + -- Do it as seldom as possible. We split the input data + -- into 32K chunks. + for i = 1, #s, 32768 do + gifupdate(self, s:sub(i, i + 32767)) + end + return + end + + if coroutine.status(self.decoder) == "dead" then + -- feeding data after the decoding is finished, ignore + return + end + assert(self.buflen <= 32768, "Buffer overflow") + + ffi.copy(self.buffer + self.buflen, s, #s) + self.buflen = self.buflen + #s + coresume(self.decoder) + return self +end + +local function gifdone(self) + -- free C memory immediately + self.buffer = false + return self +end + +local function giferr(self, msg) + print(msg) +end + +-- Gif decoding aux functions +local function gifpalette(palette, source, psize) + -- Read a palette, inserting alpha + for i = 0, psize - 1 do + palette[i*4] = source[i*3] + palette[i*4 + 1] = source[i*3 + 1] + palette[i*4 + 2] = source[i*3 + 2] + palette[i*4 + 3] = 255 + end +end + +-- Gif decoder proper +local function gifdecoder(self) + -- Read file ID and header + local buffer = self.buffer + gifread(self, 13) + if ffi.string(self.buffer, 6) ~= 'GIF87a' + and ffi.string(self.buffer, 6) ~= 'GIF89a' + then + self:err('Invalid GIF file format') + return + end + self.width = buffer[6] + 256*buffer[7] + self.height = buffer[8] + 256*buffer[9] + local gpalettesize = buffer[10] >= 128 and bit.lshift(1, bit.band(buffer[10], 7) + 1) or 0 + local background = buffer[11] + self.aspect = ((buffer[12] == 0 and 49 or 0) + 15) / 64 + + local gpalette = bytearray(256*4) + local lpalette = bytearray(256*4) + local lpalettesize + -- Read palette and set background + self.background = background -- default value + if gpalettesize > 0 then + gifread(self, gpalettesize * 3) + gifpalette(gpalette, buffer + 13, gpalettesize) + + if background < gpalettesize then + self.background = {gpalette[background*4], gpalette[background*4+1], gpalette[background*4+2]} + end + end + + local p + local GCE_trans = false + local GCE_dispose = 0 + local GCE_delay = 0 + + -- Allocate the buffers in advance, to reuse them for every frame + local dict = bytearray(4096) + local dictptrs = intarray(4096) + local reversebuf = bytearray(4096) + + repeat + -- Get block type + p = gifread(self, 1) + local blocktype = 0x3B + local blocklen + -- for simplicity (?), we fuse the block type and the extension type into + -- 'blocktype' + if buffer[p] == 0x2C then + -- Image block + blocktype = 0x2C + elseif buffer[p] == 0x21 then + -- Extension block + p = gifread(self, 1) + blocktype = buffer[p] + if blocktype == 0x2C then + -- there's no extension 2C - terminate + -- (avoids ambiguity with block type 2C) + blocktype = 0x3B + end + elseif buffer[p] ~= 0x3B then + self:err(string.format("Unknown block type: 0x%02X", buffer[p])) + break + end + + if blocktype == 0x3B then + -- Trailer block or invalid block - terminate + break + + elseif blocktype == 0xFF then + -- Application extension - may be loop, otherwise skip + p = gifread(self, 1) + blocklen = buffer[p] + p = gifread(self, blocklen + 1) + if blocklen >= 11 and ffi.string(buffer + p, 11) == 'NETSCAPE2.0' then + -- these *are* the androids we're looking for + p = p + blocklen + while buffer[p] ~= 0 do + local sblen = buffer[p] + p = gifread(self, sblen + 1) -- read also the next block length + if buffer[p] == 1 and sblen >= 3 then + -- looping subblock - that's for us + self.loop = buffer[p + 1] + 256 * buffer[p + 2] + end + p = p + sblen -- advance to next block + end + else + -- skip entire block + p = p + blocklen + while buffer[p] ~= 0 do + gifread(self, buffer[p]) + p = gifread(self, 1) + end + end + + elseif blocktype == 0x01 or blocktype == 0xFE then + -- Text or Comment Extension - not processed by us, skip + p = gifread(self, 1) -- read length + if blocktype < 0x01 then + -- skip the block header (contains a length field) + p = gifread(self, buffer[p] + 1) + buffer[p] + + -- the text extension "consumes" the GCE, so we clear it + GCE_trans = false + GCE_dispose = 0 + GCE_delay = 0 + end + while buffer[p] ~= 0 do + p = gifread(self, buffer[p] + 1) + buffer[p] + end + + elseif blocktype == 0xF9 then + -- Graphic Control Extension + p = gifread(self, 1) + blocklen = buffer[p] + p = gifread(self, blocklen + 1) + if blocklen >= 4 then + GCE_delay = (buffer[p+1] + 256 * buffer[p+2]) / 100 + GCE_trans = bit.band(buffer[p], 1) ~= 0 and buffer[p + 3] + GCE_dispose = bit.rshift(bit.band(buffer[p], 0x1C), 2) + end + p = p + blocklen + while buffer[p] ~= 0 do + p = gifread(self, buffer[p] + 1) + buffer[p] + end + elseif blocktype == 0x2C then + -- Here be dragons + p = gifread(self, 9) + + local x, y = buffer[p] + 256*buffer[p+1], buffer[p+2] + 256*buffer[p+3] + local w, h = buffer[p+4] + 256*buffer[p+5], buffer[p+6] + 256*buffer[p+7] + if w == 0 or h == 0 then + self:err('Zero size image') + break + end + local img = love.image.newImageData(w, h) + local dataptr = ffi.cast(int32ptr, img:getPointer()) + self.imgs[#self.imgs + 1] = GCE_dispose + self.imgs[#self.imgs + 1] = GCE_delay + self.imgs[#self.imgs + 1] = img + self.imgs[#self.imgs + 1] = x + self.imgs[#self.imgs + 1] = y + self.nimages = self.nimages + 1 + + local flags = buffer[p+8] + if flags >= 128 then + -- Has local palette + lpalettesize = bit.lshift(1, bit.band(flags, 7) + 1) + p = gifread(self, lpalettesize*3) + gifpalette(lpalette, buffer + p, lpalettesize) + else + -- No local palette - copy the global palette to the local one + ffi.copy(lpalette, gpalette, gpalettesize*4) + lpalettesize = gpalettesize + end + if GCE_trans and GCE_trans < lpalettesize then + -- Clear alpha + lpalette[GCE_trans*4 + 3] = 0 + end + local interlace = bit.band(flags, 64) ~= 0 and 1 + + -- LZW decoder. + + -- This could really use another coroutine for + -- simplicity, as there's another producer/consumer, + -- but we won't go there. + + p = gifread(self, 2) + local LZWsize = buffer[p] + p = p + 1 + if LZWsize == 0 or LZWsize > 11 then + self:err("Invalid code size") + break + end + local codebits = LZWsize + 1 + local clearcode = bit.lshift(1, LZWsize) -- End-of-stream is always clearcode+1 + local dictlen = clearcode + 2 + + local bitstream, bitlen = 0, 0 + x, y = 0, 0 + local nextlenptr = p + local oldcode + local walkcode + + local nrows = 0 -- counts vertical rows, used because interlacing makes the last y invalid + local row = 0 + + repeat + -- Are there enough bits in curcode? Do we need to read more data? + if bitlen >= codebits and y then + -- Extract next code + local code = bit.band(bitstream, bit.lshift(1, codebits) - 1) + bitstream = bit.rshift(bitstream, codebits) + bitlen = bitlen - codebits + + if code == clearcode then + codebits = LZWsize + 1 + dictlen = clearcode + 2 + oldcode = false + elseif code == clearcode + 1 then + if x ~= 0 or nrows ~= h then + self:err("Soft EOD before all rows were output") + end + -- signal end of processing + -- (further data won't be read, but we need to follow the blocks) + y = false + else + -- The dictionary is stored as a list of back pointers. + -- We need to reverse the order to output the entries. + -- We use a reverse buffer for that. + local reverseptr = 4095 + -- Is this code already in the table? + if code < dictlen then + -- Already in the table - get the string from the table + walkcode = code + while walkcode >= clearcode do + reversebuf[reverseptr] = dict[walkcode] + reverseptr = reverseptr - 1 + walkcode = dictptrs[walkcode] + end + reversebuf[reverseptr] = walkcode + -- Add to the table + if oldcode then + if dictlen < 4096 then + dictptrs[dictlen] = oldcode + dict[dictlen] = walkcode + dictlen = dictlen + 1 + if dictlen ~= 4096 and bit.band(dictlen, dictlen - 1) == 0 then + -- perfect power of two - increase code size + codebits = codebits + 1 + end + end + end + oldcode = code + else + -- Not in the table - deal with the special case + -- The compressor has created a new code, which must be the next + -- in sequence. We know what it must contain. + -- It must contain oldcode + first character of oldcode. + if code > dictlen or not oldcode or not walkcode then + self:err("Broken LZW") + break + end + + -- Add to the table + if oldcode then + if dictlen < 4096 then + dictptrs[dictlen] = oldcode + dict[dictlen] = walkcode + dictlen = dictlen + 1 + if dictlen ~= 4096 and bit.band(dictlen, dictlen - 1) == 0 then + -- perfect power of two - increase code size + codebits = codebits + 1 + end + end + end + oldcode = code + walkcode = oldcode + + while walkcode >= clearcode do + reversebuf[reverseptr] = dict[walkcode] + reverseptr = reverseptr - 1 + walkcode = dictptrs[walkcode] + end + reversebuf[reverseptr] = walkcode + end + + if y then + for i = reverseptr, 4095 do + local c = reversebuf[i] + if c >= lpalettesize then c = 0 end + c = ffi.cast(int32ptr, lpalette)[c] + dataptr[x + row] = c + if interlace then + -- The passes 1, 2, 3, 4 correspond to the + -- values 1, 3, 5, 7 of 'interlace'. + if self.progressive and interlace < 7 and y + 1 < h then + -- In any pass but the last, there are at least 2 lines. + dataptr[x + row + w] = c + if interlace < 5 and y + 2 < h then + -- In the first two passes, there are at least 4 lines. + dataptr[x + row + w*2] = c + if y + 3 < h then + dataptr[x + row + w*3] = c + if interlace < 3 and y + 4 < h then + -- In the first pass there are 8 lines. + dataptr[x + row + w*4] = c + if y + 5 < h then + dataptr[x + row + w*5] = c + if y + 6 < h then + dataptr[x + row + w*6] = c + if y + 7 < h then + dataptr[x + row + w*7] = c + end + end + end + end + end + end + end + -- Advance pixel + x = x + 1 + if x >= w then + -- Skip to next interlaced row + x = 0 + nrows = nrows + 1 + y = y + intertable[interlace + 1] + if y >= h then + interlace = interlace + 2 + if interlace > 7 then + y = false + else + y = intertable[interlace] + end + end + if y then + row = y * w + end + end + else + -- No interlace, just increment y + x = x + 1 + if x >= w then + x = 0 + y = y + 1 + nrows = y + if y >= h then + y = false + else + row = y * w + end + end + end + end + + else + -- This should not happen. + self:err('Data past the end of the image') + end + end + else + -- Not enough bits, grab 8 more + if p >= nextlenptr then + -- End of this subblock - read next subblock + assert(p == nextlenptr) + local sblen = buffer[nextlenptr] + + if sblen == 0 then + -- no more data + if y then + self:err("Hard EOD before the end of the image") + end + break + end + p = gifread(self, sblen + 1) + nextlenptr = p + sblen + end + if y then + bitstream = bitstream + bit.lshift(buffer[p], bitlen) + bitlen = bitlen + 8 + p = p + 1 + else + -- end of data - fast forward to end of block + p = nextlenptr + end + end + + until false + + GCE_trans = false + GCE_dispose = 0 + GCE_delay = 0 + self.ncomplete = self.nimages + + else + break + end + until false + +end + +local function gifframe(self, n) + n = (n-1) % self.nimages + 1 + return self.imgs[n*5-2], self.imgs[n*5-1], self.imgs[n*5], self.imgs[n*5-3], self.imgs[n*5-4] +end + +local function gifnew(retver) + if retver == "version" then + return 0x010002 + -- else just ignore it and create the object + end + + local self = { + update = gifupdate; + done = gifdone; + frame = gifframe; + err = giferr; + background = false; + width = false; + height = false; + imgs = {}; + nimages = 0; + ncomplete = 0; + buffer = bytearray(65536); + buflen = 0; + ptr = 0; + progressive = false; + loop = false; + aspect = false; + decoder = coroutine.create(gifdecoder); + } + -- pass self to the coroutine (will return immediately for lack of data) + coresume(self.decoder, self) + return self +end + +return gifnew \ No newline at end of file diff --git a/img/SPC/Engine Thrusters/diagonal-thrust-01.png b/img/SPC/Engine Thrusters/diagonal-thrust-01.png new file mode 100644 index 0000000..3189f88 Binary files /dev/null and b/img/SPC/Engine Thrusters/diagonal-thrust-01.png differ diff --git a/img/SPC/Engine Thrusters/diagonal-thrust-02.png b/img/SPC/Engine Thrusters/diagonal-thrust-02.png new file mode 100644 index 0000000..8893003 Binary files /dev/null and b/img/SPC/Engine Thrusters/diagonal-thrust-02.png differ diff --git a/img/SPC/Engine Thrusters/diagonal-thrust-03.png b/img/SPC/Engine Thrusters/diagonal-thrust-03.png new file mode 100644 index 0000000..bc95aa1 Binary files /dev/null and b/img/SPC/Engine Thrusters/diagonal-thrust-03.png differ diff --git a/img/SPC/Engine Thrusters/diagonal-thrust-04.png b/img/SPC/Engine Thrusters/diagonal-thrust-04.png new file mode 100644 index 0000000..9b39010 Binary files /dev/null and b/img/SPC/Engine Thrusters/diagonal-thrust-04.png differ diff --git a/img/SPC/Engine Thrusters/vertical-thrust-01.png b/img/SPC/Engine Thrusters/vertical-thrust-01.png new file mode 100644 index 0000000..4587b49 Binary files /dev/null and b/img/SPC/Engine Thrusters/vertical-thrust-01.png differ diff --git a/img/SPC/Engine Thrusters/vertical-thrust-02.png b/img/SPC/Engine Thrusters/vertical-thrust-02.png new file mode 100644 index 0000000..b46abf8 Binary files /dev/null and b/img/SPC/Engine Thrusters/vertical-thrust-02.png differ diff --git a/img/SPC/Engine Thrusters/vertical-thrust-03.png b/img/SPC/Engine Thrusters/vertical-thrust-03.png new file mode 100644 index 0000000..8eaf0f1 Binary files /dev/null and b/img/SPC/Engine Thrusters/vertical-thrust-03.png differ diff --git a/img/SPC/Engine Thrusters/vertical-thrust-04.png b/img/SPC/Engine Thrusters/vertical-thrust-04.png new file mode 100644 index 0000000..eca32dd Binary files /dev/null and b/img/SPC/Engine Thrusters/vertical-thrust-04.png differ diff --git a/img/SPC/Explosion/explosion-1.png b/img/SPC/Explosion/explosion-1.png new file mode 100644 index 0000000..0b7b2d7 Binary files /dev/null and b/img/SPC/Explosion/explosion-1.png differ diff --git a/img/SPC/Explosion/explosion-10.png b/img/SPC/Explosion/explosion-10.png new file mode 100644 index 0000000..e22683d Binary files /dev/null and b/img/SPC/Explosion/explosion-10.png differ diff --git a/img/SPC/Explosion/explosion-11.png b/img/SPC/Explosion/explosion-11.png new file mode 100644 index 0000000..46e2784 Binary files /dev/null and b/img/SPC/Explosion/explosion-11.png differ diff --git a/img/SPC/Explosion/explosion-2.png b/img/SPC/Explosion/explosion-2.png new file mode 100644 index 0000000..5df7b2d Binary files /dev/null and b/img/SPC/Explosion/explosion-2.png differ diff --git a/img/SPC/Explosion/explosion-3.png b/img/SPC/Explosion/explosion-3.png new file mode 100644 index 0000000..09360a7 Binary files /dev/null and b/img/SPC/Explosion/explosion-3.png differ diff --git a/img/SPC/Explosion/explosion-4.png b/img/SPC/Explosion/explosion-4.png new file mode 100644 index 0000000..3d8803d Binary files /dev/null and b/img/SPC/Explosion/explosion-4.png differ diff --git a/img/SPC/Explosion/explosion-5.png b/img/SPC/Explosion/explosion-5.png new file mode 100644 index 0000000..d2cfd75 Binary files /dev/null and b/img/SPC/Explosion/explosion-5.png differ diff --git a/img/SPC/Explosion/explosion-6.png b/img/SPC/Explosion/explosion-6.png new file mode 100644 index 0000000..42547db Binary files /dev/null and b/img/SPC/Explosion/explosion-6.png differ diff --git a/img/SPC/Explosion/explosion-7.png b/img/SPC/Explosion/explosion-7.png new file mode 100644 index 0000000..f13265a Binary files /dev/null and b/img/SPC/Explosion/explosion-7.png differ diff --git a/img/SPC/Explosion/explosion-8.png b/img/SPC/Explosion/explosion-8.png new file mode 100644 index 0000000..80a3a4a Binary files /dev/null and b/img/SPC/Explosion/explosion-8.png differ diff --git a/img/SPC/Explosion/explosion-9.png b/img/SPC/Explosion/explosion-9.png new file mode 100644 index 0000000..5d839a3 Binary files /dev/null and b/img/SPC/Explosion/explosion-9.png differ diff --git a/img/SPC/Projectiles/missile-01.png b/img/SPC/Projectiles/missile-01.png new file mode 100644 index 0000000..b715133 Binary files /dev/null and b/img/SPC/Projectiles/missile-01.png differ diff --git a/img/SPC/Projectiles/missile-02.png b/img/SPC/Projectiles/missile-02.png new file mode 100644 index 0000000..8fa0e05 Binary files /dev/null and b/img/SPC/Projectiles/missile-02.png differ diff --git a/img/SPC/Projectiles/projectile-blue.png b/img/SPC/Projectiles/projectile-blue.png new file mode 100644 index 0000000..8a2ceea Binary files /dev/null and b/img/SPC/Projectiles/projectile-blue.png differ diff --git a/img/SPC/Projectiles/projectile-green.png b/img/SPC/Projectiles/projectile-green.png new file mode 100644 index 0000000..3df2af7 Binary files /dev/null and b/img/SPC/Projectiles/projectile-green.png differ diff --git a/img/SPC/Projectiles/projectile-orange.png b/img/SPC/Projectiles/projectile-orange.png new file mode 100644 index 0000000..0fb4b8b Binary files /dev/null and b/img/SPC/Projectiles/projectile-orange.png differ diff --git a/img/SPC/Projectiles/projectile-red.png b/img/SPC/Projectiles/projectile-red.png new file mode 100644 index 0000000..11e00d0 Binary files /dev/null and b/img/SPC/Projectiles/projectile-red.png differ diff --git a/img/SPC/_pixel_spaceships_for_shmup_1.4.psd b/img/SPC/_pixel_spaceships_for_shmup_1.4.psd new file mode 100644 index 0000000..be52be4 Binary files /dev/null and b/img/SPC/_pixel_spaceships_for_shmup_1.4.psd differ diff --git a/img/SPC/blue_01.png b/img/SPC/blue_01.png new file mode 100644 index 0000000..d97955d Binary files /dev/null and b/img/SPC/blue_01.png differ diff --git a/img/SPC/blue_02.png b/img/SPC/blue_02.png new file mode 100644 index 0000000..acaacdc Binary files /dev/null and b/img/SPC/blue_02.png differ diff --git a/img/SPC/blue_03.png b/img/SPC/blue_03.png new file mode 100644 index 0000000..fc8373f Binary files /dev/null and b/img/SPC/blue_03.png differ diff --git a/img/SPC/blue_04.png b/img/SPC/blue_04.png new file mode 100644 index 0000000..792e486 Binary files /dev/null and b/img/SPC/blue_04.png differ diff --git a/img/SPC/blue_05.png b/img/SPC/blue_05.png new file mode 100644 index 0000000..511533f Binary files /dev/null and b/img/SPC/blue_05.png differ diff --git a/img/SPC/blue_06.png b/img/SPC/blue_06.png new file mode 100644 index 0000000..9c3e953 Binary files /dev/null and b/img/SPC/blue_06.png differ diff --git a/img/SPC/darkgrey_01.png b/img/SPC/darkgrey_01.png new file mode 100644 index 0000000..e97606d Binary files /dev/null and b/img/SPC/darkgrey_01.png differ diff --git a/img/SPC/darkgrey_02.png b/img/SPC/darkgrey_02.png new file mode 100644 index 0000000..70a59bf Binary files /dev/null and b/img/SPC/darkgrey_02.png differ diff --git a/img/SPC/darkgrey_03.png b/img/SPC/darkgrey_03.png new file mode 100644 index 0000000..6981cf7 Binary files /dev/null and b/img/SPC/darkgrey_03.png differ diff --git a/img/SPC/darkgrey_04.png b/img/SPC/darkgrey_04.png new file mode 100644 index 0000000..6e90225 Binary files /dev/null and b/img/SPC/darkgrey_04.png differ diff --git a/img/SPC/darkgrey_05.png b/img/SPC/darkgrey_05.png new file mode 100644 index 0000000..e3ca544 Binary files /dev/null and b/img/SPC/darkgrey_05.png differ diff --git a/img/SPC/darkgrey_06.png b/img/SPC/darkgrey_06.png new file mode 100644 index 0000000..d57517d Binary files /dev/null and b/img/SPC/darkgrey_06.png differ diff --git a/img/SPC/green_01.png b/img/SPC/green_01.png new file mode 100644 index 0000000..7d20878 Binary files /dev/null and b/img/SPC/green_01.png differ diff --git a/img/SPC/green_02.png b/img/SPC/green_02.png new file mode 100644 index 0000000..1272a84 Binary files /dev/null and b/img/SPC/green_02.png differ diff --git a/img/SPC/green_03.png b/img/SPC/green_03.png new file mode 100644 index 0000000..4a21c55 Binary files /dev/null and b/img/SPC/green_03.png differ diff --git a/img/SPC/green_04.png b/img/SPC/green_04.png new file mode 100644 index 0000000..368782b Binary files /dev/null and b/img/SPC/green_04.png differ diff --git a/img/SPC/green_05.png b/img/SPC/green_05.png new file mode 100644 index 0000000..5aa6107 Binary files /dev/null and b/img/SPC/green_05.png differ diff --git a/img/SPC/green_06.png b/img/SPC/green_06.png new file mode 100644 index 0000000..317a019 Binary files /dev/null and b/img/SPC/green_06.png differ diff --git a/img/SPC/large_blue_01.png b/img/SPC/large_blue_01.png new file mode 100644 index 0000000..55d2943 Binary files /dev/null and b/img/SPC/large_blue_01.png differ diff --git a/img/SPC/large_blue_02.png b/img/SPC/large_blue_02.png new file mode 100644 index 0000000..d263b70 Binary files /dev/null and b/img/SPC/large_blue_02.png differ diff --git a/img/SPC/large_green_01.png b/img/SPC/large_green_01.png new file mode 100644 index 0000000..e21c913 Binary files /dev/null and b/img/SPC/large_green_01.png differ diff --git a/img/SPC/large_grey_01.png b/img/SPC/large_grey_01.png new file mode 100644 index 0000000..c11df58 Binary files /dev/null and b/img/SPC/large_grey_01.png differ diff --git a/img/SPC/large_grey_02.png b/img/SPC/large_grey_02.png new file mode 100644 index 0000000..2832934 Binary files /dev/null and b/img/SPC/large_grey_02.png differ diff --git a/img/SPC/large_purple_01.png b/img/SPC/large_purple_01.png new file mode 100644 index 0000000..4740265 Binary files /dev/null and b/img/SPC/large_purple_01.png differ diff --git a/img/SPC/large_red_01.png b/img/SPC/large_red_01.png new file mode 100644 index 0000000..9837352 Binary files /dev/null and b/img/SPC/large_red_01.png differ diff --git a/img/SPC/metalic_01.png b/img/SPC/metalic_01.png new file mode 100644 index 0000000..2ad6de9 Binary files /dev/null and b/img/SPC/metalic_01.png differ diff --git a/img/SPC/metalic_02.png b/img/SPC/metalic_02.png new file mode 100644 index 0000000..d5a4f68 Binary files /dev/null and b/img/SPC/metalic_02.png differ diff --git a/img/SPC/metalic_03.png b/img/SPC/metalic_03.png new file mode 100644 index 0000000..d694151 Binary files /dev/null and b/img/SPC/metalic_03.png differ diff --git a/img/SPC/metalic_04.png b/img/SPC/metalic_04.png new file mode 100644 index 0000000..8cd0d73 Binary files /dev/null and b/img/SPC/metalic_04.png differ diff --git a/img/SPC/metalic_05.png b/img/SPC/metalic_05.png new file mode 100644 index 0000000..ff5532c Binary files /dev/null and b/img/SPC/metalic_05.png differ diff --git a/img/SPC/metalic_06.png b/img/SPC/metalic_06.png new file mode 100644 index 0000000..47b86b3 Binary files /dev/null and b/img/SPC/metalic_06.png differ diff --git a/img/SPC/orange_01.png b/img/SPC/orange_01.png new file mode 100644 index 0000000..cfeb138 Binary files /dev/null and b/img/SPC/orange_01.png differ diff --git a/img/SPC/orange_02.png b/img/SPC/orange_02.png new file mode 100644 index 0000000..e23af41 Binary files /dev/null and b/img/SPC/orange_02.png differ diff --git a/img/SPC/orange_03.png b/img/SPC/orange_03.png new file mode 100644 index 0000000..71ee69a Binary files /dev/null and b/img/SPC/orange_03.png differ diff --git a/img/SPC/orange_04.png b/img/SPC/orange_04.png new file mode 100644 index 0000000..bac4116 Binary files /dev/null and b/img/SPC/orange_04.png differ diff --git a/img/SPC/orange_05.png b/img/SPC/orange_05.png new file mode 100644 index 0000000..5078ed0 Binary files /dev/null and b/img/SPC/orange_05.png differ diff --git a/img/SPC/orange_06.png b/img/SPC/orange_06.png new file mode 100644 index 0000000..b578d59 Binary files /dev/null and b/img/SPC/orange_06.png differ diff --git a/img/SPC/purple_01.png b/img/SPC/purple_01.png new file mode 100644 index 0000000..23743c0 Binary files /dev/null and b/img/SPC/purple_01.png differ diff --git a/img/SPC/purple_02.png b/img/SPC/purple_02.png new file mode 100644 index 0000000..dfe7e4c Binary files /dev/null and b/img/SPC/purple_02.png differ diff --git a/img/SPC/purple_03.png b/img/SPC/purple_03.png new file mode 100644 index 0000000..e95e6cf Binary files /dev/null and b/img/SPC/purple_03.png differ diff --git a/img/SPC/purple_04.png b/img/SPC/purple_04.png new file mode 100644 index 0000000..d014b1b Binary files /dev/null and b/img/SPC/purple_04.png differ diff --git a/img/SPC/purple_05.png b/img/SPC/purple_05.png new file mode 100644 index 0000000..552d667 Binary files /dev/null and b/img/SPC/purple_05.png differ diff --git a/img/SPC/purple_06.png b/img/SPC/purple_06.png new file mode 100644 index 0000000..b4f4ba9 Binary files /dev/null and b/img/SPC/purple_06.png differ diff --git a/img/SPC/red_01.png b/img/SPC/red_01.png new file mode 100644 index 0000000..b17fb8b Binary files /dev/null and b/img/SPC/red_01.png differ diff --git a/img/SPC/red_02.png b/img/SPC/red_02.png new file mode 100644 index 0000000..27f8c64 Binary files /dev/null and b/img/SPC/red_02.png differ diff --git a/img/SPC/red_03.png b/img/SPC/red_03.png new file mode 100644 index 0000000..36edd01 Binary files /dev/null and b/img/SPC/red_03.png differ diff --git a/img/SPC/red_04.png b/img/SPC/red_04.png new file mode 100644 index 0000000..07a28d3 Binary files /dev/null and b/img/SPC/red_04.png differ diff --git a/img/SPC/red_05.png b/img/SPC/red_05.png new file mode 100644 index 0000000..f70a7f7 Binary files /dev/null and b/img/SPC/red_05.png differ diff --git a/img/SPC/red_06.png b/img/SPC/red_06.png new file mode 100644 index 0000000..eb06a4a Binary files /dev/null and b/img/SPC/red_06.png differ diff --git a/img/SPC/tankbase_01.png b/img/SPC/tankbase_01.png new file mode 100644 index 0000000..00a4af9 Binary files /dev/null and b/img/SPC/tankbase_01.png differ diff --git a/img/SPC/tankbase_02.png b/img/SPC/tankbase_02.png new file mode 100644 index 0000000..a002b9b Binary files /dev/null and b/img/SPC/tankbase_02.png differ diff --git a/img/SPC/tankbase_03.png b/img/SPC/tankbase_03.png new file mode 100644 index 0000000..b89468e Binary files /dev/null and b/img/SPC/tankbase_03.png differ diff --git a/img/SPC/tankbase_04.png b/img/SPC/tankbase_04.png new file mode 100644 index 0000000..de9986f Binary files /dev/null and b/img/SPC/tankbase_04.png differ diff --git a/img/SPC/tankbase_05.png b/img/SPC/tankbase_05.png new file mode 100644 index 0000000..b4e71ad Binary files /dev/null and b/img/SPC/tankbase_05.png differ diff --git a/img/SPC/tankcannon-01a.png b/img/SPC/tankcannon-01a.png new file mode 100644 index 0000000..5fd70c1 Binary files /dev/null and b/img/SPC/tankcannon-01a.png differ diff --git a/img/SPC/tankcannon-01b.png b/img/SPC/tankcannon-01b.png new file mode 100644 index 0000000..b3bb410 Binary files /dev/null and b/img/SPC/tankcannon-01b.png differ diff --git a/img/SPC/tankcannon-02a.png b/img/SPC/tankcannon-02a.png new file mode 100644 index 0000000..13d7dc9 Binary files /dev/null and b/img/SPC/tankcannon-02a.png differ diff --git a/img/SPC/tankcannon-02b.png b/img/SPC/tankcannon-02b.png new file mode 100644 index 0000000..abcbb43 Binary files /dev/null and b/img/SPC/tankcannon-02b.png differ diff --git a/img/SPC/tankcannon-03a.png b/img/SPC/tankcannon-03a.png new file mode 100644 index 0000000..9662f96 Binary files /dev/null and b/img/SPC/tankcannon-03a.png differ diff --git a/img/SPC/tankcannon-03b.png b/img/SPC/tankcannon-03b.png new file mode 100644 index 0000000..bc6435f Binary files /dev/null and b/img/SPC/tankcannon-03b.png differ diff --git a/img/background.jpg b/img/background.jpg new file mode 100644 index 0000000..f22ccf1 Binary files /dev/null and b/img/background.jpg differ diff --git a/img/bg.gif b/img/bg.gif new file mode 100644 index 0000000..b00764c Binary files /dev/null and b/img/bg.gif differ diff --git a/img/large_grey_01.png b/img/large_grey_01.png new file mode 100644 index 0000000..c11df58 Binary files /dev/null and b/img/large_grey_01.png differ diff --git a/img/large_red_01.png b/img/large_red_01.png new file mode 100644 index 0000000..9837352 Binary files /dev/null and b/img/large_red_01.png differ diff --git a/img/tankbase_05.png b/img/tankbase_05.png new file mode 100644 index 0000000..b4e71ad Binary files /dev/null and b/img/tankbase_05.png differ diff --git a/img/tankcannon-02a.png b/img/tankcannon-02a.png new file mode 100644 index 0000000..13d7dc9 Binary files /dev/null and b/img/tankcannon-02a.png differ diff --git a/img/tankcannon-03a.png b/img/tankcannon-03a.png new file mode 100644 index 0000000..9662f96 Binary files /dev/null and b/img/tankcannon-03a.png differ diff --git a/main.lua b/main.lua index f462e32..f157ba1 100644 --- a/main.lua +++ b/main.lua @@ -15,13 +15,28 @@ doubleclick1 = false doubleclick2 = false hold1 = false hold2 = false -debug = true +debug = false paused = false androidButtons = {} pauseButtons = {} doneButtons = {} showTouchControls = false --GLOBAL VARIABLES + + +--0.9 VARIABLES +background = love.graphics.newImage('img/background.jpg') +bigship = love.graphics.newImage('img/large_red_01.png') +backgroundScroll = 0 + +background_scroll_speed = 10 +background_looping_point = 810 + +--END HERE + + + + frameratecap = 1/60 realtimer = 0 myip = "unknown" @@ -55,7 +70,7 @@ GREEN = 255 IP = '45.76.95.31' IPnew = '45.76.95.31' BLUE = 255 -updateTEXT = "Chalkboard Update" +updateTEXT = "Galaxy Update" maxBalls = 1 playerCount = 1 player1reverbav = 0 @@ -173,6 +188,7 @@ controlSettings = {} modeSelectorButtons = {} pracdiff = {} playerCountButtons = {} +ships = {} function controlChanger() if (gameState == "assign") then love.graphics.clear(50 / 255, 50 / 255, 50 / 255, 255) @@ -180,6 +196,7 @@ function controlChanger() end end function love.load() + love.graphics.setDefaultFilter('nearest', 'nearest') love.keyboard.setKeyRepeat(true) tick.framerate = 60 @@ -855,6 +872,7 @@ function love.load() -- resizable = true, -- vsync = true, --}) + love.window.setVSync( 0 ) player1score = 0 player2score = 0 areanuclear = 0 @@ -902,7 +920,8 @@ function love.load() mymenu = mainMenu() ballSpeed = 200 - + background_scroll_speed = ballSpeed / 20 + background_scroll_speed = ballSpeed / 20 ballDX = math.random(2) == 1 and 100 or -100 ballDY = math.random(-50, 50) @@ -928,10 +947,13 @@ end function speedControl() if (ballSpeed > maxspeed and gameState == "play") then ballSpeed = maxspeed + background_scroll_speed = ballSpeed / 20 end end - +checking = 0 function love.update(dt) + --checking = checking + 1 + --print(checking) --print("IMPORTANT!!!!!" .. globalState .. gameState) for i, explosion in ipairs(explosions) do explosion:update(dt) @@ -944,7 +966,7 @@ function love.update(dt) end if debug then displayFPS() - print(player2.y .. " " .. player2.goal .. " " .. player2.dy .. " " .. AI_SPEED .. " " .. paddle_SPEED .. " " .. lastSentKeyClient) + --print(player2.y .. " " .. player2.goal .. " " .. player2.dy .. " " .. AI_SPEED .. " " .. paddle_SPEED .. " " .. lastSentKeyClient) end if globalState == "base" and not paused then basegame(dt) @@ -1485,6 +1507,7 @@ function speedSetter(requesttype) paddle_SPEED = paddle_SPEED + 5 end ballSpeed = ballSet + background_scroll_speed = ballSpeed / 20 end if (requesttype == "snc") then synctype = synctype + 1 @@ -1525,10 +1548,12 @@ function speedSetter(requesttype) synctext = "death is imminent" end ballSpeed = ballSet + background_scroll_speed = ballSpeed / 20 end if (requesttype == "practice") then if (ballSpeed > 999) then ballSpeed = 200 + background_scroll_speed = ballSpeed / 20 ballSet = 200 end if (ballSpeed > 799) then @@ -1545,10 +1570,12 @@ function speedSetter(requesttype) maxBalls = 3 end ballSpeed = ballSpeed + 200 + background_scroll_speed = ballSpeed / 20 ballSet = ballSet + 200 end if (requesttype == "reset") then ballSpeed = 200 + background_scroll_speed = ballSpeed / 20 ballSet = 200 synctype = 0 prtext = "Easy" @@ -1943,6 +1970,7 @@ function resettinggenius() player2.height = 100 ballSet = 200 ballSpeed = ballSet + background_scroll_speed = ballSpeed / 20 player2.GREEN = 255 player2.BLUE = 255 player1.GREEN = 255 @@ -2396,4 +2424,5 @@ function resetButtonX(arr) for i, buttons in ipairs(arr) do buttons.x = 1290 end -end \ No newline at end of file +end + diff --git a/mainMenu.lua b/mainMenu.lua index 16a1f4a..b3aa777 100644 --- a/mainMenu.lua +++ b/mainMenu.lua @@ -71,7 +71,7 @@ function mainMenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, buttons, sounds local total_height = (ev_BUTTON_HEIGHT + margin) * #buttons local ev_bx, ev_by for i, button in ipairs(buttons) do - print("Button") + --print("Button") button.last = button.now ev_bx = button.x if (location == 'control') then diff --git a/ship.lua b/ship.lua new file mode 100644 index 0000000..3691337 --- /dev/null +++ b/ship.lua @@ -0,0 +1,74 @@ +ship = Class{} + + + + + +function ship:init() + self.direction = love.math.random(0, 2) + if self.direction == 0 then + self.y = VIRTUAL_HEIGHT + 100 + self.image = love.graphics.newImage('img/SPC/blue_0' .. love.math.random(1,6) .. '.png') + self.scroll = -1 * love.math.random(80, 120) - background_scroll_speed + else + self.y = -100 + self.image = love.graphics.newImage('img/SPC/red_0' .. love.math.random(1,6) .. '.png') + self.scroll = love.math.random(80, 120) - background_scroll_speed + end + self.x = love.math.random(40, VIRTUAL_WIDTH - 40) + + + self.width = self.image:getWidth() + self.height = self.image:getHeight() + self.destroyed = false + self.deathCounter = 0 +self.deathNumber = 1 +end + +function ship:update(dt) + + --print("Width " .. self.width .. " Height: " .. self.height) + if self.destroyed then + self:deathanimation(dt) + end + self.y = self.y + self.scroll * dt + --print("traveling at " .. self.y .. " " .. self.x) + for i, ball in pairs(ball) do + print("BALL IS AT: " .. ball.x .. " " .. ball.y) + print("I AM AT " .. self.x .. " " .. self.y) + if self:collides(ball) then + print("KABOOM") + self.destroyed = true + end + end +end + +function ship:deathanimation(dt) + self.deathCounter = self.deathCounter + dt + if self.deathCounter > 0.1 and self.deathNumber < 12 then + self.image = love.graphics.newImage('img/SPC/Explosion/explosion-' .. self.deathNumber .. '.png') + self.deathCounter = 0 + self.deathNumber = self.deathNumber + 1 + end +end + +function ship:collides(object) + if (object.y > self.y and object.y < self.y + self.height and + object.x > self.x and + object.x < self.x + self.width ) then + print("!!!!!!!!!!!!!" .. object.y .. " > " .. self.y .. " and " .. object.y .. " < " .. self.y + self.height .. " " .. object.x .. " > " .. self.x .. " and " .. object.x .. " < " .. self.x + self.width) + return true + + else + return false + end + print("Shit detection") +end + +function ship:render() + if self.direction ~= 0 then + love.graphics.draw(self.image, self.x, self.y+self.height, 0, 1, -1) + else + love.graphics.draw(self.image, self.x, self.y) + end +end \ No newline at end of file diff --git a/src/AI.lua b/src/AI.lua deleted file mode 100644 index bb72fde..0000000 --- a/src/AI.lua +++ /dev/null @@ -1,170 +0,0 @@ -function AI(target, ballCnt, diff) - currentTarget = evaluateClosestBall(target); - --print("CLOSEST TARGET IS " .. currentTarget) - if diff < 1200 then - --print ("Normal targeting ".. currentTarget .. " " .. target.x - ball[currentTarget].x .. " " .. ball[currentTarget].y - target.y) - if (ball[currentTarget].y - target.y >= target.height and math.abs(target.x - ball[currentTarget].x) < diff) then - target.dy = AI_SPEED - elseif (target.y - ball[currentTarget].y >= -target.height/2 and math.abs(target.x - ball[currentTarget].x) < diff) then - target.dy = -AI_SPEED - else - target.dy = 0 - end - else - --print("Complex targeting") - if target.x < 100 then - neededTarget = predictBall(ball[currentTarget], target.x) - --print(target.x .. " found " .. neededTarget) - if neededTarget ~= -1 then - --print("Calculated target = " .. neededTarget) - if (target.y + target.height/2 - neededTarget >= 15) then - target.dy = -AI_SPEED - elseif (neededTarget - target.y >= target.height*0.9) then - target.dy = AI_SPEED - else - target.dy = 0 - end - end - else - neededTarget1 = predictBall(ball[currentTarget], target.x) - --print(target.x .. " found " .. neededTarget) - if neededTarget1 ~= -1 then - --print("Calculated target = " .. neededTarget) - if (target.y + target.height/2 - neededTarget1 >= 10) then - target.dy = -AI_SPEED - elseif (neededTarget1 - (target.y+target.height/2) >= 10) then - target.dy = AI_SPEED - else - target.dy = 0 - end - - end - end - end - if - difficultyl == 350 and player2reverbav == true and VIRTUAL_WIDTH - ball[currentTarget].x < 90 and - math.abs(ball[currentTarget].y - targe.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 -function evaluateClosestBall(target) - local ans = 0 - local min = 99999; - for i = 1, maxBalls do - if math.abs(target.x - ball[i].x ) < min then - min = math.abs(target.x - ball[i].x) - ans = i - end - end - return ans -end -function predictBall(target, px) - --print("BALLSTATS:" .. target.x .. " " .. target.y) - if target.dx > 0 and px > 100 then - local ans = recursiveCalculations(px, target.x, target.y, target.dx, target.dy, 1) - return ans - elseif target.dx < 0 and px < 100 then - local ans = recursiveCalculations(px, target.x, target.y, target.dx, target.dy, 1) - return ans - else - --print("GO TO CENTER!!") - return VIRTUAL_HEIGHT/2 - end -end -function recursiveCalculations(px, ex, ey, edx, edy, ifspecial) - if (edy > 0) then - --print ("normal" .. ex .." " .. ey .. " " .. edx .. " " .. edy) - local time = (VIRTUAL_HEIGHT-40-ey) / (ballSpeed * edy) - - local distance = math.abs(ballSpeed * edx) * time - --print("DOWNWARD" .. distance .. " " .. edx .. " " .. time .. " " .. math.abs(px-ex)) - if distance > math.abs(px - ex) then - --print("QQ") - local anstime = math.abs(px - ex) / math.abs(ballSpeed * edx) - local bonus = (ballSpeed * edy) * anstime - --print("results: " .. bonus .. " " .. edx .. " " .. anstime .. " " .. (px-ex)) - -- if (ifspecial == 0) then - local answer = ey + bonus - --love.window.setTitle(tostring(answer) .. "Basiccalc") - return ey + bonus - - -- else - -- return -1 - --end - else - --print("SS") - local emulatedx = ex + distance * edx - local emulatedy = VIRTUAL_HEIGHT-40 - --print("EMULATED: " .. emulatedx .. " " .. emulatedy) - local answer = recursiveCalculations(px, emulatedx, emulatedy, edx, -edy, 0) - --print("GOT EMULATION RESULT AS " .. answer) - --love.window.setTitle(tostring(answer) .. "recursive calc bottom") - return answer - end - elseif edy == 0 then - return ey - else - --print ("inverse" .. ex .." " .. ey .. " " .. edx .. " " .. edy) - local time = (ey) / math.abs((ballSpeed * edy)) - local distance = math.abs(ballSpeed * edx) * time - --print("UPWARD" .. distance .. " " .. edx .. " " .. time .. " " .. math.abs(px-ex)) - - - --print("Why th efuck ") - - if distance > math.abs(px - ex) then - local anstime = math.abs(px - ex) / math.abs(ballSpeed * edx) - local bonus = (ballSpeed * edy) * anstime - --print("results: " .. bonus .. " " .. edx .. " " .. anstime .. " " .. math.abs(px-ex)) --- if (ifspecial == 0) then - local answer = ey + bonus - --love.window.setTitle(tostring(answer) .. "Basiccalc") - return answer - -- else - -- return -1 - -- end - else - local emulatedx = ex + distance * edx - local emulatedy = 0 -----print("results: " .. bonus .. " " .. edx .. " " .. anstime .. " " .. (VIRTUAL_WIDTH-ex)) - local answer = recursiveCalculations(px, emulatedx, emulatedy, edx, -edy, 0) - --love.window.setTitle(tostring(answer) .. "recursivecalc") - return answer - end - end -end \ No newline at end of file diff --git a/src/androidCs b/src/androidCs deleted file mode 100644 index 244edca..0000000 --- a/src/androidCs +++ /dev/null @@ -1,5 +0,0 @@ -VIRTUAL_WIDTH = 1280 -VIRTUAL_HEIGHT = 720 -WINDOW_WIDTH = 1280 -WINDOW_HEIGHT = 720 -isAndroid = true \ No newline at end of file diff --git a/src/baseGame.lua b/src/baseGame.lua deleted file mode 100644 index 45128b9..0000000 --- a/src/baseGame.lua +++ /dev/null @@ -1,1599 +0,0 @@ -local counter = 0 -function basegame(dt) - if gameMode == "reversegame" then - reversegame(dt) - end - if player1nukescore > 300 then - player1nukescore = 300 - end - if player2nukescore > 300 then - player2nukescore = 300 - end - speedControl() - balancer() - effectControl() - if t < shakeDuration then - t = t + dt - end - --print("T = " .. tostring(t)) - serveBot() - if gameState == 'play' then - if (AGAINST_AI == 1) then - AI(player2, maxBalls, AI_LEVEL) - end - if (love.keyboard.isDown(p1control.up) or sectortouched(2)) then - player1.dy = (paddle_SPEED + p1bonus) * -1 - elseif (love.keyboard.isDown(p1control.down) or sectortouched(3)) then - player1.dy = paddle_SPEED + p1bonus - else - player1.dy = 0 - end - if (AGAINST_AI == 0) then - if ((globalState ~= "nettest" and (love.keyboard.isDown(p2control.up) or sectortouched(1))) ) then - player2.dy = (paddle_SPEED + p2bonus) * -1 - elseif ((globalState ~= "nettest" and (love.keyboard.isDown(p2control.down) or sectortouched(4)))) then - player2.dy = paddle_SPEED + p2bonus - elseif (globalState ~= "nettest") then - player2.dy = 0 - end - end - --print(areanuclear .. striken .. player1score .. player2score) - for i = 1, maxBalls do - if rules("p1hit", i) then - print("inserted") - if (areanuclear == 0 and striken == 1 and (player1score > ptw*0.8 or player2score > ptw*0.8)) then - --print("Calling animation") - --print("AREA NUCLEAR?" .. areanuclear) - superanimator("tensehit", 1) - end - 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 - --print("AREA NUCLEAR?" .. areanuclear) - if areanuclear == 0 then - superanimator("tensehit", 1) - 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 - 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) or sectortouched(2)) 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) or sectortouched(3) 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 rules("p2hit", i) then - --ameState = 'quickanim' - t = 0 - shakeDuration = 1 - if - (areanuclear == 0 and - (striken == 1 and (player1score > ptw*0.8 or player2score > ptw*0.8))) - then - --print("AREA NUCLEAR?" .. areanuclear) - superanimator("tensehit", 2) - end - 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 - --print("AREA NUCLEAR?" .. areanuclear) - if areanuclear == 0 then - superanimator("tensehit", 2) - end - 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 - 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 ((globalState ~= "nettest" and (love.keyboard.isDown(p2control.up) or sectortouched(1)) ) or AI_SPEED < 0 or lastSentKeyClient == p2control.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 (globalState ~= "nettest" and (love.keyboard.isDown(p2control.down)or sectortouched(4))) or AI_SPEED > 0 or lastSentKeyClient == p2control.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 - hitIdentifier() - 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 = 300 - 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 = 300 - timeIsSlow2 = false - player2reverbav = false - ballSpeed = originalSpeed - sounds["time"]:stop() - paddle_SPEED = originalPaddle - end - end - ball[i]:update(dt) - end - end - goalManager() - powerAvailability() - player1:update(dt) - player2:update(dt) -end - - - - -function debugCheck(dt) - - if (gameState == "menu") then - updateTEXT = "0.7.9 Chalkboard" - end - dangerChecker() - elapsed = elapsed + dt - rotation = math.sin(elapsed * 2.5) * 0.7 - if gameState == "assign" then - controlChanger() - end - editor() - mapChanger() -end - -function goalManager() - for i = 1, maxBalls do - if (rules("p1miss", i)) then - ball[i].disabled = true - ball[i].x = 2000 - - if ballsAlive() == false then - if (nuckemodactive == 0) then - areanuclear = 0 - nuclearanimation = 3 - end - striken = 0 - player1striken = 0 - player2striken = 0 - ballSpeed = ballSet - if (synctype == 0) then - paddle_SPEED = ballSet - end - if (synctype == 1) then - paddle_SPEED = ballSpeed - end - - AI_SPEED = difficultyl - for i = 1, maxBalls do - ball[i]:reset(i, 2) - end - if (player2score+1 == ptw+maxBalls-1 and gameMode ~= "practice") then - for i = 1, maxBalls do - ball[i]:reset(i) - end - sounds["win"]:play() - gameState = "done" - TEXT = "Player 2 Won!" - else - if globalState ~= "clienttest" or (globalState == "clienttest" and gameState == "1serve") then - gameState = "1serve" - serveBot() - ball[i]:reset(i, 1) - end - end - end - - player2score = player2score + 1 - end - if (rules("p2miss", i)) then - ball[i].disabled = true - ball[i].x = 2000 - if ballsAlive() == false then - if (nuckemodactive == 0) then - areanuclear = 0 - nuclearanimation = 3 - end - striken = 0 - player1striken = 0 - player2striken = 0 - ballSpeed = ballSet - - if (synctype == 0) then - paddle_SPEED = ballSet - AI_SPEED = ballSet - end - if (synctype == 1) then - paddle_SPEED = ballSpeed - AI_SPEED = ballSpeed - end - - AI_SPEED = difficultyl - - if (player1score+1 == ptw+maxBalls-1) then - ball[i]:reset(i) - - sounds["win"]:play() - gameState = "done" - TEXT = "Player 1 Won" - else - if globalState ~= "nettest" or (globalState == "nettest" and gameState == "2serve") then - gameState = "2serve" - serveBot() - - ball[i]:reset(i, 2) - end - - - end - end - sounds["score"]:play() - player1score = player1score + 1 - - end - end -end - -function powerAvailability() - if (player1nukescore >= 20 and player1nukescore < 200) then - potentialstrike1 = 1 - if (((globalState ~= "clienttest" and (love.keyboard.isDown(p1control.super) or doubleclick1 == true)) or (globalState == "clienttest" and lastSentKeyP1 == p1control.super)) ) then - player1striken = 1 - doubleclick1 = false - player1reverbav = 0 - end - end - if (player1nukescore >= 140) and timeIsSlow2 == false and timeIsSlow == false and (maxBalls > 1 or (ball[1].dx < 0 and ball[1].x < VIRTUAL_WIDTH/2))then - player1reverbav = 1 - if ((globalState == "clienttest" and lastSentKeyP1 == p1control.counter) or (globalState ~= "clienttest" and (love.keyboard.isDown(p1control.counter) or hold1 == true))) then - powerControl(1, "special") - end - end - if (player1nukescore >= 200) then - potentialnuke1 = 1 - if ((globalState == "clienttest" and (lastSentKeyP1 == p1control.super or doubleclick1 == true))or (globalState ~= "clienttest" and (love.keyboard.isDown(p1control.super) or doubleclick1 == true))) then - sounds["nuke"]:play() - doubleclick1 = false - 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 - 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 < 200) then - potentialstrike2 = 1 - if (AGAINST_AI == 0) then - if ((globalState ~= "nettest" and (love.keyboard.isDown(p2control.super) or doubleclick2)) or lastSentKeyClient == p2control.super ) then - player2striken = 1 - player2reverbav = 0 - doubleclick2 = false - end - end - end - if (player2nukescore >= 140) and timeIsSlow == false and timeIsSlow2 == false and (maxBalls > 1 or (ball[1].dx > 0 and ball[1].x > VIRTUAL_WIDTH/2)) then - player2reverbav = 1 - --print("Available counter, " .. globalState .. tostring(love.keyboard.isDown(p2control.counter))) - if (globalState ~= "nettest" and (love.keyboard.isDown(p2control.counter) or hold2)) or lastSentKeyClient == 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 - potentialnuke2 = 1 - if (((globalState ~= "nettest" and (love.keyboard.isDown(p2control.super) or doubleclick2)) or lastSentKeyClient == p2control.super)) and AGAINST_AI == 0 then - sounds["nuke"]:play() - doubleclick2 = false - if areanuclear == 1 then - maxspeed = maxspeed + 50 - end - potentialstrike2 = 0 - areanuclear = 1 - player2reverbav = 0 - ballSpeed = ballSpeed * 2 - if (synctype == 0) then - paddle_SPEED = paddle_SPEED * 2 - end - if (synctype == 1) then - paddle_SPEED = ballSpeed - 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 -end - -function editor() - if (gameState == "editor") then - if debug then - --print("Editor is active!") - end - local mx, my = love.mouse.getPosition() - mx = mx * DIFFERENCE_X - my = my * DIFFERENCE_Y - 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 - end -end - -function nuclearDraw() - love.graphics.setColor(1, 1, 1, 1) - for i = 1, maxBalls do - love.graphics.circle("fill", ball[i].x, ball[i].y, explosionRange * 100, 100) - end - 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() -end - -function winDraw(who) - - love.graphics.setColor(0, 0, 0, 1) - if who == 1 then - love.graphics.circle("fill", player2.x, player2.y, explosionRange * 100, 100) - love.graphics.setColor(0.7, 0.1, 0.1, 1) - love.graphics.circle("fill", player2.x, player2.y, explosionRange * 90, 100) - love.graphics.setColor(0.1, 0.7, 0.1, 1) - love.graphics.circle("fill", player2.x, player2.y, explosionRange * 80, 100) - love.graphics.setColor(0.1, 0.1, 0.7, 1) - love.graphics.circle("fill", player2.x, player2.y, explosionRange * 70, 100) - love.graphics.setColor(0, 0, 0, 1) - love.graphics.circle("fill", player2.x, player2.y, explosionRange * 60, 100) - print("cicrleexplostion at " .. explosionRange) - else - love.graphics.circle("fill", player1.x, player1.y, explosionRange * 100, 100) - love.graphics.setColor(0.7, 0.1, 0.1, 1) - love.graphics.circle("fill", player1.x, player1.y, explosionRange * 90, 100) - love.graphics.setColor(0.1, 0.7, 0.1, 1) - love.graphics.circle("fill", player1.x, player1.y, explosionRange * 80, 100) - love.graphics.setColor(0.1, 0.1, 0.7, 1) - love.graphics.circle("fill", player1.x, player1.y, explosionRange * 70, 100) - love.graphics.setColor(0, 0, 0, 1) - love.graphics.circle("fill", player1.x, player1.y, explosionRange * 60, 100) - end - love.graphics.setColor(1, 1, 1, 1) - love.graphics.printf(TEXT, 0, 20, VIRTUAL_WIDTH, "center") -end - -function normalDraw() - if (areanuclear == 1) then - love.graphics.clear(1, 1, 1, 1) - else - love.graphics.clear(40 / 255, 40 / 255, 40 / 255, 1) - end - for i, explosion in ipairs(explosions) do - explosion:render() - print("exploding") - end - staticanimator() - - 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 - 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 - - pongDraw() - love.graphics.setFont(smallfont) - for i = 1, maxBalls do - if areanuclear == 1 then - --love.window.setTitle('rendering black') - ball[i]:render("black") - else - --love.window.setTitle('rendering white') - ball[i]:render(" ") - end - end - -end -function pongDraw() - --print("Drawing classic pong") - love.graphics.setColor(1, 1, 1, 1) - love.graphics.printf(TEXT, 0, 20, VIRTUAL_WIDTH, "center") - love.graphics.setFont(smallfont) - love.graphics.setFont(scorefont) - if (areanuclear == 1) then - love.graphics.setColor(0, 0, 0, 1) - end - love.graphics.print(tostring(math.floor(player1score)), VIRTUAL_WIDTH / 2 - 500, VIRTUAL_HEIGHT / 12) - love.graphics.print(tostring(math.floor(player2score)), VIRTUAL_WIDTH / 2 + 400, VIRTUAL_HEIGHT / 12) - love.graphics.setColor(1, 1, 1, 1) - displayPoints() - player1:render() - player2:render() - -end -function practiceDraw() - player1:render() - love.graphics.rectangle("fill", VIRTUAL_WIDTH-10, 0, 10, VIRTUAL_HEIGHT) - love.graphics.setColor(1, 1, 1, 1) - love.graphics.printf(TEXT, 0, 20, VIRTUAL_WIDTH, "center") - love.graphics.setFont(smallfont) - love.graphics.setFont(scorefont) - love.graphics.print(tostring(math.floor(player1score)), VIRTUAL_WIDTH / 2 - 500, VIRTUAL_HEIGHT / 12) -end -function menuDraw() - love.graphics.setColor(1, 1, 1, 1) - 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") - 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 - 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 - player1:render() - player2:render() - ball[1]:render("controlled") - if gameState == "touchcontrols" then - if doubleclick1 or doubleclick2 then - gameState = "menu" - globalState = "menu" - resettinggenius() - end - love.graphics.setFont(smallfont) - love.graphics.printf("The green zones are for moving up and down, double tap the red zone for special attack or to start the serve.", 10, 150, VIRTUAL_WIDTH, "center") - love.graphics.printf("Swipe from red to green for stopping time", 10, 450, VIRTUAL_WIDTH, "center") - 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 == "chooseIP" then - IPselect = {} - if isAndroid then - table.insert( - IPselect, - newButton( - IPnew, - function() - love.keyboard.setTextInput( true, 0, VIRTUAL_HEIGHT, VIRTUAL_WIDTH, VIRTUAL_HEIGHT/3) - end, - "stationary" - ) - ) - end - table.insert( - IPselect, - newButton( - "LANHost", - function() - globalState = "selfhost" - AGAINST_AI = 0 - gameState = "1serve" - ball[1]:reset(1, 1) - player2.dy = 0 - end, - "stationary" - ) - ) - table.insert( - IPselect, - newButton( - "Check Server", - function() - IP = IPnew - counter = 0 - end, - "stationary" - ) - ) - if status == "offline" then - animateConnection() - elseif status == "nettest" and IP == IPnew then - table.insert( - IPselect, - newButton( - "Connect as Host", - function() - resettinggenius() - globalState = "nettest" - AGAINST_AI = 0 - gameState = "1serve" - ball[1]:reset(1, 1) - player2.dy = 0 - end, - "stationary" - ) - ) - - elseif status == "clienttest" and IP == IPnew then - table.insert( - IPselect, - newButton( - "Connect as Guest", - function() - resettinggenius() - globalState = "clienttest" - AGAINST_AI = 0 - gameState = "1serve" - ball[1]:reset(1, 1) - player2.dy = 0 - end, - "stationary" - ) - ) - elseif status == "full" then - love.graphics.printf("SERVER FULL", 0, VIRTUAL_HEIGHT / 2, VIRTUAL_WIDTH, "center") - end - mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, IPselect, sounds, "middle") - love.keyboard.mouseisReleased = false - if not isAndroid then - love.graphics.printf(IPnew, 0, VIRTUAL_HEIGHT / 4, VIRTUAL_WIDTH, "center") - end - 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, "middle") - love.keyboard.mouseisReleased = false - end - if gameState == "prdiff" then - mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, pracdiff, sounds, "playercount") - love.keyboard.mouseisReleased = false - end - 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.setColor(200/255, 200/255, 200/255, 1) - if isAndroid then - love.graphics.print("Tap to Start", WINDOW_WIDTH / -10, VIRTUAL_HEIGHT / 8) - else - love.graphics.print("Press Enter to Start", WINDOW_WIDTH / -10, VIRTUAL_HEIGHT / 8) - end - love.graphics.setColor(255, 255, 255, 255) - love.graphics.pop() - end -end -function baseDraw() - love.graphics.clear(40 / 255, 40 / 255, 40 / 255, 1) - - if shakeDuration > t then - - local dx = love.math.random(-shakeMagnitude, shakeMagnitude) - local dy = love.math.random(-shakeMagnitude, shakeMagnitude) - love.graphics.translate(dx, dy) - end - if globalState == 'menu' then - --print("Drawing menuDraw") - if gameState == 'animation' then - - --print("Drawing animation") - intro() - end - if gameState ~= 'animation' then - --print("Drawing notanimtaion") - love.graphics.setFont(scorefont) - menuDraw() - end - end - - if globalState == 'base' or globalState == 'reverse' or globalState == 'nettest' or globalState == 'clienttest' then - - love.graphics.setFont(smallfont) - if gameState == 'nuclearExplosion' then - nuclearDraw() - end - - if gameState == 'play' or gameState == '1serve' or gameState == '2serve' or gameState == 'done' then - --print("Drawing normally") - normalDraw() - end - if gameState == 'done' and player1score > player2score then - winDraw(1) - elseif gameState == 'done' and player1score < player2score then - winDraw(2) - end - end - if paused then - mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, pauseButtons, sounds, "middle") - love.keyboard.mouseisReleased = false - end - if gameState == "done" then - mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, doneButtons, sounds, "middle") - love.keyboard.mouseisReleased = false - end - -end -function androidDraw() ---HOME BUTTON HERE -mymenu:butt(gameState, VIRTUAL_WIDTH, VIRTUAL_HEIGHT, androidButtons, sounds, "android") -if showTouchControls then - love.graphics.setColor(15/255, 255/255, 15/255, 0.5) - love.graphics.rectangle("fill", 0, 0, 100, VIRTUAL_HEIGHT) - love.graphics.setColor(15/255, 255/255, 15/255, 0.5) - love.graphics.rectangle("fill", VIRTUAL_WIDTH-100, 0, 50, VIRTUAL_HEIGHT) - love.graphics.setColor(255/255, 15/255, 15/255, 0.5) - love.graphics.rectangle("fill", 100, 0, VIRTUAL_WIDTH/2-100, VIRTUAL_HEIGHT) - love.graphics.rectangle("fill", VIRTUAL_WIDTH/2, 0, VIRTUAL_WIDTH/2-100, VIRTUAL_HEIGHT) - love.graphics.setColor(0, 0, 0, 0.5) - love.graphics.rectangle("fill", VIRTUAL_WIDTH/2-5, 0, 10, VIRTUAL_HEIGHT) -end -end -function renderEditor() - 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 - 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 - -function intro() - love.graphics.setColor(255, 255, 255, light / 255) - love.graphics.draw(image, 0, 0) -end - - -function displayPoints() - love.graphics.setFont(smallfont) - if areanuclear == 1 then - love.graphics.setColor(0,0,0,1) - end - if (potentialstrike1 == 1 and potentialnuke1 == 0 and player1reverbav == 0) then --FLAG: AVAILABLE SUPER - 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) - elseif (potentialnuke1 == 1) then - love.graphics.setColor(255, 0, 0, 255) - love.graphics.print( - tostring( - math.floor(player1nukescore) .. "[" .. p1control.super .. "]" - ), - 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) then - love.graphics.print( - tostring(math.floor(player2nukescore) .. "[" .. p2control.super .. "]"), - VIRTUAL_WIDTH / 2 + 430, - VIRTUAL_HEIGHT / 60 - ) - else - love.graphics.print(tostring("READY"), VIRTUAL_WIDTH / 2 + 430, VIRTUAL_HEIGHT / 60) - end - elseif (potentialnuke2 == 1) then - love.graphics.setColor(255, 0, 0, 255) - love.graphics.print( - tostring(math.floor(player2nukescore) .. "[" .. p2control.super .. "] [" .. p2control.counter .. "]"), - VIRTUAL_WIDTH / 2 + 400, - VIRTUAL_HEIGHT / 60 - ) - love.graphics.setColor(255, 255, 255, 255) - elseif (potentialnuke2 == 1 and maxBalls > 1) 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 + 400, - VIRTUAL_HEIGHT / 60 - ) - else - love.graphics.print(tostring(math.floor(player2nukescore)), VIRTUAL_WIDTH / 2 + 430, VIRTUAL_HEIGHT / 60) - end -end - -function hitIdentifier() - 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 -function rules(query, i) - if query == "p1hit" then - if gameMode == "normal" then - return ball[i]:collides(player1) - elseif gameMode == "reversegame" then - return ball[i].x < 0 and ball[i].disabled == false - end - end - if query == "p2hit" then - if gameMode == "normal" then - return ball[i]:collides(player2) - elseif gameMode == "reversegame" then - return ball[i].x > VIRTUAL_WIDTH-10 and ball[i].disabled == false - end - end - if query == "p1miss" then - if gameMode == "reversegame" then - - return ball[i]:collides(player1) - elseif gameMode == "normal" then - return ball[i].x < -10 and ball[i].disabled == false - end - end - if query == "p2miss" then - if gameMode == "reversegame" then - return ball[i]:collides(player2) - elseif gameMode == "normal" then - return ball[i].x > VIRTUAL_WIDTH and ball[i].disabled == false - end - end -end -function clientsBaseGame(dt) - if gameMode == "reverse" then - reversegame(dt) - end - if player1nukescore > 300 then - player1nukescore = 300 - end - if player2nukescore > 300 then - player2nukescore = 300 - end - speedControl() - balancer() - effectControl() - if t < shakeDuration then - t = t + dt - end - - if (lastSentKeyP1 == p1control.up) then - player1.dy = (paddle_SPEED + p2bonus) * -1 - --print("moving player1 up") - elseif (lastSentKeyP1 == p1control.down) then - player1.dy = paddle_SPEED + p2bonus - --print("moving player1 down") - else - player1.dy = 0 - ----print("stopping player") - end - if ((love.keyboard.isDown(p2control.up) or sectortouched(1))) then - player2.dy = (paddle_SPEED + p2bonus) * -1 - elseif ((love.keyboard.isDown(p2control.down)) or sectortouched(4)) then - player2.dy = paddle_SPEED + p2bonus - else - player2.dy = 0 - end - --print("T = " .. tostring(t)) - serveBot() - if gameState == 'play' then - if (AGAINST_AI == 1) then - AI(player2, maxBalls, AI_LEVEL) - end - --print(areanuclear .. striken .. player1score .. player2score) - for i = 1, maxBalls do - if rules("p1hit", i) then - - if (areanuclear == 0 and striken == 1 and (player1score > ptw*0.8 or player2score > ptw*0.8)) then - --print("Calling animation") - superanimator("tensehit", 1) - --print("AREA NUCLEAR?" .. areanuclear) - end - 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 - if areanuclear == 0 then - superanimator("tensehit", 1) - 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 - 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 - end - if rules("p2hit", i) then - --ameState = 'quickanim' - t = 0 - shakeDuration = 1 - if - (areanuclear == 0 and - (striken == 1 and (player1score > ptw*0.8 or player2score > ptw*0.8))) - then - --print("AREA NUCLEAR?" .. areanuclear) - superanimator("tensehit", 2) - end - 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 - --print("AREA NUCLEAR?" .. areanuclear) - if areanuclear == 0 then - superanimator("tensehit", 2) - end - 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 - 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 sectortouched(1)) 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 sectortouched(4))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 - hitIdentifier() - 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 = 300 - 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 = 300 - timeIsSlow2 = false - player2reverbav = false - ballSpeed = originalSpeed - sounds["time"]:stop() - paddle_SPEED = originalPaddle - end - end - ball[i]:update(dt) - end - end - goalManager() - powerAvailability() - player1:update(dt) - player2:update(dt) -end - -function animateConnection() - if GetIPType(IP) ~= 1 then - love.graphics.printf("WRONG SYNTAX", 0, VIRTUAL_HEIGHT-80, VIRTUAL_WIDTH, "center") - else - counter = counter + 1 / love.timer.getFPS() - if counter < 0.8 then - love.graphics.printf("TRYING TO CONNECT.", 0, VIRTUAL_HEIGHT-80, VIRTUAL_WIDTH, "center") - elseif counter < 1.6 then - love.graphics.printf("TRYING TO CONNECT..", 0, VIRTUAL_HEIGHT-80, VIRTUAL_WIDTH, "center") - elseif counter < 2.4 then - love.graphics.printf("TRYING TO CONNECT...", 0, VIRTUAL_HEIGHT-80, VIRTUAL_WIDTH, "center") - else - love.graphics.printf("NO CONNECTION!", 0, VIRTUAL_HEIGHT-80, VIRTUAL_WIDTH, "center") - end -end -end -function GetIPType(ip) - -- must pass in a string value - if ip == nil or type(ip) ~= "string" then - return 0 - end - - -- check for format 1.11.111.111 for ipv4 - local chunks = {ip:match("(%d+)%.(%d+)%.(%d+)%.(%d+)")} - if (#chunks == 4) then - for _,v in pairs(chunks) do - if (tonumber(v) < 0 or tonumber(v) > 255) then - return 0 - end - end - return 1 - else - return 0 - end - - -- check for ipv6 format, should be 8 'chunks' of numbers/letters - local _, chunks = ip:gsub("[%a%d]+%:?", "") - if chunks == 8 then - return 2 - end - - -- if we get here, assume we've been given a random string - return 3 -end - -function menuDemo(dt) - paddle_SPEED = 200 - ballSpeed = 200 - if ball[1].dx > 0 then - AI(player2, maxBalls, 1300) - player1.goal = 360 - elseif ball[1].dx < 0 then - AI(player1, maxBalls, 1300) - player2.goal = 360 - end - --print(neededTarget, neededTarget1) - --print("menu demo active") - ball[1]:update(dt) - player1:update(dt) - player2:update(dt) - if ball[1].x < player1.x+15 then - player1.y = ball[1].y-player1.height - end - if ball[1].x > player2.x-15 then - player2.y = ball[1].y-player2.height - end - if ball[1].x >= player2.x-7 then - sounds["beep"]:setPitch(ballSpeed / 250) - sounds["beep"]:play() - select = math.random(1, 2) - if ball[1].dy < 0 then - select = math.random(1, 5) - if select == 1 then - ball[1].dy = -1 - elseif select == 2 then - ball[1].dy = -1.2 - elseif select == 3 then - ball[1].dy = -1.5 - elseif select == 4 then - ball[1].dy = -1.8 - elseif select == 5 then - ball[1].dy = -2 - end - else - select = math.random(1, 5) - if select == 1 then - ball[1].dy = 1 - elseif select == 2 then - ball[1].dy = 1.2 - elseif select == 3 then - ball[1].dy = 1.5 - elseif select == 4 then - ball[1].dy = 1.8 - elseif select == 5 then - ball[1].dy = 2 - end - end - ball[1].x = player2.x-8 - ball[1].dx = -ball[1].dx - end - if ball[1].x <= player1.x+7 then - sounds["beep"]:setPitch(ballSpeed / 250) - sounds["beep"]:play() - select = math.random(1, 2) - if ball[1].dy < 0 then - select = math.random(1, 5) - if select == 1 then - ball[1].dy = -1 - elseif select == 2 then - ball[1].dy = -1.2 - elseif select == 3 then - ball[1].dy = -1.5 - elseif select == 4 then - ball[1].dy = -1.8 - elseif select == 5 then - ball[1].dy = -2 - end - else - select = math.random(1, 5) - if select == 1 then - ball[1].dy = 1 - elseif select == 2 then - ball[1].dy = 1.2 - elseif select == 3 then - ball[1].dy = 1.5 - elseif select == 4 then - ball[1].dy = 1.8 - elseif select == 5 then - ball[1].dy = 2 - end - end - ball[1].x = player1.x+8 - ball[1].dx = -ball[1].dx - end - - if ball[1].y <= 0 then - soundtype = love.math.random(1, 5) - sounds["wallhit"]:setPitch(ballSpeed / 250) - sounds["wallhit"]:play() - ball[1].y = 0 - ball[1].dy = -ball[1].dy - end - - -- -4 to account for the ball's size - if ball[1].y >= VIRTUAL_HEIGHT - 40 then - soundtype = love.math.random(1, 5) - sounds["wallhit"]:setPitch(ballSpeed / 250) - sounds["wallhit"]:play() - ball[1].y = VIRTUAL_HEIGHT - 40 - ball[1].dy = -ball[1].dy - - end -end -function effectControl() - if player1score > 0.8 * ptw or player2score > 0.8 * ptw then - for i = 1, maxBalls do - if math.abs(ball[i].x - VIRTUAL_WIDTH/2) < 10 and #explosions < 1 then - table.insert(explosions, explosion(love.math.random(100, VIRTUAL_WIDTH-100), love.math.random(player1.y, player2.y), 100, {player1.y/2.81/255,player2.y/2.81/255,ball[1].y/2.81/255,0.4})) - end - end - end - for i, explosion in ipairs(explosions) do - if explosion.killed then - table.remove(explosions, i) - print("buried the body") - end - end -end \ No newline at end of file diff --git a/src/constantvars.lua b/src/constantvars.lua deleted file mode 100644 index fe18bf6..0000000 --- a/src/constantvars.lua +++ /dev/null @@ -1,5 +0,0 @@ -VIRTUAL_WIDTH = 1280 -VIRTUAL_HEIGHT = 720 -WINDOW_WIDTH = 1280 -WINDOW_HEIGHT = 720 -isAndroid = false \ No newline at end of file diff --git a/src/dependencies.lua b/src/dependencies.lua deleted file mode 100644 index 9354dcd..0000000 --- a/src/dependencies.lua +++ /dev/null @@ -1,19 +0,0 @@ -Class = require 'class' -require 'paddle' -require 'simpleScale' -require 'TSerial' -require 'eball' -require 'fullScreener' -require 'superPowerControl' -require 'mainMenu' -require 'music' -require 'animator' -require 'src/baseGame' -require 'src/constantvars' -require 'src/menus' -require 'src/AI' -require 'src/reverseGame' -require 'explosion' -tick = require 'tick' -utf8 = require("utf8") -serialize = require 'ser' \ No newline at end of file diff --git a/src/menus.lua b/src/menus.lua deleted file mode 100644 index 8d949bc..0000000 --- a/src/menus.lua +++ /dev/null @@ -1,3 +0,0 @@ -function menumode() - dangerChecker() -end \ No newline at end of file diff --git a/src/pcCs b/src/pcCs deleted file mode 100644 index fe18bf6..0000000 --- a/src/pcCs +++ /dev/null @@ -1,5 +0,0 @@ -VIRTUAL_WIDTH = 1280 -VIRTUAL_HEIGHT = 720 -WINDOW_WIDTH = 1280 -WINDOW_HEIGHT = 720 -isAndroid = false \ No newline at end of file diff --git a/src/reverseGame.lua b/src/reverseGame.lua deleted file mode 100644 index 356c5f5..0000000 --- a/src/reverseGame.lua +++ /dev/null @@ -1,15 +0,0 @@ -function reversegame(dt) - player1.height = ballSpeed/2 - player2.height = ballSpeed/2 - if (player1.y < ball[1].y)then - player1.y = player1.y + ballSpeed/50 - elseif(player1.y > ball[1].y)then - player1.y = player1.y - ballSpeed/50 - end - if (player2.y < ball[1].y) then - player2.y = player2.y + ballSpeed/50 - - elseif(player2.y > ball[1].y) then - player2.y = player2.y - ballSpeed/50 - end -end diff --git a/superPowerControl.lua b/superPowerControl.lua deleted file mode 100644 index 8f3e2b9..0000000 --- a/superPowerControl.lua +++ /dev/null @@ -1,8 +0,0 @@ -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/tick.lua b/tick.lua deleted file mode 100644 index 5d00c7a..0000000 --- a/tick.lua +++ /dev/null @@ -1,70 +0,0 @@ --- tick --- https://github.com/bjornbytes/tick --- MIT License - -local tick = { - framerate = nil, - rate = .03, - timescale = 1, - sleep = .001, - dt = 0, - accum = 0, - tick = 1, - frame = 1 - } - - local timer = love.timer - local graphics = love.graphics - - love.run = function() - if not timer then - error('love.timer is required for tick') - end - - if love.load then love.load(love.arg.parseGameArguments(arg), arg) end - timer.step() - local lastframe = 0 - - love.update(0) - - return function() - tick.dt = timer.step() * tick.timescale - tick.accum = tick.accum + tick.dt - while tick.accum >= tick.rate do - tick.accum = tick.accum - tick.rate - - if love.event then - love.event.pump() - for name, a, b, c, d, e, f in love.event.poll() do - if name == 'quit' then - if not love.quit or not love.quit() then - return a or 0 - end - end - - love.handlers[name](a, b, c, d, e, f) - end - end - - tick.tick = tick.tick + 1 - if love.update then love.update(tick.rate) end - end - - while tick.framerate and timer.getTime() - lastframe < 1 / tick.framerate do - timer.sleep(.0005) - end - - lastframe = timer.getTime() - if graphics and graphics.isActive() then - graphics.origin() - graphics.clear(graphics.getBackgroundColor()) - tick.frame = tick.frame + 1 - if love.draw then love.draw() end - graphics.present() - end - - timer.sleep(tick.sleep) - end - end - - return tick \ No newline at end of file diff --git a/win.wav b/win.wav deleted file mode 100644 index b8af816..0000000 Binary files a/win.wav and /dev/null differ