|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521 |
- --CALLING OTHER LUA FILES
-
- require "src/dependencies"
- io.stdout:setvbuf("no")
- --CANCELLED ATTEMPETED SHADING (NOT WORKING)
- local shader_code =
- [[
- vec4 effect(vec4 color, Image image, vec2 uvs, vec2 screen_coords) {
- vec4 pixel = Texel(image,uvs);
- return pixel * color;
- }
- ]]
- --ANDROID EXLUSIVE VARIABLES
- touches = {}
- doubleclick1 = false
- doubleclick2 = false
- hold1 = false
- hold2 = false
- debug = true
- paused = false
- androidButtons = {}
- pauseButtons = {}
- doneButtons = {}
- showTouchControls = false
- --GLOBAL VARIABLES
-
-
- --0.9 VARIABLES
- globalMessage = "none"
- globalAnimation = "none"
- globalMessageTime = 0
- isButtonAnimated = false
- lowcpu = false
- wallsLoadError = false
- background = love.graphics.newImage('img/background.jpg')
- backgroundScroll = 0
-
- background_scroll_speed = 10
- background_looping_point = 810
-
- --END HERE
-
-
-
-
- frameratecap = 1/60
- realtimer = 0
- myip = "unknown"
- status = "offline"
- gameMode = "normal"
- ts = 0
- globalState = "menu"
- timeIsSlow = false
- timeIsSlow2 = false
- originalSpeed = 200
- explosionRange = 0
- blockinput = false
- wall1width = 30
- nuclearanimation = 3
- easternum = 0
- qq = 0
- ball_DIR = 0
- updaterate = 0.015
- RED = 255
- hitNum = {}
- hitNum[1] = 0
- hitNum[2] = 0
- hitNum[3] = 0
- confirmation = "N"
- hitNum[4] = 0
- p1bonus = 0
- p2bonus = 0
- hitNum[5] = 0
- hitNum[6] = 0
- GREEN = 255
- IP = '45.76.95.31'
- IPnew = '45.76.95.31'
- BLUE = 255
- updateTEXT = "Galaxy Update"
- maxBalls = 1
- playerCount = 1
- player1reverbav = 0
- playertext = "1v1"
- player2reverbav = 0
- elapsed = 0
- rotation = 0
- TEXT = "Nuclear Pong"
- currentKey = " "
- ptw = 10
- checkrate = 0.5
- --CHECKING IF CONTROLS ARE TAKEN
- danger = "none"
- danger2 = "none"
-
- nuckemodactive = 0
- maxspeed = 700
- DIFFERENCE_X = 1
- DIFFERENCE_Y = 1
- OFFSET_X = 0
- OFFSET_Y = 0
- paddle_SPEED = 200
- textamount = 15
- AI_STRIKEMOD = 1000
- resolutionWin = 0
- AGAINST_AI = 0
- RESOLUTION_SET = 0
- AI_NUKEMOD = 1000
- animstart = true
- AI_SPEED = 300
- craz = 0
- AI_LEVEL = 500
- isFullscreen = 0
- prtext = "Easy"
- lastSentKey = "c"
- MAP_TYPE = 0
- lastSentKeyClient = "c"
- difficultyl = 300
- req = "pp"
- ballSet = 200
- p1control = {up = "a", down = "z", super = "s", counter = "x"}
- p2control = {up = ";", down = ".", super = "l", counter = ","}
- synctext = "Independent"
- synctype = 0
- function newTouch(id, x, y)
- return {
- id = id,
- x = x,
- y = y,
- originalX = x,
- originalY = y
- }
- end
- function newButton(text, fn, sp, qp)
- if qp ~= nil then
- return {
- x = (VIRTUAL_WIDTH * 0.5) - VIRTUAL_WIDTH * (1/3)*0.5,
- text = text,
- fn = fn,
- skipAnim = true,
- now = false,
- last = false
- }
- else
- return {
- x = 1300,
- text = text,
- fn = fn,
- skipAnim = sp,
- now = false,
- last = false
- }
- end
- end
- function love.keyboard.mouseWasReleased()
- return love.keyboard.mouseisReleased
- end
- function autoSave(dt)
- autoTimer = autoTimer + dt
- end
-
- function balancer()
- if (player2score == 9 or player1score == 9) then
- shakeDuration = 5
- if debug then
- --print("Shaking set to match almost over")
- end
- end
- if (player1score < player2score) then
- p1bonus = (player2score - player1score) * 5
- else
- p1bonus = 0
- end
- if (player2score < player1score) then
- p2bonus = (player1score - player2score) * 5
- else
- p2bonus = 0
- end
- end
-
- function newWall(wallx, wally, wallwidth, wallheight)
- return {
- wallx = wallx,
- wally = wally,
- walwidth = wallwidth,
- wallheight = wallheight
- }
- end
- speedParameters = {}
- buttons = {}
- IPselect = {}
- difbuttons = {}
- settings = {}
- walls = {}
- editorpicks = {}
- controlSettings = {}
- modeSelectorButtons = {}
- pracdiff = {}
- playerCountButtons = {}
- function controlChanger()
- if (gameState == "assign") then
- love.graphics.clear(50 / 255, 50 / 255, 50 / 255, 255)
- love.graphics.printf("SELECT BUTTON", 0, VIRTUAL_HEIGHT / 2, VIRTUAL_WIDTH, "center")
- end
- end
- function love.load()
- walls = {}
- print(love.filesystem.createDirectory( "pong" ))
- love.filesystem.setIdentity( "pong" )
- print (love.filesystem.getSaveDirectory())
- print (love.filesystem.getIdentity( ))
- love.graphics.setDefaultFilter('nearest', 'nearest')
- love.keyboard.setKeyRepeat(true)
-
- tick.framerate = 60
- simpleScale.setWindow(VIRTUAL_WIDTH, VIRTUAL_HEIGHT, WINDOW_WIDTH, WINDOW_HEIGHT)
- configfile = io.open("config.lua", "r")
- configsave = io.open("config.lua", "w")
- shader = love.graphics.newShader(shader_code)
- time_1 = 0
- --print("Debug active")
- --load
-
- testwalls = love.filesystem.load("save.lua")()
- if testwalls ~= nil then
- walls = love.filesystem.load("save.lua")()
- print("Save file found")
- else
- print("No save file found!")
- end
-
- light = 0
- image = love.graphics.newImage("Madi.png")
- table.insert(
- androidButtons,
- newButton(
- "H",
- function()
- if globalState == "base" and gameState ~= "done" then
- paused = true
- else
- resetButtonX(buttons)
- TEXT = "Nuclear Pong"
- resettinggenius()
- paused = false
- gameState = "menu"
- ball[1].dx = 1
- ball_DIR = 1
- ball[1].dy = 1
- globalState = "menu"
- hardmanager()
- end
- end,
- false
- )
- )
- table.insert(
- editorpicks,
- newButton(
- "C",
- function()
- for k in pairs(walls) do
- walls[k] = nil
- end
- end,
- false
- )
- )
- table.insert(
- pauseButtons,
- newButton(
- "Resume",
- function()
- paused = false
- TEXT = "Let's Continue"
- end,
- false
- )
- )
- table.insert(
- doneButtons,
- newButton(
- "Freeplay",
- function()
- if player1score > player2score then
- gameState = "2serve"
- else
- gameState = "1serve"
- end
- potentialnuke1 = 0
- potentialnuke2 = 0
- striken = 0
- if (nuckemodactive == 0) then
- areanuclear = 0
- nuclearanimation = 3
- end
- potentialstrike1 = 0
- potentialstrike2 = 0
- player1nukescore = 0
- player2nukescore = 0
- end,
- false
- )
- )
- table.insert(
- doneButtons,
- newButton(
- "Menu",
- function()
- resettinggenius()
- TEXT = "Nuclear Pong"
- paused = false
- gameState = "menu"
- ball[1].dx = 1
- ball_DIR = 1
- ball[1].dy = 1
- globalState = "menu"
- hardmanager()
- end,
- false
- )
- )
- if not isAndroid then
- table.insert(
- pauseButtons,
- newButton(
- "Toggle Fullscreen",
- function()
- myscreen:toggle(VIRTUAL_HEIGHT, VIRTUAL_WIDTH)
- DIFFERENCE_X = myscreen.c
- DIFFERENCE_Y = myscreen.d
- OFFSET_X = myscreen.e
- OFFSET_Y = myscreen.f
- end,
- true
- )
- )
- end
- table.insert(
- pauseButtons,
- newButton(
- "Toggle Music",
- function()
- if mute then
- musicController("mute", 0)
- else
- musicController("mute", 1)
- end
- end,
- true
- )
- )
- table.insert(
- pauseButtons,
- newButton(
- "Menu",
- function()
- resettinggenius()
- paused = false
- TEXT = "Nuclear Pong"
- gameState = "menu"
- ball[1].dx = 1
- ball_DIR = 1
- ball[1].dy = 1
- globalState = "menu"
- hardmanager()
- end,
- false
- )
- )
-
- table.insert(
- editorpicks,
- newButton(
- "S",
- function()
- print(love.filesystem.write("save.lua", serialize(walls)))
- end,
- true
- )
- )
- table.insert(
- editorpicks,
- newButton(
- "L",
- function()
- walls = love.filesystem.load("save.lua")()
- if walls == nil then
- walls = {}
- wallsLoadError = true
- end
- end,
- true
- )
- )
- table.insert(
- buttons,
- newButton(
- "Singleplayer",
- function()
- ptw = 10
- gameState = "gameMode"
- end,
- false
- )
- )
- table.insert(
- buttons,
- newButton(
- "Online",
- function()
- MAP_TYPE = 0
- if isAndroid then
- love.keyboard.setTextInput( true, 0, VIRTUAL_HEIGHT, VIRTUAL_WIDTH, VIRTUAL_HEIGHT/3)
- end
- gameState = "chooseIP"
- end,
- false
- )
- )
- table.insert(
- IPselect,
- newButton(
- "Host",
- function()
- globalState = "nettest"
- AGAINST_AI = 0
- gameState = "1serve"
- ball[1]:reset(1, 1)
- end,
- true
- )
- )
- table.insert(
- IPselect,
- newButton(
- "Guest",
- function()
- globalState = "clienttest"
- AGAINST_AI = 0
- gameState = "1serve"
- ball[1]:reset(1, 1)
- end,
- true
- )
- )
- table.insert(
- buttons,
- newButton(
- "Multiplayer",
- function()
- gameState = "multiMode"
- end,
- false
- )
- )
- if not isAndroid then
- table.insert(
- buttons,
- newButton(
- "Settings",
- function()
- AGAINST_AI = 0
- gameState = "windowsettings"
- end,
- false
- )
- )
- else
- table.insert(
- buttons,
- newButton(
- "Show Controls",
- function()
- if showTouchControls then
- showTouchControls = false
- else
- showTouchControls = true
- end
- gameState = "touchcontrols"
- end,
- true
- )
- )
- end
- table.insert(
- buttons,
- newButton(
- "Exit",
- function()
- love.event.quit(0)
- end,
- false
- )
- )
- table.insert(
- difbuttons,
- newButton(
- "Easy",
- function()
- hardmanager("easy")
- end,
- false
- )
- )
- table.insert(
- difbuttons,
- newButton(
- "Normal",
- function()
- hardmanager("normal")
- end,
- false
- )
- )
- table.insert(
- difbuttons,
- newButton(
- "Hard",
- function()
- hardmanager("hard")
- end,
- false
- )
- )
- table.insert(
- difbuttons,
- newButton(
- "Smart",
- function()
- hardmanager("smart")
- end,
- false
- )
- )
- --table.insert(
- -- settings,
- -- newButton(
- -- "Change Map",
- -- function()
- -- MAP_TYPE = MAP_TYPE + 1
- -- end
- -- )
- --)
- table.insert(
- settings,
- newButton(
- "Toggle Fullscreen",
- function()
- myscreen:toggle(VIRTUAL_HEIGHT, VIRTUAL_WIDTH)
- DIFFERENCE_X = myscreen.c
- DIFFERENCE_Y = myscreen.d
- OFFSET_X = myscreen.e
- OFFSET_Y = myscreen.f
- end,
- true
- )
- )
- if isAndroid then
- table.insert(
- buttons,
- newButton(
- "Toggle Music",
- function()
- if mute then
- musicController("mute", 0)
- else
- musicController("mute", 1)
- end
- end,
- true
- )
- )
- end
- table.insert(
- settings,
- newButton(
- "Toggle Music",
- function()
- if mute then
- musicController("mute", 0)
- else
- musicController("mute", 1)
- end
- end,
- true
- )
- )
- table.insert(
- settings,
- newButton(
- "Editor",
- function()
- gameState = "editor"
- end,
- true
- )
- )
- table.insert(
- settings,
- newButton(
- "Speed Settings",
- function()
- gameState = "speedSettings"
- end,
- true
- )
- )
- table.insert(
- settings,
- newButton(
- "Control Settings",
- function()
- gameState = "controlSettings"
- end,
- false
- )
- )
- table.insert(
- settings,
- newButton(
- "Back to Menu",
- function()
- gameState = "menu"
- end,
- false
- )
- )
- table.insert(
- speedParameters,
- newButton(
- "Back to Menu",
- function()
- gameState = "windowsettings"
- end,
- false
- )
- )
- --table.insert(speedParameters, newButton("Ball Speed: ", function() speedSetter('ball') end))
- table.insert(
- playerCountButtons,
- newButton(
- "Ball Speed: ",
- function()
- speedSetter("ball")
- end,
- true
- )
- )
- --table.insert(speedParameters, newButton("snc", function() speedSetter('snc') end))
- table.insert(
- playerCountButtons,
- newButton(
- "snc",
- function()
- speedSetter("snc")
- end,
- true
- )
- )
- table.insert(
- speedParameters,
- newButton(
- "NUCLEAR MODE",
- function()
- speedSetter("nuclearmod")
- end,
- true
- )
- )
- table.insert(
- controlSettings,
- newButton(
- "1up",
- function()
- gameState = "assign"
- req = "p1up"
- end,
- true
- )
- )
- table.insert(
- controlSettings,
- newButton(
- "1down",
- function()
- gameState = "assign"
- req = "p1down"
- end,
- true
- )
- )
- table.insert(
- controlSettings,
- newButton(
- "1special",
- function()
- gameState = "assign"
- req = "p1super"
- end,
- true
- )
- )
- table.insert(
- controlSettings,
- newButton(
- "1ct",
- function()
- gameState = "assign"
- req = "p1ct"
- end,
- true
- )
- )
- table.insert(
- controlSettings,
- newButton(
- "2up",
- function()
- gameState = "assign"
- req = "p2up"
- end,
- true
- )
- )
- table.insert(
- controlSettings,
- newButton(
- "2down",
- function()
- gameState = "assign"
- req = "p2down"
- end,
- true
- )
- )
- table.insert(
- controlSettings,
- newButton(
- "2special",
- function()
- gameState = "assign"
- req = "p2super"
- end,
- true
- )
- )
- table.insert(
- controlSettings,
- newButton(
- "2ct",
- function()
- gameState = "assign"
- req = "p2ct"
- end,
- true
- )
- )
- table.insert(
- controlSettings,
- newButton(
- "Default",
- function()
- p1control = {up = "a", down = "z", super = "s", counter = "x"}
- p2control = {up = ";", down = ".", super = "l", counter = ","}
- end,
- true
- )
- )
- table.insert(
- controlSettings,
- newButton(
- "Return",
- function()
- gameState = "windowsettings"
- end,
- false
- )
- )
- table.insert(
- modeSelectorButtons,
- newButton(
- "Nuclear Pong",
- function()
- gameState = "difficulty"
- end,
- false
- )
- )
- table.insert(
- modeSelectorButtons,
- newButton(
- "Main Menu",
- function()
- gameState = "menu"
- end,
- false
- )
- )
- table.insert(
- pracdiff,
- newButton(
- "Silverblade",
- function()
- speedSetter("practice")
- end,
- false
- )
- )
- table.insert(
- pracdiff,
- newButton(
- "Return",
- function()
- speedSetter("reset")
- gameState = "gameMode"
- end,
- false
- )
- )
- table.insert(
- pracdiff,
- newButton(
- "Go!",
- function()
- gameMode = "practice"
- hardmanager("practice")
- end,
- false
- )
- )
- --table.insert(playerCountButtons, newButton("1v1", function() speedSetter('pc') end))
- table.insert(
- playerCountButtons,
- newButton(
- "ballCount",
- function()
- speedSetter("ballz")
- end,
- true
- )
- )
- table.insert(
- difbuttons,
- newButton(
- "ballCount",
- function()
- speedSetter("ballz")
- end,
- true
- )
- )
- table.insert(
- playerCountButtons,
- newButton(
- "Return",
- function()
- speedSetter("reset")
- gameState = "menu"
-
- end,
- false
- )
- )
- table.insert(
- playerCountButtons,
- newButton(
- "ptw",
- function()
- speedSetter("ptw")
- end,
- true
- )
- )
- table.insert(
- playerCountButtons,
- newButton(
- "Play",
- function()
- AGAINST_AI = 0
- gameState = "1serve"
- globalState = "base"
- end,
- false
- )
- )
- table.insert(
- playerCountButtons,
- newButton(
- "Reverse Play",
- function()
- gameState = "1serve"
- gameMode = "reversegame"
- globalState = "base"
- end,
- false
- )
- )
-
- --table.insert(speedParameters, newButton("Ball Speed: ", function() speedSetter() end))
-
- love.window.setTitle("NUCLEAR PONG")
- textphrases = {
- "Amazing",
- "Superb",
- "Absolutely beautiful!",
- "Awesome",
- "Look at That!",
- "Great",
- "Nice",
- "Boom!",
- "Dangerous!",
- "Astonishing!",
- "u/ebernerd saved me",
- "Absolutely Wonderful!",
- "Exsquisite",
- "Delicate",
- "Pow!",
- "Great Hit",
- "all hail nazarbayev"
- }
- sounds = {
- ["updateMusic"] = love.audio.newSource("audio/theme1.mp3", "static"),
- ["gayTheme"] = love.audio.newSource("audio/theme2.mp3", "static"),
- ["gayTheme2"] = love.audio.newSource("audio/theme3.mp3", "static"),
- ["gayTheme3"] = love.audio.newSource("audio/theme4.mp3", "static"),
- ["gayTheme4"] = love.audio.newSource("audio/theme5.mp3", "static"),
- ["beep"] = love.audio.newSource("audio/hit1.mp3", "static"),
- ["wallhit"] = love.audio.newSource("audio/hit2.wav", "static"),
- ["win"] = love.audio.newSource("win.wav", "static"),
- ["score"] = love.audio.newSource("audio/score.wav", "static"),
- ["nuke"] = love.audio.newSource("audio/bomb.wav", "static"),
- ["striking"] = love.audio.newSource("audio/superhit.wav", "static"),
- ["nuclearhit"] = love.audio.newSource("audio/hit1.mp3", "static"),
- ["time"] = love.audio.newSource("audio/time.wav", "static")
- }
- love.graphics.setDefaultFilter("nearest", "nearest")
- --comic sans lmao
- math.randomseed(os.time())
- smallfont = love.graphics.newFont("font.ttf", 25)
- scorefont = love.graphics.newFont("font.ttf", 60)
- love.graphics.setFont(smallfont)
-
- --push:setupScreen(VIRTUAL_WIDTH, VIRTUAL_HEIGHT, WINDOW_WIDTH, WINDOW_HEIGHT, {
- -- fullscreen = isFullscreen,
- -- resizable = true,
- -- vsync = true,
- --})
- love.window.setVSync( 0 )
- player1score = 0
- player2score = 0
- areanuclear = 0
- player1nukescore = 0
- player2nukescore = 0
- striken = 0
- soundtype = 1
- soundturn = 1
- potentialstrike1 = 0
- potentialstrike2 = 0
- potentialnuke1 = 0
- potentialnuke2 = 0
- player1striken = 0
- player2striken = 0
- randomtext = 0
- selecting = 0
- number = 0
- elec = 1
- INDIC = {
- "",
- "",
- "",
- ""
- }
- --playe1nuke
- player1 = paddle(0, 30, 10, 100, 1)
- player2 = paddle(VIRTUAL_WIDTH * 0.99, VIRTUAL_HEIGHT * 0.88, 10, 100, 2)
- player3 = paddle(5000, 5000, 10, 100)
- player4 = paddle(5000, 5000, 10, 100)
- ball = {}
- explosions = {}
- ball[1] = eball(VIRTUAL_WIDTH / 2, VIRTUAL_HEIGHT / 2 - 2, 16, 16)
- ball[2] = eball(VIRTUAL_WIDTH / 1.9, VIRTUAL_HEIGHT / 2 - 2, 16, 16)
- ball[3] = eball(VIRTUAL_WIDTH / 1.8, VIRTUAL_HEIGHT / 2 - 2, 16, 16)
- ball[4] = eball(VIRTUAL_WIDTH / 2.2, VIRTUAL_HEIGHT / 2 - 2, 16, 16)
- ball[5] = eball(VIRTUAL_WIDTH / 2.1, VIRTUAL_HEIGHT / 2 - 2, 16, 16)
- myscreen = fullScreener(RESOLUTION_SET, isFullscreen, DIFFERENCE_X, DIFFERENCE_Y, OFFSET_X, OFFSET_Y)
- if isAndroid then
- myscreen:toggle(VIRTUAL_HEIGHT, VIRTUAL_WIDTH)
- DIFFERENCE_X = myscreen.c
- DIFFERENCE_Y = myscreen.d
- OFFSET_X = myscreen.e
- OFFSET_Y = myscreen.f
- end
- 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)
-
- gameState = "animation"
- end
- t = 0
- shakeDuration = 0
- shakeMagnitude = 1
- function startShake(duration, magnitude)
- t, shakeDuration, shakeMagnitude = 0, duration or 1, magnitude or 5
- end
- function displayFPS()
- love.window.setTitle(love.timer.getFPS())
- --love.window.setTitle(globalState .. " " .. gameState .. " " .. paddle_SPEED .. " " .. p1bonus .. " " .. player1.dy)
- if love.keyboard.isDown("space") then
- player1nukescore = 200
- player1score = player1score + 0.2
- player2nukescore = 200
- end
-
- end
-
- function speedControl()
- if (ballSpeed > maxspeed and gameState == "play") then
- ballSpeed = maxspeed
- background_scroll_speed = ballSpeed / 20
- end
- end
- checking = 0
- local countinglowcpu = 0
- function love.update(dt)
- --checking = checking + 1
- --print(checking)
- --print("IMPORTANT!!!!!" .. globalState .. gameState)
- if globalMessage ~= "none" then
- globalMessageTime = globalMessageTime + dt
- if globalMessageTime > 10 then
- globalMessage = "none"
- end
- end
- if not lowcpu then
- if (love.timer.getFPS() < 50 and gameState ~= "animation") then
- countinglowcpu = countinglowcpu + 1
- if countinglowcpu > 30 then
- lowcpu = true
- globalMessage = "[color=#00ff00][bounce]Low-end mode enabled[/bounce][/color]"
- end
- end
- end
- for i, explosion in ipairs(explosions) do
- explosion:update(dt)
- end
- staticanimatorcounter(dt)
- player1.goal = -1
- player2.goal = -1
- if gameState == "chooseIP" then
- checkCurrentServer(dt)
- end
- if debug then
- displayFPS()
- --print(player2.y .. " " .. player2.goal .. " " .. player2.dy .. " " .. AI_SPEED .. " " .. paddle_SPEED .. " " .. lastSentKeyClient)
- end
- if globalState == "base" and not paused then
- basegame(dt)
- end
- if globalState == "menu" then
- debugCheck(dt)
- if gameState ~= "animation" then
- menuDemo(dt)
- end
- end
- if gameState ~= "animation" then
- musicController('norm', 1)
-
- end
- if globalState == "nettest" then
- --print("Confcode: " .. confirmation)
- if confirmation == "N" then
- basegame(dt)
- end
- nettest(dt)
-
- end
- if globalState == "selfhost" then
- --print("Confcode: " .. confirmation)
- if confirmation == "N" then
- globalState = "nettest"
- basegame(dt)
- end
- globalState = "selfhost"
- selfHost(dt)
- IP = "127.0.0.1"
-
- end
- if globalState == "clienttest" then
- ts = ts + dt
- if confirmation == "N" then
- lastSentKeyP1 = lastSentKeyClient
- clientsBaseGame(dt)
- end
- clienttest(dt)
- end
-
- end
- serverinit = false
- dserverinit = false
- datawaspassedtimer = 0
- clientinit = false
- function love.textinput(t)
- if gameState == "chooseIP" then
- IPnew = IPnew .. t
- end
- end
- function nettest(dt)
- --print("nettest running")
- if serverinit == false then
- local socket = require "socket"
- local address, port = IP, 12345
- --print(address)
- udp = socket.udp()
- udp:setpeername(address, port)
- udp:settimeout(0)
- serverinit = true
- end
- if isAndroid then
- if table.empty(touches) then
- lastSentKey = "g"
- end
- end
- for i = 1, maxBalls do
- ts = ts + dt
- if ts > updaterate then
- udp:send(tostring(lastSentKey) ..
- '|' .. tostring(ball[1].dy) ..
- '|' .. tostring(player2.y) ..
- '|' .. tostring(player1.y) ..
- '|' .. tostring(player1score) ..
- '|' .. tostring(player2score) ..
- '|' .. tostring(player1nukescore) ..
- '|' .. tostring(player2nukescore) ..
- '|' .. tostring(ball[1].x) ..
- '|' .. tostring(ball[1].y) ..
- '|' .. gameState ..
- '|' .. tostring(ball[1].dx) ..
- '|' .. tostring(ballSpeed) ..
- '|' .. tostring(paddle_SPEED) ..
- '|' .. tostring(player1striken) ..
- '|' .. tostring(areanuclear) ..
- "|HOST")
- ts = 0
- end
- end
-
- local data
- local datanumtest = 0
- local datawaspassed = false
- repeat
- datanumtest = datanumtest + 1
- --print("LATENCY: " .. tostring(datanumtest))
- data = udp:receive()
- if data then
- datawaspassed = true
- --print("ReceivedINFO: " .. data)
- confirmation = "N"
- local p = split(data, '|')
- if p[17] then
- if tonumber(p[18]) > 90 then
- confirmation = "L"
- end
- if p[17] ~= "CLIENT" then
- confirmation = "U"
- end
- elseif p[1] == "RESPONSE" then
- if p[2] == "1" then
-
- elseif p[2] == "2" then
-
- elseif p[2] == "3" then
- end
- else
- confirmation = "U"
- end
-
- if p[17] then
- if ball[1].disabled and ball[1].x > 20 and ball[1].x < VIRTUAL_WIDTH - 20 then
- ball[1].disabled = false
- --print("illegal disabling")
- end
- if gameState ~= "1serve" then
- if (ball[1].x > VIRTUAL_WIDTH/2) then
- if tonumber(p[9]) > VIRTUAL_WIDTH/2 then
- die = tonumber(p[2])
- lastSentKeyClient,
- ball[1].dy,
- player2.y,
- player1score,
- player2score,
- player1nukescore,
- player2nukescore,
- ball[1].x,
- ball[1].y,
- gameState,
- ball[1].dx,
- ballSpeed,
- paddle_SPEED,
- player2striken,
- areanuclear = p[1], die, tonumber(p[4]), tonumber(p[5]), tonumber(p[6]), tonumber(p[7]), tonumber(p[8]), tonumber(p[9]), tonumber(p[10]), p[11], tonumber(p[12]), tonumber(p[13]), tonumber(p[14]), tonumber(p[15]), tonumber(p[16])
- --print("ACCEPTED")
- else
- --print("DECLINED")
- end
- else
- if tonumber(p[9]) > VIRTUAL_WIDTH/2 then
- die = tonumber(p[2])
- lastSentKeyClient,
- ball[1].dy,
- player2.y,
- player1score,
- player2score,
- player1nukescore,
- player2nukescore,
- ball[1].x,
- ball[1].y,
- gameState,
- ball[1].dx,
- ballSpeed,
- paddle_SPEED, player2striken,
- areanuclear = p[1], die, tonumber(p[4]), tonumber(p[5]), tonumber(p[6]), tonumber(p[7]), tonumber(p[8]), tonumber(p[9]), tonumber(p[10]), p[11], tonumber(p[12]), tonumber(p[13]), tonumber(p[14]), tonumber(p[15]), tonumber(p[16])
- --print("ACCEPTED")
- else
- --print("ENFORCED" .. ball[1].x .. " " .. ball[1].dx)
- lastSentKeyClient = p[1]
- player2striken = tonumber(p[15])
- player2.y = tonumber(p[4])
- end
- end
- end
- end
- end
- until not data
- if not datawaspassed then
- datawaspassedtimer = datawaspassedtimer + 1
- if datawaspassedtimer > 15 then
- confirmation = "D"
- datawaspassedtimer = 0
- end
- else
- datawaspassedtimer = 0
- end
- end
- function clienttest(dt)
- if clientinit == false then
- local socket = require "socket"
- local address, port = IP, 12345
-
- udp = socket.udp()
- udp:setpeername(address, port)
- udp:settimeout(0)
- clientinit = true
- end
- if isAndroid then
- if table.empty(touches) then
- lastSentKey = "g"
- end
- end
- ts = ts + dt
- if ts > updaterate then
- udp:send(tostring(lastSentKey) ..
- '|' .. tostring(ball[1].dy) ..
- '|' .. tostring(player1.y) ..
- '|' .. tostring(player2.y) ..
- '|' .. tostring(player1score) ..
- '|' .. tostring(player2score) ..
- '|' .. tostring(player1nukescore) ..
- '|' .. tostring(player2nukescore) ..
- '|' .. tostring(ball[1].x) ..
- '|' .. tostring(ball[1].y) ..
- '|' .. gameState ..
- '|' .. tostring(ball[1].dx) ..
- '|' .. tostring(ballSpeed) ..
- '|' .. tostring(paddle_SPEED) ..
- '|' .. tostring(player2striken) ..
- '|' .. tostring(areanuclear) ..
- "|CLIENT")
- ts = 0
- end
- local data
- local datanumtest = 0
- local datawaspassed = false
- repeat
- datanumtest = datanumtest + 1
- --print("LATENCY: " .. tostring(datanumtest))
- data = udp:receive()
-
- if data then
- --print("RECEIVED DATA: " .. data)
- datawaspassed = true
- --print("SENT TO SERVER:" .. lastSentKey)
- confirmation = "N"
- local p = split(data, '|')
- if p[17] then
- if p[17] ~= "HOST" then
- confirmation = "U"
- end
- if tonumber(p[18]) > 90 then
- confirmation = "L"
- end
- for i = 1, maxBalls do
- local die = tonumber(p[2])
- if (ball[i].x <= VIRTUAL_WIDTH/2) then
- if tonumber(p[9]) <= VIRTUAL_WIDTH/2 then
- lastSentKeyClient, ball[i].dy, player1.y, player1score, player2score, player1nukescore, player2nukescore, ball[i].x, ball[i].y, gameState, ball[i].dx, ballSpeed, paddle_SPEED, player1striken, areanuclear = p[1], die, tonumber(p[4]), tonumber(p[5]), tonumber(p[6]), tonumber(p[7]), tonumber(p[8]), tonumber(p[9]), tonumber(p[10]), p[11], tonumber(p[12]), tonumber(p[13]), tonumber(p[14]), tonumber(p[15]), tonumber(p[16])
- --print("ACCEPTED")
- else
- --print("DECLINED")
- end
- else
- if tonumber(p[9]) <= VIRTUAL_WIDTH/2 then
- lastSentKeyClient, ball[i].dy, player1.y, player1score, player2score, player1nukescore, player2nukescore, ball[i].x, ball[i].y, gameState, ball[i].dx, ballSpeed, paddle_SPEED, player1striken, areanuclear = p[1], die, tonumber(p[4]), tonumber(p[5]), tonumber(p[6]), tonumber(p[7]), tonumber(p[8]), tonumber(p[9]), tonumber(p[10]), p[11], tonumber(p[12]), tonumber(p[13]), tonumber(p[14]), tonumber(p[15]), tonumber(p[16])
- --print("REROUTED")
- else lastSentKeyClient = p[1]
- player1.y = tonumber(p[4])
- player1striken = tonumber(p[15])
- --print("ENFORCED")
- end
- end
- end
- else
- confirmation = "U"
- end
- end
- --print("GOT: " .. lastSentKeyClient)
- until not data
- if not datawaspassed then
- datawaspassedtimer = datawaspassedtimer + 1
- if datawaspassedtimer > 15 then
- confirmation = "D"
- datawaspassedtimer = 0
- end
- else
- datawaspassedtimer = 0
- end
- end
- function wallbreaker(x, y)
- if (gameState == "editor") then
- for i, wall in ipairs(walls) do
- if math.abs(wall.wallx - x) < 10 and math.abs(wall.wally - y) < 10 then
- table.remove(walls, i)
- end
- end
- end
- end
-
- function hardmanager(diff)
- selecting = 1
- if (diff == "easy") then
- INDIC[1] = ">"
- AGAINST_AI = 1
- AI_SPEED = ballSet
- AI_STRIKEMOD = 100
- AI_NUKEMOD = 1000
- AI_LEVEL = 350
- difficultyl = 200
- selecting = 0
- gameState = "1serve"
- globalState = "base"
- end
- if (diff == "normal") then
- INDIC[2] = ">"
- AI_SPEED = ballSet
- AI_LEVEL = 500
- AI_NUKEMOD = 250
- AI_STRIKEMOD = 60
- AGAINST_AI = 1
- difficultyl = 300
- selecting = 0
- gameState = "1serve"
- globalState = "base"
- end
- if (diff == "hard") then
- INDIC[3] = ">"
- AI_SPEED = ballSpeed * 1.1 + 50
- AI_LEVEL = 700
- AI_NUKEMOD = 200
- AI_STRIKEMOD = 20
- selecting = 0
- difficultyl = 350
- AGAINST_AI = 1
- gameState = "1serve"
- globalState = "base"
- end
- if (diff == "smart") then
- INDIC[3] = ">"
- AI_SPEED = ballSpeed * 1.1 + 50
- AI_LEVEL = 1500
- AI_NUKEMOD = 200
- AI_STRIKEMOD = 20
- selecting = 0
- difficultyl = 350
- AGAINST_AI = 1
- gameState = "1serve"
- globalState = "base"
- end
- if (diff == "practice") then
- INDIC[3] = ">"
- AI_SPEED = ballSpeed * 500 + 50
- AI_LEVEL = 700
- AI_NUKEMOD = 9000000000
- AI_STRIKEMOD = 90000000
- selecting = 0
- difficultyl = 350
- AGAINST_AI = 1
- gameState = "base"
- end
- end
-
- function dangerChecker() --CHECK IF CONTROLS ARE DUPLICATING
- if (p1control.up == p1control.down) then
- danger = "1up"
- danger2 = "1down"
- elseif (p1control.up == p1control.super) then
- danger = "1up"
- danger2 = "1special"
- elseif (p1control.up == p1control.counter) then
- danger = "1up"
- danger2 = "1ct"
- elseif (p1control.down == p1control.super) then
- danger = "1down"
- danger2 = "1special"
- elseif (p1control.down == p1control.counter) then
- danger = "1ct"
- danger2 = "1down"
- elseif (p1control.super == p1control.counter) then
- danger = "1special"
- danger2 = "1ct"
- elseif (p2control.down == p2control.up) then
- danger = "2down"
- danger2 = "2up"
- elseif (p2control.down == p2control.super) then
- danger = "2down"
- danger2 = "2special"
- elseif (p2control.down == p2control.counter) then
- danger = "2down"
- danger2 = "2ct"
- elseif (p2control.up == p2control.super) then
- danger = "2up"
- danger2 = "2special"
- elseif (p2control.up == p2control.counter) then
- danger = "2ct"
- danger2 = "2up"
- elseif (p2control.super == p2control.counter) then
- danger = "2special"
- danger2 = "2ct"
- else
- danger = "none"
- danger2 = "none"
- end
- end
- function love.keypressed(key)
- if not isAndroid then
- lastSentKey = key
- end
-
- if gameState == "chooseIP" then
- if key == "backspace" then
- -- get the byte offset to the last UTF-8 character in the string.
- local byteoffset = utf8.offset(IPnew, -1)
-
- if byteoffset then
- -- remove the last UTF-8 character.
- -- string.sub operates on bytes rather than UTF-8 characters, so we couldn't do string.sub(text, 1, -2).
- IPnew = string.sub(IPnew, 1, byteoffset - 1)
- end
- end
- end
- if gameState == "assign" then
- if (req == "p1up") then
- p1control.up = key
- currentKey = key
- --love.window.setTitle(key)
- gameState = "controlSettings"
- end
- if (req == "p2up") then
- p2control.up = key
- currentKey = key
- --love.window.setTitle(key)
- gameState = "controlSettings"
- end
- if (req == "p1down") then
- p1control.down = key
- currentKey = key
- --love.window.setTitle(key)
- gameState = "controlSettings"
- end
- if (req == "p2down") then
- p2control.down = key
- currentKey = key
- -- love.window.setTitle(key)
- gameState = "controlSettings"
- end
- if (req == "p1super") then
- p1control.super = key
- currentKey = key
- -- love.window.setTitle(key)
- gameState = "controlSettings"
- end
- if (req == "p2super") then
- p2control.super = key
- currentKey = key
- -- love.window.setTitle(key)
- gameState = "controlSettings"
- end
- if (req == "p1ct") then
- p1control.counter = key
- currentKey = key
- -- love.window.setTitle(key)
- gameState = "controlSettings"
- end
- if (req == "p2ct") then
- p2control.counter = key
- currentKey = key
- --love.window.setTitle(key)
- gameState = "controlSettings"
- end
- end
- if key == "escape" then
- if not isAndroid and globalState == "base" and gameState ~= "done" then
- if paused then
- paused = false
- TEXT = "Let's Continue"
- else
- paused = true
- TEXT = "PAUSED"
- end
-
- end
- elseif key == "enter" or key == "return" then
- if gameState == "start" then
- resettinggenius()
- gameState = "menu"
- ball[1].dx = 1
- ball[1].dy = 1
- globalState = "menu"
- hardmanager()
- elseif (gameState == "done") then
- if (player1score > player2score) then
- gameState = "2serve"
- potentialnuke1 = 0
- potentialnuke2 = 0
- striken = 0
- if (nuckemodactive == 0) then
- areanuclear = 0
- nuclearanimation = 3
- end
- potentialstrike1 = 0
- potentialstrike2 = 0
- player1nukescore = 0
- player2nukescore = 0
- else
- gameState = "1serve"
- resettinggenius()
- for i = 1, maxBalls do
- ball[i]:reset(i, 1)
- end
- end
- else
- gameState = "menu"
- ball[1].dx = 1
- ball[1].dy = 1
- globalState = "menu"
- if (love.math.random(0, 20) == 1) then
- TEXT = "Nuclear Ching Chong"
- else
- TEXT = "Nuclear Pong"
- end
- resettinggenius()
- for i = 1, maxBalls do
- ball[i]:reset(i)
- end
- end
- end
- end
-
- function love.keyreleased(key)
- currentKey = " "
- if lastSentKey == key and not isAndroid then
- lastSentKey = "g"
- end
- end
- function speedSetter(requesttype)
- if (requesttype == "ball") then
- if (ballSet > 550) then
- ballSet = 0
- paddle_SPEED = 0
- else
- ballSet = ballSet + 50
- paddle_SPEED = paddle_SPEED + 5
- end
- ballSpeed = ballSet
- background_scroll_speed = ballSpeed / 20
- end
- if (requesttype == "snc") then
- synctype = synctype + 1
- if (synctype > 1) then
- synctype = 0
- end
-
- if synctype == 0 then
- synctext = "Independent"
- end
- if synctype == 1 then
- synctext = "Synchronised"
- end
- end
- if (requesttype == "nuclearmod") then
- nuckemodactive = nuckemodactive + 1
- if (nuckemodactive > 1) then
- nuckemodactive = 0
- end
- if (nuckemodactive == 0) then
- areanuclear = 0
- nuclearanimation = 3
- ballSet = 200
- TEXT = "Nuclear Pong"
-
- synctype = 0
- maxspeed = 700
- synctext = "Independent"
- paddle_SPEED = ballSet
- AI_SPEED = ballSet
- end
- if (nuckemodactive == 1) then
- areanuclear = 1
- ballSet = 2000
- maxspeed = 2000
- paddle_SPEED = ballSet
- AI_SPEED = ballSet
- 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
- prtext = "Insane"
- maxBalls = 5
- elseif ballSpeed > 599 then
- prtext = "Hard"
- maxBalls = 4
- elseif ballSpeed > 399 then
- prtext = "Normal"
- maxBalls = 3
- elseif ballSpeed > 199 then
- prtext = "Easy"
- maxBalls = 3
- end
- ballSpeed = ballSpeed + 200
- 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"
- maxBalls = 1
- end
- if (requesttype == "pc") then
- if (playerCount == 2) then
- playerCount = 1
- playertext = "1v1"
- elseif (playerCount == 1) then
- playerCount = playerCount + 1
- player3.x = player1.x + VIRTUAL_WIDTH / 2
- player3.y = player3.y
- playertext = "2v2"
- end
- end
- if (requesttype == "ballz") then
- if (maxBalls > 1) then
- --love.window.setTitle("more than 4")
- maxBalls = 1
- else
- maxBalls = maxBalls + 1
- end
- end
- if requesttype == "ptw" then
- if ptw == 10 then
- ptw = 1
- else
- ptw = ptw + 1
- end
- end
- end
-
- function gameModeChanger()
- if (gameState == "gameMode") then
- local button_width = VIRTUAL_WIDTH * (1 / 3)
- local BUTTON_HEIGHT = 50
- local margin = 20
- local hot = false
- local cursor_y = 0
- local total_height = (BUTTON_HEIGHT + margin) * #buttons
- for i, button in ipairs(modeSelectorButtons) do
- button.last = button.now
- local bx = (VIRTUAL_WIDTH * 0.5) - (button_width * 0.5)
- local by = (VIRTUAL_HEIGHT * 0.5) - (total_height * 0.5) + cursor_y
- local color = {255, 255, 255, 255}
- local mx, my = love.mouse.getPosition()
- mx = mx
- my = my
- mx = mx * DIFFERENCE_X
- my = my * DIFFERENCE_Y
- hot = (mx > bx and mx < bx + button_width and my > by and my < by + BUTTON_HEIGHT) and i
- if (hot == i) then
- color = {10, 10, 0, 255}
- end
- button.now = love.mouse.isDown(1)
- if button.now and not button.last and hot == i then
- love.graphics.setColor(0, 0, 0, 1)
- love.graphics.rectangle("fill", 0, 0, VIRTUAL_WIDTH, VIRTUAL_HEIGHT)
- sounds["wallhit"]:play()
- button.fn()
- end
- love.graphics.setColor(unpack(color))
- love.graphics.rectangle("fill", bx, by, button_width, BUTTON_HEIGHT)
- love.graphics.setColor(0, 0, 0, 255)
- local textW = smallfont:getWidth(button.text)
- local textH = smallfont:getHeight(button.text)
- love.graphics.print(button.text, smallfont, VIRTUAL_WIDTH * 0.5 - textW * 0.5, by + textH * 0.5)
- love.graphics.setColor(255, 255, 255, 255)
- cursor_y = cursor_y + (BUTTON_HEIGHT + margin)
- end
- end
- if (gameState == "multiMode") then
- local button_width = VIRTUAL_WIDTH * (1 / 3)
- local BUTTON_HEIGHT = 50
- local margin = 20
- local hot = false
- local cursor_y = 0
- local total_height = (BUTTON_HEIGHT + margin) * #buttons
- for i, button in ipairs(playerCountButtons) do
- button.last = button.now
-
- local bx = (VIRTUAL_WIDTH * 0.5) - (button_width * 0.5)
-
- local by = (VIRTUAL_HEIGHT * 0.3) - (total_height * 0.5) + cursor_y
- if (button.text == "Play") then
- by = by + by / 1.8
- end
- local color = {255, 255, 255, 255}
- local mx, my = love.mouse.getPosition()
- mx = mx
- my = my
- mx = mx * DIFFERENCE_X
- my = my * DIFFERENCE_Y
- hot = (mx > bx and mx < bx + button_width and my > by and my < by + BUTTON_HEIGHT) and i
- if (hot == i) then
- if (button.text == "Play") then
- color = {0 / 255, 255 / 255, 0 / 255, 255}
- else
- color = {10, 10, 0, 255}
- end
- end
- button.now = love.mouse.isDown(1)
- if button.now and not button.last and hot == i then
- love.graphics.setColor(0, 0, 0, 1)
- love.graphics.rectangle("fill", 0, 0, VIRTUAL_WIDTH, VIRTUAL_HEIGHT)
- sounds["wallhit"]:play()
- if button.text == "Ball Speed: " and nuckemodactive == 1 then
- else
- button.fn()
- end
- end
- love.graphics.setColor(unpack(color))
- love.graphics.rectangle("fill", bx, by, button_width, BUTTON_HEIGHT)
- love.graphics.setColor(0, 0, 0, 255)
- local textW = smallfont:getWidth(button.text)
- local textH = smallfont:getHeight(button.text)
- if (button.text == "1v1") then
- love.graphics.print(playertext, smallfont, VIRTUAL_WIDTH * 0.5 - textW * 0.5, by + textH * 0.5)
- elseif button.text == "snc" then
- if (nuckemodactive == 1) then
- love.graphics.setColor(1, 0, 0, 1)
- love.graphics.print(synctext, smallfont, VIRTUAL_WIDTH * 0.5 - textW * 0.5, by + textH * 0.5)
- love.graphics.setColor(1, 1, 1, 1)
- love.graphics.print(synctext, smallfont, VIRTUAL_WIDTH * 0.5 - textW * 0.5, by + textH * 0.5)
- love.graphics.setColor(0, 0, 0, 1)
- else
- --
- love.graphics.print(synctext, smallfont, VIRTUAL_WIDTH * 0.45 - textW * 0.5, by + textH * 0.5)
- end
- elseif (button.text == "ballCount") then
- love.graphics.print(
- "Ball Count: " .. maxBalls,
- smallfont,
- VIRTUAL_WIDTH * 0.5 - textW * 0.5,
- by + textH * 0.5
- )
- elseif (button.text == "Ball Speed: ") then
- if (nuckemodactive == 1) then
- love.graphics.setColor(1, 0, 0, 1)
- love.graphics.print(
- "shaitan machina",
- smallfont,
- VIRTUAL_WIDTH * 0.5 - textW * 0.5,
- by + textH * 0.5
- )
- love.graphics.setColor(1, 1, 1, 1)
- love.graphics.print(
- "shaitan machina",
- smallfont,
- VIRTUAL_WIDTH * 0.5 - textW * 0.5,
- by + textH * 0.5
- )
- love.graphics.setColor(0, 0, 0, 1)
- else
- love.graphics.print(
- button.text .. ballSet,
- smallfont,
- VIRTUAL_WIDTH * 0.5 - textW * 0.5,
- by + textH * 0.5
- )
- end
- elseif button.text == "ptw" then
- love.graphics.print(
- "Points to Win: " .. ptw,
- smallfont,
- VIRTUAL_WIDTH * 0.5 - textW * 1.5,
- by + textH * 0.5
- )
- else
- love.graphics.print(button.text, smallfont, VIRTUAL_WIDTH * 0.5 - textW * 0.5, by + textH * 0.5)
- end
- love.graphics.setColor(255, 255, 255, 255)
- cursor_y = cursor_y + (BUTTON_HEIGHT + margin)
- end
- end
- end
-
- function love.draw(dt)
- simpleScale.set()
-
- if globalState == "selfhost" then
- globalState = "nettest"
- baseDraw()
- globalState = "selfhost"
- else
- baseDraw()
- end
- if (globalState == "nettest" or globalState == "clienttest" or globalState == "selfhost") and confirmation == "D" then
- love.graphics.clear(50 / 255, 50 / 255, 50 / 255, 255)
- love.graphics.printf("WAIT FOR OPPONENT", 0, VIRTUAL_HEIGHT / 2, VIRTUAL_WIDTH, "center")
- end
- if (globalState == "nettest" or globalState == "clienttest" or globalState == "selfhost") and confirmation == "U" then
- love.graphics.clear(50 / 255, 50 / 255, 50 / 255, 255)
- love.graphics.printf("LOBBY FULL OR WRONG MODE CHOSEN", 0, VIRTUAL_HEIGHT / 2, VIRTUAL_WIDTH, "center")
- end
- if (globalState == "nettest" or globalState == "clienttest" or globalState == "selfhost") and confirmation == "L" then
- love.graphics.clear(50 / 255, 50 / 255, 50 / 255, 255)
- love.graphics.printf("POOR CONNECTION TO SERVER", 0, VIRTUAL_HEIGHT / 2, VIRTUAL_WIDTH, "center")
- end
- if (globalState == "nettest" or globalState == "clienttest" or globalState == "selfhost") and confirmation == "S" then
- love.graphics.clear(50 / 255, 50 / 255, 50 / 255, 255)
- love.graphics.printf("INTERNAL SERVER WAITING", 0, VIRTUAL_HEIGHT / 2, VIRTUAL_WIDTH, "center")
- love.graphics.printf(myip, 0, VIRTUAL_HEIGHT / 2 + 120, VIRTUAL_WIDTH, "center")
- end
- if isAndroid then
- androidDraw()
- love.keyboard.mouseisReleased = false
- end
- if debug then
- if touches then
- for i, touch in ipairs(touches) do
- love.graphics.printf(touch.x, 0, VIRTUAL_HEIGHT / 2, VIRTUAL_WIDTH, "center")
- end
- end
- end
- showMessage()
- if wallsLoadError then
- love.graphics.setColor(1,0,0,1)
- love.graphics.printf("Error loading map!", 0,0,VIRTUAL_WIDTH, "left")
- end
- simpleScale.unSet()
- end
-
- --Check if controls are duplicating
- function controllerSer()
- for i = 1, maxBalls do
- if (ball[i].dy == 0) then
- hitNum[i] = hitNum[i] + 1
- if hitNum[i] >= 10 then
- ball[i].dy = 1
- hitNum[i] = 0
- end
- else
- hitNum[i] = 0
- end
- end
- end
-
- function palleteController() --!!!!LEGACY CODE, MIGRATED TO Paddle.lua!!!!
- if (areanuclear == 0) then
- player1.RED = 1
- player1.GREEN = 1
- player1.BLUE = 1
- end
- if (areanuclear == 0) then
- player2.RED = 1
- player2.GREEN = 1
- player2.BLUE = 1
- end
- if (areanuclear == 1) then
- player1.RED = 0
- player1.GREEN = 0
- player1.BLUE = 0
- end
- if (areanuclear == 1) then
- player2.RED = 0
- player2.GREEN = 0
- player2.BLUE = 0
- end
- end
-
- function love.wheelmoved(x, y)
- if (y < 0 and wall1width > 0) then
- wall1width = wall1width - 5
- elseif y > 0 and wall1width < 900 then
- wall1width = wall1width + 5
- end
- end
-
- function serveBot() --THIS IS USED TO CHANGE TEXT/BALL DIRECTION ON DIFFERENT SERVES
- --print("servebot called")
- if (gameState == "1serve") then
- updateTEXT = ""
- if (gameMode ~= "practice") then
- if isAndroid then
- TEXT = "PLAYER 1, serve!(double-click)"
- else
- TEXT = "PLAYER 1, serve!(q)"
- end
- end
- if ((globalState ~= "clienttest" and love.keyboard.isDown("q")) or (globalState == "clienttest" and lastSentKeyP1 == "q") or doubleclick1) then
- TEXT = "Lets Begin!"
- doubleclick1 = false
- ball_DIR = 1
- if maxBalls == 1 then
- ball[1]:reset(1, 1)
- else
- for i = 1, maxBalls do
- ball[i]:reset(i)
- end
- end
- gameState = "play"
-
- end
- end
- if (gameState == "2serve") then
- if (gameMode ~= "practice") then
- if isAndroid then
- TEXT = "PLAYER 2, serve!(double-click)"
- else
- TEXT = "PLAYER 2, serve!(p)"
- end
- end
- if (AGAINST_AI == 1) then
- TEXT = ""
- doubleclick2 = false
- ball_DIR = -1
- if maxBalls == 1 then
- ball[2]:reset(i, 2)
- else
- for i = 1, maxBalls do
- ball[i]:reset(i)
- end
- end
-
- gameState = "play"
-
- end
- if (((globalState == "nettest" and lastSentKeyClient == "p") or ((globalState ~= "nettest") and love.keyboard.isDown("p")) or doubleclick2)and AGAINST_AI == 0) then
- TEXT = "Lets Begin"
- doubleclick2 = false
- ball_DIR = -1
- if maxBalls == 1 then
- ball[1]:reset(1, 2)
- else
- for i = 1, maxBalls do
- ball[i]:reset(i)
- end
- end
- --love.window.setTitle("An atttttttt")
- gameState = "play"
-
- end
- end
- end
- function mapChanger()
- if (gameState == "editor") then
- MAP_TYPE = 2
- end
- if (MAP_TYPE > 2) then
- MAP_TYPE = 0
- end
-
- end
- function resolutionChanger()
- if (RESOLUTION_SET > 1) then
- RESOLUTION_SET = 0
- end
- if (RESOLUTION_SET == 0) then
- if (isFullscreen == 1) then
- DIFFERENCE_X = 1
- DIFFERENCE_Y = 1
- OFFSET_X = 0
- OFFSET_Y = 0
- simpleScale.updateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, {fullscreen = false})
- isFullscreen = 0
- end
- end
- if (RESOLUTION_SET == 1) then
- if (isFullscreen == 0) then
- simpleScale.updateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, {fullscreen = true})
- local newWidth = love.graphics.getWidth()
- local newHeight = love.graphics.getHeight()
- DIFFERENCE_X = VIRTUAL_WIDTH / newWidth
- DIFFERENCE_Y = VIRTUAL_HEIGHT / newHeight
- OFFSET_X = math.fmod(newWidth, VIRTUAL_WIDTH) / 2
- OFFSET_Y = math.fmod(newHeight, VIRTUAL_HEIGHT) / 2
- isFullscreen = 1
- end
- end
- end
- function resettinggenius()
- maxBalls = 1
- for i = 1, maxBalls do
- ball[i]:reset(i)
- end
- paddle_SPEED = 200
- nuclearanimation = 3
- timeIsSlow = false
- timeIsSlow2 = false
- serverinit = false
- ts = 0
- originalSpeed = 200
- gameState = "menu"
- ball[1].dx = 1
- ball_DIR = 1
- ball[1].dy = 1
- globalState = "menu"
- gameMode = "normal"
- player1.height = 100
- player2.height = 100
- ballSet = 200
- ballSpeed = ballSet
- background_scroll_speed = ballSpeed / 20
- player2.GREEN = 255
- player2.BLUE = 255
- player1.GREEN = 255
- player1.BLUE = 255
- player1score = 0
- player2score = 0
- potentialnuke1 = 0
- potentialnuke2 = 0
- striken = 0
- areanuclear = 0
- potentialstrike1 = 0
- potentialstrike2 = 0
- player1nukescore = 0
- player2nukescore = 0
- player1reverbav = 0
- player2reverbav = 0
- selecting = 0
- AGAINST_AI = 0
- end
-
- function love.mousereleased(x, y, button)
- love.keyboard.mouseisReleased = true
- if (gameState == "editor") then
- if (#walls < 1000 and button == 1 and blockinput ~= true) then
- table.insert(walls, newWall((x ) * DIFFERENCE_Y , (y ) * DIFFERENCE_Y , 10, wall1width))
- end
- end
- end
-
- function ballsAlive()
- for i = 1, maxBalls do
- if ball[i].disabled == false then
- --print("Ball " .. i .. " is not disabled")
- return true
- end
- end
- return false
- end
- function split(s, delimiter)
- result = {}
- for match in (s..delimiter):gmatch("(.-)"..delimiter) do
- table.insert(result, match)
- end
- return result
- end
- address, port = IP, 12345
- function checkCurrentServer(dt)
- if GetIPType(IP) ~= 1 then
- status = "offline"
- end
- if GetIPType(IP) == 1 then
- if dserverinit == false then
- --print("Switching IP")
- socket = require "socket"
- address, port = IP, 12345
- --print(address)
- udp = socket.udp()
- udp:setpeername(address, port)
- udp:settimeout(0)
- dserverinit = true
- end
- if IP ~= address then dserverinit = false--print(IP .. " doesnt equal " .. address)
- else
- ts = ts + dt
- --print(ts)
- if ts > checkrate then
- status = "offline"
- --print("sent ping")
- udp:send("HELLO")
- local data
- data = udp:receive()
- if data then
- --print("got answer!")
- local p = split(data, '|')
- status = p[1]
- print("answer is " .. status)
- else
- print("no response!")
- end
- ts = 0
- end
- end
- end
-
- end
- local gts = 0
- hostinit = false
- player1ip = "127.0.0.1"
- player1port = "12345"
- player2ip = "none"
- player2port = nil
- local p1ping = 0
- local p2ping = 0
- local requesterip
- local requresterport
- function selfHost(dt)
- --print("Server running")
- if not hostinit then
- local socket = require('socket')
- udp = socket.udp()
- udp:setsockname('*', 12345)
- udp:settimeout(0)
- local s = socket.udp()
- s:setpeername("74.125.115.104",80)
- myip, _ = s:getsockname()
-
- hostinit = true
- else
- gts = gts + dt
- if gts > 0.015 then
- local data, msg_or_ip, port_or_nil
- local p1data, p2data
- if table.empty(touches) then
- lastSentKey = "g"
- end
- repeat
-
- data, msg_or_ip, port_or_nil = udp:receivefrom()
- if data then
-
- if data == "HELLO" then
- --print("getting pinged")
- requesterip = msg_or_ip
- requesterport = port_or_nil
- else
- --print(string.sub(data,1,1) .. "Playerlist: " .. player1ip .. " " .. player2ip)
- if player2ip == msg_or_ip then
- p2data = data .. '|' .. p2ping
- p2ping = 0
- else
- if player2ip == "none" and msg_or_ip ~= player1ip then
- player2ip = msg_or_ip
- p2data = data .. '|' .. p2ping
- p2ping = 0
- player2port = port_or_nil
- --print("CONNECTED: PLAYER 2 FROM: " .. player2ip)
- elseif (player1ip ~= msg_or_ip and player2ip ~= msg_or_ip) then
- --print("Lobby Full!" .. player1ip .. player2ip)
- end
- end
-
- end
- end
- until not data
- if player1ip ~= "none" then
- p1ping = p1ping + 1
- end
- if player2ip == "none" then
- confirmation = "S"
- else
- --print("Player2: " .. player2ip)
- p2ping = p2ping + 1
- if p2ping > 100 then
- for i = 1, maxBalls do
- ts = ts + dt
- if ts > updaterate then
- udp:sendto(tostring(lastSentKey) ..
- '|' .. tostring(ball[1].dy) ..
- '|' .. tostring(player2.y) ..
- '|' .. tostring(player1.y) ..
- '|' .. tostring(player1score) ..
- '|' .. tostring(player2score) ..
- '|' .. tostring(player1nukescore) ..
- '|' .. tostring(player2nukescore) ..
- '|' .. tostring(ball[1].x) ..
- '|' .. tostring(ball[1].y) ..
- '|' .. gameState ..
- '|' .. tostring(ball[1].dx) ..
- '|' .. tostring(ballSpeed) ..
- '|' .. tostring(paddle_SPEED) ..
- '|' .. tostring(player1striken) ..
- '|' .. tostring(areanuclear) ..
- "|HOST|".. p2ping, player2ip, player2port)
- ts = 0
- end
- end
- --print("PLAYER 2 DISCONNECTED")
- p2data = nil
- player2ip = "none"
- player2port = nil
- end
- end
- if player2port then
- for i = 1, maxBalls do
- ts = ts + dt
- if ts > updaterate then
- udp:sendto(tostring(lastSentKey) ..
- '|' .. tostring(ball[1].dy) ..
- '|' .. tostring(player2.y) ..
- '|' .. tostring(player1.y) ..
- '|' .. tostring(player1score) ..
- '|' .. tostring(player2score) ..
- '|' .. tostring(player1nukescore) ..
- '|' .. tostring(player2nukescore) ..
- '|' .. tostring(ball[1].x) ..
- '|' .. tostring(ball[1].y) ..
- '|' .. gameState ..
- '|' .. tostring(ball[1].dx) ..
- '|' .. tostring(ballSpeed) ..
- '|' .. tostring(paddle_SPEED) ..
- '|' .. tostring(player1striken) ..
- '|' .. tostring(areanuclear) ..
- "|HOST|".. p2ping, player2ip, player2port)
- ts = 0
- end
- end
- --print("SENT TO " .. player2ip .. ":" .. player2port .. " : " ..lastSentKey)
- end
- local datanumtest = 0
- local datawaspassed = false
- if p2data and player1port then
- datawaspassed = true
- --print("ReceivedINFO: " .. p2data)
- confirmation = "N"
- local p = split(p2data, '|')
- if p[17] then
- if tonumber(p[18]) > 90 then
- confirmation = "L"
- end
- if p[17] ~= "CLIENT" then
- confirmation = "U"
- end
- elseif p[1] == "RESPONSE" then
- if p[2] == "1" then
-
- elseif p[2] == "2" then
-
- elseif p[2] == "3" then
- end
- else
- confirmation = "U"
- end
-
- if p[17] then
- if ball[1].disabled and ball[1].x > 20 and ball[1].x < VIRTUAL_WIDTH - 20 then
- ball[1].disabled = false
- --print("illegal disabling")
- end
- if gameState ~= "1serve" then
- if (ball[1].x > VIRTUAL_WIDTH/2) then
- if tonumber(p[9]) > VIRTUAL_WIDTH/2 then
- die = tonumber(p[2])
- lastSentKeyClient,
- ball[1].dy,
- player2.y,
- player1score,
- player2score,
- player1nukescore,
- player2nukescore,
- ball[1].x,
- ball[1].y,
- gameState,
- ball[1].dx,
- ballSpeed,
- paddle_SPEED, player2striken,
- areanuclear = p[1], die, tonumber(p[4]), tonumber(p[5]), tonumber(p[6]), tonumber(p[7]), tonumber(p[8]), tonumber(p[9]), tonumber(p[10]), p[11], tonumber(p[12]), tonumber(p[13]), tonumber(p[14]), tonumber(p[15]), tonumber(p[16])
- --print("ACCEPTED")
- else
- --print("DECLINED")
- end
- else
- if tonumber(p[9]) > VIRTUAL_WIDTH/2 then
- die = tonumber(p[2])
- lastSentKeyClient,
- ball[1].dy,
- player2.y,
- player1score,
- player2score,
- player1nukescore,
- player2nukescore,
- ball[1].x,
- ball[1].y,
- gameState,
- ball[1].dx,
- ballSpeed,
- paddle_SPEED, player2striken,
- areanuclear = p[1], die, tonumber(p[4]), tonumber(p[5]), tonumber(p[6]), tonumber(p[7]), tonumber(p[8]), tonumber(p[9]), tonumber(p[10]), p[11], tonumber(p[12]), tonumber(p[13]), tonumber(p[14]), tonumber(p[15]), tonumber(p[16])
- --print("ACCEPTED")
- else
- --print("ENFORCED" .. ball[1].x .. " " .. ball[1].dx)
- lastSentKeyClient = p[1]
- player2.y = tonumber(p[4])
- player2striken = tonumber(p[15])
- end
- end
- end
- end
- --print("SENT TO " .. player1ip .. ":" .. player1port .. " : " .. string.sub(p2data,1,1))
- --print("1::" .. p1data)
- --print("2::" .. p2data)
- --print("SENT1: " .. player2ip .. " " .. player2port .. " " .. p1data)
- --print("SENT2: " .. player1ip .. " " .. player1port .. " " .. p2data)
- end
- if requesterip then
- --print("getting pnged!")
- if player2ip == "none" then
- udp:sendto("clienttest", requesterip, requesterport)
- --print("clienttest av to: " .. requesterip)
- else
- udp:sendto("full", requesterip, requesterport)
- --print("full to: " .. msg_or_ip)
- end
- requesterip, requesterport = nil
- end
- gts = 0
- end
- end
- end
- local lastclick = 0
- local clickInterval = 0.4
- function love.touchpressed( id, x, y, dx, dy, pressure )
- if isAndroid then
- if x < love.graphics.getWidth()-OFFSET_X/2 then
- actualX = (x - OFFSET_X/2) * DIFFERENCE_Y
- else
- actualX = 1380
- end
- local existsingID = touchExists(id)
- if existsingID ~= -1 then
- touches[existsingID].x = actualX
- touches[existsingID].y = (y) * DIFFERENCE_Y
- else
- table.insert(touches, newTouch(id, actualX , (y) * DIFFERENCE_Y))
- local time = love.timer.getTime()
- if actualX < VIRTUAL_WIDTH/2 then
- if time <= lastclick + clickInterval and actualX> 100 then
- doubleclick1 = true
- if gameState == "1serve" then
- lastSentKey = "q"
- else
- lastSentKey = p1control.super
- end
- else
- doubleclick1 = false
- lastclick = time
- end
-
- else
- if time <= lastclick + clickInterval and actualX < VIRTUAL_WIDTH-100 then
- doubleclick2 = true
- if gameState == "2serve" then
- lastSentKey = "p"
- else
- lastSentKey = p2control.super
- end
- else
- doubleclick2 = false
- lastclick = time
- end
- end
- end
- end
- end
- function love.touchreleased( id, x, y, dx, dy, pressure )
- if isAndroid then
- if gameState == "start" then
- resettinggenius()
- gameState = "menu"
- ball[1].dx = 1
- ball_DIR = 1
- ball[1].dy = 1
- globalState = "menu"
- hardmanager()
-
- end
- local existsingID = touchExists(id)
- if existsingID ~= -1 then
- table.remove(touches, existsingID)
- end
- end
- end
- function love.touchmoved( id, x, y, dx, dy, pressure )
- if isAndroid then
- if x < love.graphics.getWidth()-OFFSET_X/2 then
- actualX = (x - OFFSET_X/2) * DIFFERENCE_Y
- else
- actualX = 1380
- end
- local existsingID = touchExists(id)
- if existsingID ~= -1 then
- touches[existsingID].x = actualX
- touches[existsingID].y = (y ) * DIFFERENCE_Y
- if touches[existsingID].originalX - touches[existsingID].x > 200 and
- touches[existsingID].originalX < VIRTUAL_WIDTH/2 then
- hold1 = true
- lastSentKey = p1control.counter
- else
- hold1 = false
- end
- if touches[existsingID].x - touches[existsingID].originalX > 200 and
- touches[existsingID].originalX > VIRTUAL_WIDTH/2 then
- hold2 = true
-
- lastSentKey = p2control.counter
- else
- hold2 = false
- end
- end
- end
- end
- function touchExists(ID)
- for i, touch in ipairs(touches) do
- if touch.id == ID then
- return i
- end
- end
- return -1
- end
- function table.empty (self)
- for _, _ in pairs(self) do
- return false
- end
- return true
- end
- function sectortouched(sector)
- for i, touch in ipairs(touches) do
- if (AGAINST_AI == 1) then
- if sector == 2 and touch.x < 100 and touch.y < player1.y then
- lastSentKey = p1control.up
- return true
- elseif sector == 2 and touch.x > VIRTUAL_WIDTH/2+10 and touch.y < player1.y then
- lastSentKey = p1control.up
- return true
- elseif sector == 3 and touch.x < 100 and touch.y > player1.y+player1.height*0.9 then
- lastSentKey = p1control.down
- return true
- elseif sector == 3 and touch.x > VIRTUAL_WIDTH/2+10 and touch.y > player1.y+player1.height*0.9 then
- lastSentKey = p1control.down
- return true
- end
- else
- if sector == 1 and touch.x > VIRTUAL_WIDTH-100 and touch.y < player2.y then
- lastSentKey = p2control.up
- return true
- elseif sector == 2 and touch.x < 100 and touch.y < player1.y then
- lastSentKey = p1control.up
- return true
- elseif sector == 3 and touch.x < 100 and touch.y > player1.y+player1.height*0.9 then
- lastSentKey = p1control.down
- return true
- elseif sector == 4 and touch.x > VIRTUAL_WIDTH-100 and touch.y > player2.y+player1.height*0.9 then
- lastSentKey = p2control.down
- return true
- end
- end
- end
- return false
- end
- function showMessage()
- print (globalMessage)
- if globalMessage ~= "none" then
- love.graphics.printf("Low CPU mode active", 0, VIRTUAL_WIDTH/2, VIRTUAL_HEIGHT/2, "center")
- end
-
- end
- function resetButtonX(arr)
- for i, buttons in ipairs(arr) do
- buttons.x = 1300
- end
- end
-
|