0   D$4@@@ }i$  }, }u
P          2TvͫgE#2Tv2Tv     z       S                                                             U  @@P  P          f   @    @  @    Ue                                                        @  D @                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   D   @   @   D          D  D @                                                                                                                                                                                                                                                                                                                                                                                                     w    U  _  3  3           ww
 ww  ww  w  0   0   0   0              3  03  0  U   pw        3   3  33      w             3  03  0  U      w        3   3  33       w              3  03  0  P    w        3   3  33       w             3  03  0  U      w        3   3  33       w              3  03  0  U     w        3   3  33       w                                                                                                                                               p   w  ww33ww  ww        3   3  33      w 
  pww pww  ww   w            ww ww ww  w  0   0   0   0     pw  ww pww pw            w  ww  ww ww 0   0   0   0     w   w   w   w            ww  ww  ww  w  0   0   0   0     pw  ww  ww  w            w  ww  ww  w  0   0   0   0    pww pww  ww  pw            ww ww w  w   0   0   0   0                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       303  03 3  3   3   3   3    3  33   0   0   0 3                                                                      f`f`f  `  U      w        f   f  ff       w                  P   P                   333 33 ?33 3 3  w                 P   P                    333 33 ?33 3 3  w                 P   P         w        333 33 ?33 3 3  w           fff`ff ff ff `f `f                    f                                              033 03   3    03       0    3     33       0                                                   pw  
w  w  w            w  w  w 
 w  0   0   0   0                     0     0  0 w}  w  ww  ww  33  0       3                                 ww ww ww ww 0  0  0  0                    0     0    w}  w  ww  ww   0     0                          0                         0       ``f  `f`f  f  f          f  ff  o  o  o                      @ D D`@Dfj                    ff  ff ff                   @  D @ DDf                    ff `ffjff                  @  D @ DDf                    ff `ffjff                                                                           3  03  0  U   0    w        3   3  33        w              3  03  0  U      w        3   3  33       w    `f  ff `fff`ff `f `f ff fff  ff  ff f f f ff ff @DD @D       0       0      
                   @Df@DDf DD DDD DD@D       f f 
DD
DDDDDD        @D @D  D  D @D CD        ffff

ݠ          @D @D  D  D              ffff

ݠ                                                                            p  
  
  w            p  p  p  w  0   0   0   0     pw  
w  
w  w            w  w  w  w  0   0   0   0    `                  
 
  
             0        ``f  `f`f  f  f   
    f  ff  o  o  o          ``f  `f`f  f  f  
    f  ff  o  o  o 
 
   `f`fj j        f  ff  o  o  o       o`f `f j  j           f  ff  o  o  o                   f   f`f  ff  ff   
    f
j j                f  `f f`f  ff  ff            f  ff  f  o  o               f  `f f`f  ff  ff            f  ff  f  o  o  `f  ff `fff`ff `f `f ff fff  ff  ff f f f ff ff            0       0                                    0       0                                     0       0                                       0       0                              0 00 0    3   0
                0 0             ꪪ                      0 0             
  
 
                 `  
   /             
    
            0                                            fff`ff ff ff `f `f                    f                fff`ff ff ff `f `f                    f             fff`ff ff ff `f `f                    f             fff`ff ff ff `f `f                    f                                                      P   P                    UU5 UU _53 5 3  w    DD D  @   @               DD    D          @   @   @   @ @DD@TUU@fffTTTTTDD UUEfffoEoEoEoEoEDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD             0                                            0                                   @  @D  MD  @  0                           D      @  @D  MD  @  0                          D                                                                  ww ww ww ww 0  0  30 0              @   @    D    DD   @   @   @   @        D DD  TTTTT@fff@TUU @DDoEoEoEoEoEfffUUEDD}                                                                                           P                                                                                                                                                                                                                                                0   3                                                                                       0   3  0                                                                P                                                                                                                                                                                      0    0                  03  3            0    3    3   030 3           0      0  0        00               0   3 0  3                                                                     P   U   P                        P UU  P                                                                                                                                                                                                                                                                            0   0   0      0          0   0 00 0  0  3  0        0  03   0   0       3        0 0 0 0   00 03                                                                                                                               3 33333                      3   0  0                                                                                                                                                                                                                                                                                             0                        00                                                                                                           0                            30 3cf3`600f  03   0  p73 wpw      3     0  3                                                                                                                                                                                                                                                                                                                                                                                                                                                                     0   0ppp w  p  p   w  3  s0  s7w0w   p   w   p   w   p   ppww                                                                                                                                                                                                                                                                                                                                                                                                                                    3  30 0 03 0 33          300000  00  00  00  00  0   0 3           3   0   3                                                                                                                0   S  S 0U 0U 05                                                                                                                                                                                                                                                                                                                            0   0                                                0  03  0  03                           3            0   03 0U5 0SU  SU  0U                3   U33 UU53UUUU 05   3           S   S33 350S         333SU5UUUUUUUUUUUU5SUU5       333 U333USU3UUUSUUUUUUU5        0 3S3 SU5 3UU5SU53S                                                                                                                                                                                                  0  0   0      3   3   0   3 0       0       0       0     ` 0 `   `   `   f             0   3     0                03   0                        UUU3333                         3S  0U   3   3   3   3   3 335SUU5UUUUUUU5UUU3UUUU53 V3  6 3UUU5SUUUSUUU0UUS SU3 033       33S U553U5U5U5U5U5U535U33U  03                                                                                                                                                                                                  0   0     03   0   3                                  0   0   0   0   3    3                 0  0    3                                                                           0SU503U500UU 03S33UUSUUUSUUU0UUU6   6   3   5  3  U3  U3 U3  0 00033 03 03  0   0        3333P  S  S  S   S   S   S                                                                                                                                                                                                                                    f   `f   `                      `  f f   f                                                                                                                  3SU SU 0U  03  05   S   3    U53 UU5UU50UU353 5 03           3    3033P03U      3     S  SU UU5 UUUUUUUU535                                                                                                                                                                                                                                                                                                0     3  0  3    0                                                                                                                                                                                                                                                                                                                                                                                                                                                                         0     0     0   3     3     0       0  0 0  0   3                                                                                                                             0  3  003      0  03  30 3 0303330                  0  303       0                                                                                                                                                                                                                       0   0   0   0  0  0033     0330 3  00       3  0   3                                                                                                                                           03333 SU SU3 SU S S5  S3                   0  0  3 0   3 333 0                     03   3   0   0                                                                                                                                                                                    0   0 0 0 03  0 03 0 0     3   0333 0                                                                                                                                                          0  0S 3S5 03            S3  U03U303300  3  0 3 0 3 0 3  0 3  3     03 0  0  0  0  30330 3003000 00   0                                                                                                                                                                                                                                                                                                                                                                                                                                   3   3   0   0   3   0   0                03  3  0  033 3 33 00  3 03 3   3   3   3   	|          	 
                    
      		
                s    
 
                                                                                                     % #   ! " $ % % $ " ! ! " # $ & & $ " ! ! " # % % " ! 
               
                                                                                           d                                        @B@@ @ B @@@B@B @ @0@ A@@@AA@@ @ @@B@@@   Q S S T T V W Y Z \ ] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _                                                            4     l l j i h g f f e e d d c c c c c c c d d e f f g h j k m n b                     	 
 
         C                                          P P P P P P P P P P P P P P P P P P P P P P P P P P P P P P      N M M L L K K J J I H H H G F F F E E D C C C B B A @ @ @ @      ^ ] \ \ \ [ [ Z Y X X W V U T T S S R R Q Q P P P P P P P P                                                                         nM<* ˀoooooo________u    Pа    00c@c@S0TTUVVVWWXXYZ [ \0]0_@                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
                                                                           	% `   `   `   `   `   `   `   `   @   @   `   @   `   @   `   `   @   @   `   @   `   @   `   `   @   @         `   `   `   `   `   a         a                                 a         a                                 a         a                                 A         A                                 # # # # #                                                                                                                                                                                                                                                                                                                                                                                                d   d      d      d         d   d      d      d         d   d                     e      e      e         e   e   e   E      E      E         E   E   E   e      e      e         e   e   e   e      e      e         e   e   e                                                                                                                                                                                                                                                                                                                                                                                    i               iii                     I               Iii                     i               iii                     I               Iii         iiii                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        `             `       ` ` ` `                @       `	 ` ` `                `       ` ` ` `                                                                                    M                                                                                                                                                                                             ``````t`w`d`g`T`W`D`G`4`7`$`'```                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                `   @   `                                                                                                                                             #                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      $         4         D         T         d         t                                                                         01  (Ő(    818L28            @                                                  օ                                                                                                                                                  @                                                                                                    0                                       ?                                                                                                                                                                                                                                    0                                                                                                                    03                                                                                                                    30   0               3                                                                                               3 03 3              3                                                                                            00303        3      30                                                                                            3 330           3      33                                                                                          003      0      3                                                                                                03      33      0     0                                                                                         333     3333           00                                                                                         SU      0  0    0   0     3                                                                                         SU3         0    0    `  0                                                                                         SU            0   0     0                                                                                         S 0                   0                                                                                         S5  0           0    0    0                                                                                         S3  3 0    0          3   0                                                                                         S3    0 3      3        0                                                                                        0U03 3  033      0      3  3                                                                                       0SU3033   0 3      3     0 3                                                                                      3S5300   03003             030                                                                                      03 3  0 000       03       0                                                                                          0 3 0 00        0                                                                                                   0 3 0                `                                                                                            0 3 0 0           `   f                                                                                            3      0           f `                                                                                            3       3            f`                                                                                             0      03             `f                                                                                             0 03  3                                                                                                               3 3  03                                                                                                               0  033                                                                                                                03 3 3                                                                                                                 33 0                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          P                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    P                                                                                                       P                                                                                                                   U P                                                                                                                 PUU                                                                                                                  P                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         05                                                                                                                    05                                                                                                                    S5                                                                                                                    S5                                                                                                                    S                                                                                                                    S                                                                                                                    0       0                                                                                              3           0  033333 0 3                                                                                           0    33        0UUSU533335                                                                                          3     SU3     0UUUUU5U53UU                                                                                              3UU53   0UUUUUUU55SU5                                                                                         0     0UUUU3330SUUUSUUUU3U5                                                                                                SUUUUU3 35UUUSUUUS335                                                                                        0      3SUU53 035UUUSUUU333                                                                                                3333   SUUUU5UUUUUS3                                                                                                      0SUUU3UUUUUSU                                                                                      0                0SUU5SU5UUSU                                                                                        0             0SUU5 0U5SUSU                                                                                     0   0             0SU3  333SS5                                                                                     3  0              0c5     00S                                                                                        0             03Sc3 03     33                                                                                     3   3             3UUc   3  3333                                                                                    0  0              3SUc   3 33                                                                                     0  00              SU5  03  30                                                                                    0                  33U3  03  30                                                                                    0                03SU53  0  30                                                                                  033  3               0UUUU5     0                                                                                    0                0UUUU53      0                                                                                 0  3                 SUUU5      0                                                                                 0033                 03UUU3     0                                                                                 00 3                  00UUUU3 0 0UU                                                                                 0 3                   0 SUUU3  0SUU                                                                                0  0                    3SU50 33UUU5                                                                              0 0333                     S3S3 33PUUU5                                                                              030                       0U3  3   PUU3                                                                               0                        033     03S3                                                                               03                                                                                                                   0 0                -- title:  UNBoundClassic_Ver4.1
-- author: Maku Santiran
-- desc: Can you overcome all the urges?
-- script: lua
-- input:  gamepad/keyboard


function lerp(a,b,t) return (1-t)*a + t*b end

local yesclr = 15
local noclr = 1
local outtime = 1
local mdlspr = 46
local enablevhseff = false

t=0
st = 0
atr = 0

x=0
y=0

local shakex = 0
local oldshakex = 0

local isTouched = false

local SHsizeM = 10
local SHsize = -SHsizeM
local SHysize = SHsizeM


local TPsizeM = 20
local TPsize = -TPsizeM
local TPysize = TPsizeM


local lslope = 70
local rlslope = math.random(-5,5)
local rlh = math.random(20,50)
local lcolorch = 15
local lfirst = true
local lighttimer = 0

local lightenab = false
local bgbmenab2 = false

local bgbmsize = 10
local bgbmx = 75
local oldbgbmx = bgbmx


local orb1size = 2
local orbmove = false
local orbs = {}
local orbspeed = 75


local bmrandomx = math.random(30,240)
local randomslopedist1 = math.random(20,60)
local bmlength = 10
local beamlor = 2

local bw1 = 0

local beamsptimer = 0
local beamrel = 0
local beams = {}

local finxval = 998
local finslopeval = 998
local finbeamlor = -1


local closeinsize = 5
local closeinx = 0

local closeinsize2 = 5
local closeinx2 = 0

local bgbmattack2x = 0


local bmparticle = {}
local bmpartcount = 0

local blparticle = {}
local blpartcount = 0

local klparticle = {}
local klpartcount = 0

local staticparticle = {}
local staticpartcount = 0

function emptypart()
bmparticle = {}
bmpartcount = 0

blparticle = {}
blpartcount = 0

klparticle = {}
klpartcount = 0

staticparticle = {}
staticpartcount = 0

lavapartcount = 0
lavaparticle = {}
end

local marvtimer = 0
local marvfinished = false
local marvcht = 0

local screenstatic = false
local statictimer = 0

local marvst = nil
local marvx = 20

local marvy = 50
local marvrs = false

marvfinished = true

local followmaku = false
local atrrun = false



--local sound = music(80,0)
local musno = 0


local stracker = 0
local obs1enab = false
local obs2enab = false
local bgbmenab = false
local spkheight = 0
local smthstpbm = false
local stracker = 0

local obstimer = 0
local obsx1 = 0
local obsy1 = 0

local obsx2 =-30
local obsy2 = 0

local obsx3 =-30
local obsy3= 0

local cntdwntmr = 0
local cntdwnvar = 4
local cntdwnvar2 = 8


local onVOID = false
local onMENU = false
local onTUTORIAL = false
local firstStart = true
local onENDING = false
local onFINAL = false
local onTHUMBNAIL = false

local fonVD = true
local fonVOID2 = true

local scene4timer = 0
local endscetimer = 0
local hidmsg1 = false
local hidmsg2 = false
local fmsg = false

local msc4x = 280
local msc4y = 100
local mudat = 0
local bodyx = 105
local bodyy = -20
local tpspd = 0.1
local bodyspr = 174

local death = 0

music()

local ttrltimer = 0
local ttrltrck = 1
local ttrlslctn = 0
local allwans = false
local crrctans = false
local ttrltrck5val = 0
local ttrlobspos = 0
local ttrlfail = false

local xbtnpressed = false

local goingup = false
local goingdown = true

local chrspr = 2

goingup_Effects = {}
goingdown_Effects = {}
local gup_Timer = 0
local gdw_Timer = 0

effect = {
i_Amount = 0;
t_Amount = 0;

goingdown_efx = function()
if goingdown then
gdw_Timer = gdw_Timer + 1

if gdw_Timer > 3 then
p = {}
p.x = math.random(0,230)
p.ry = math.random(0,10)
p.y = -2
p.ly = -2
p.clr = 1
table.insert(goingdown_Effects,p)
gdw_Timer = 0 
end

end

for i,p in pairs(goingdown_Effects) do
p.ly  = lerp(p.ly,190,0.05)
p.y = p.ly

line(
p.x,
p.y,
p.x,
p.y-p.ry,
p.clr
)

if p.y > 199 then
table.remove(goingdown_Effects,i)
end
end
end,

goingup_efx = function()

if goingup then
gup_Timer = gup_Timer + 1

if gup_Timer > 3 then
p = {}
p.x = math.random(0,230)
p.ry = math.random(0,10)
p.y = 190
p.ly = 190
p.clr = 1
table.insert(goingup_Effects,p)
gup_Timer = 0
end
end

for i,p in pairs(goingup_Effects) do
p.ly  = lerp(p.ly,-22,0.05)
p.y = p.ly

line(
p.x,
p.y,
p.x,
p.y-p.ry,
p.clr
)

if p.y < -20 then
table.remove(goingup_Effects,i)
end
end      
end
}

local marvine = {
x = 51,
y = 50,
state = 192,
rot = 0
}


local wb = {
x = 40,
y = 48,
size = 1

}

local char = {
x= 20 ,
y= 90 ,
size = 1,
area = 4,
mx = 0,
my = 0,

pt1 = {
x =0,
y = 0
},

pt2 = {
x =0,
y = 0
},

pt3 = {
x =0,
y = 0
},


pt4 = {
x =0,
y = 0
},


pt5 = {
x =0,
y = 0
},

}



local orb1 = {
x = 100,
y = 70,
mx = 1,
my = 1,

position = {
x =100+8*orb1size,
y = 999+8*orb1size
},
size = orb1size,
radius = 8*orb1size,
area = 8*orb1size,
colour = 4

}

local orb2 = {
x = 100,
y = 70,
mx = 1,
my = 1,

position = {
x =100+8*orb1size,
y = 70+8*orb1size
},
size = orb1size,
radius = 8*orb1size,
area = 8*orb1size,
colour = 4

}

local shield = {

position = {
x = char.x+4,
y = char.y+3
},

rotation = 1,

points = {
{x =SHsize, y= SHysize},
{x =SHsize, y=-SHysize},
{x =SHsizeM,y=-SHysize},
{x =SHsizeM,y= SHysize},
{x =SHsize, y= SHysize}
}

}

local marvinetp = {

position = {
x = 999,
y = 999
},

rotation = 5,

points = {
{x =TPsize, y= TPysize},
{x =TPsize, y=-TPysize},
{x =TPsizeM,y=-TPysize},
{x =TPsizeM,y= TPysize},
{x =TPsize, y= TPysize}
}

}

local rndmchrlrpx = char.x+math.random(-30,30)
local rndmchrlrpy = char.y+math.random(-30,30)
local hitonce = false
local gthttmr = 0

local funny_guix = 73
local funny_guiy = 90

local thumbnailTimer = 0
local makuSprite = 140
local webcenterpoint = 100

local oldmarvposx = 0
local oldmarvposy = 0
local slashtpadj = 0
slshbxh = 0
marvtimer = 0
marvine.x = 121
marvine.y = 95
local marvspin = 0.2
local marvspd = 0.1
local gravityMode = true



function rotatedpointfunc(point, rotation)

local rotatedx =
(point.x * math.cos(rotation))
- (point.y * math.sin(rotation))

local rotatedy =
(point.y * math.cos(rotation))
+ (point.x * math.sin(rotation))

return {x = rotatedx, y = rotatedy}

end

function drawShield(shape, color)

local firstrun = true
local lastpoint = 0
local rotatedpoint = 0

for index, point in ipairs(shape.points) do

rotatedpoint = rotatedpointfunc(point, shape.rotation)

if firstrun then
lastpoint = rotatedpoint
firstrun = false
else
line(
lastpoint.x + shape.position.x,
lastpoint.y + shape.position.y,
rotatedpoint.x + shape.position.x,
rotatedpoint.y + shape.position.y,
color
)

lastpoint = rotatedpoint

end
end
end

function updtradcol()

if isTouched == false then
char.mx = char.x + 3
char.my = char.y + 3
orb1.mx = orb1.x + 15
orb1.my = orb1.y + 15
orb2.mx = orb2.x + 15
orb2.my = orb2.y + 15

radialCol(char,orb1,false,0,0)

rndmchrlrpx = char.x+math.random(-30,30)
rndmchrlrpy = char.y+math.random(-30,30)


end
end



function gotHit()

if (isTouched == false) then
sfx(20,20,-1)

if chrspr == 2 then
chrspr = 4
end

if chrspr == 1 then
chrspr = 3
end

gthttmr = 0
blpartcount = 0
isTouched = true
--music(99)
end

end

function resetTutovar()
chrspr = 2
char.x = 5
char.y = 90
isTouched = false
enablevhseff = false
end

function resetVOIDvar()

emptypart()
st = 0
chrspr = 1
char.x = 20
char.y = 90
isTouched = false
fonVD = true
rstcnttimer()

bmrandomx = math.random(30,240)
randomslopedist1 = math.random(20,60)
bmlength = 10
beamlor = 2

xbtnpressed = false

obstimer = 0
stracker = 0
obs1enab = false
obs2enab = false
bgbmenab = false
obsx1 = 0
obsy1 = 0
obsx2 =-30
obsy2 = 0
obsx3 =-30
obsy3= 0
lfirst = true
lightenab = false
lslope = 70
closeinsize = 5
bgbmenab2 = false
bgbmsize = 10
bgbmx = 75
oldbgbmx = bgbmx
lighttimer = 0

resetclosein(0,5)
spkheight = 0
finxval = 998
finslopeval = 998

atr = 0

beamsptimer = 0
beamrel = 0
beams = {}
goingdown = true

marvst = nil
marvx = 20
marvy = 50
marvrs = false

marvfinished = true
marvine = {
x = 100,
y = 50,
state = 192,
rot = 0
}

followmaku = false
atrrun = false
msc4x = 280
msc4y = 100
mudat = 0
bodyx = 105
bodyy = -20
tpspd = 0.1
bodyspr = 174
scene4timer = 0

goingup = false
goingdown = true

endscetimer = 0
hidmsg1 = false
hidmsg2 = false
fmsg = false

enablevhseff = false

marvx = 50
marvy = 50

if musno <= 5 then
musno = 0
end

if musno > 5 and musno <= 7 then
musno = 6
end

if musno > 7 and musno <= 9 then
musno = 8
stracker = 2
end

if musno > 9 and musno <= 11 then
musno = 10
end

if musno > 11 and musno <= 15 then
musno = 12
stracker = 0
end


if musno > 19 and musno <= 21 then
musno = 20
end

if musno > 21 then
musno = 20
end

end

function dthlstnr()
if (isTouched == true) then

gthttmr = gthttmr + 1

char.x = lerp(char.x,rndmchrlrpx,0.2)
char.y = lerp(char.y,rndmchrlrpy,0.2)

bladdParticle(char.x,char.y,5,50,false,6)
blburst()

if gthttmr > 1 and gthttmr < 7 then cls(4) end
if gthttmr > 35 and gthttmr < 41 then cls(15) end

if gthttmr == 35 then sfx(21,10,-1) cls(15) blpartcount = 0
death = death + 1 end

if gthttmr > 35 then
bladdParticle(char.x,char.y,30,50,false,15)
blburst()
chrspr = 8
end

if gthttmr == 79 then
if onENDING then
onVOID = true
musno = 20
onENDING = false
end
end

if gthttmr == 80 then
if onTUTORIAL then
resetttrl()
resetTutovar()
end

if onVOID then
char.x = 20
onVOID = true
resetVOIDvar()

end
end
end
end

function dthlstnr_ending()
gthttmr = gthttmr + 1

char.x = lerp(char.x,rndmchrlrpx,0.2)
char.y = lerp(char.y,rndmchrlrpy,0.2)

bladdParticle(char.x,char.y,5,50,false,6)
blburst()

if gthttmr == 1 then sfx(20,20,-1,3) chrspr = 3 end
if gthttmr > 1 and gthttmr < 7 then cls(4) end
if gthttmr > 35 and gthttmr < 41 then cls(15) end

if gthttmr == 35 then sfx(21,10,-1) cls(15) blpartcount = 0 end

if gthttmr > 35 then
bladdParticle(char.x,char.y,30,50,false,15)
blburst()
chrspr = 8
end
end

function radialCol(obj1,obj2,isspr,ox,oy)

local obj2mx = 0
local obj2my = 0
local distx = 0
local disty = 0

if (isspr==true) then

mindist = obj1.area + obj2.area
distx = (obj1.mx - obj2.mx)
disty = (obj1.my - obj2.my)


else

obj2mx = obj2.position.x - ox
obj2my = obj2.position.y - oy
mindist = obj1.area + obj2.radius
distx = (obj1.mx - obj2mx)
disty = (obj1.my - obj2my)


end

local mindist = obj1.area + obj2.radius
local mindist2 = mindist * mindist



local totalDist = (distx * distx)+(disty * disty)

if (totalDist <= mindist2) then
gotHit()
end


end

function spawnorb1 ()

circ(
orb1.position.x,
orb1.position.y,
orb1.radius,
orb1.colour
)


circ(
orb1.position.x,
orb1.position.y,
orb1.radius/1.1,
orb1.colour+1
)


circ(
orb1.position.x,
orb1.position.y,
orb1.radius/1.4,
orb1.colour+2
)


circ(
orb1.position.x,
orb1.position.y,
orb1.radius/1.6,
15
)

updtradcol()

if orbmove == true then
if marvine.rot == 0 then
orb1.position.x = lerp(orb1.position.x,orb1.position.x+orbspeed ,0.05)
orb1.position.y= lerp(orb1.position.y,orb1.position.y+orbspeed ,0.05)
else
orb1.position.x = lerp(orb1.position.x,orb1.position.x-orbspeed ,0.05)
orb1.position.y= lerp(orb1.position.y,orb1.position.y+orbspeed ,0.05)
end

updtradcol()
bladdParticle(orb1.position.x,orb1.position.y,1,20,true,15)
end



end

function spawnLaserBeam(x, slope, top, bot, color,cld,shrnk)
if bmlength>0 then

if shrnk == nil then
bmlength = bmlength - 1
end

b1 = {
ax = slope,
ay = top,
bx = x,
by = bot,
cx = x-bmlength,
cy = bot
}


b2 = {
ax = b1.ax,
ay = top,
bx = b1.ax+bmlength,
by = top,
cx = b1.bx,
cy = b1.cy
}

local bm1 = {
position = {
x = 0,
y = 0
},
points = {
{x =b1.ax, y = b1.ay},
{x =b1.bx, y =b1.by},
{x =b1.cx,y =b1.cy},
{x =b1.ax,y =b1.ay},
},
rad = 0

}


local bm2 = {
position = {
x = 0,
y = 0
},
points = {
{x =b2.ax, y = b2.ay},
{x =b2.bx, y =b2.by},
{x =b2.cx,y =b2.cy},
{x =b2.ax,y =b2.ay},
},
rad = 0

}




bm1.position.x = (slope-x)/2 + x
bm1.position.y = (bot-top)/2 + top
bm1.rad = (bot-top)/1

bm2.position.x = (slope-x)/2 + x
bm2.position.y = (bot-top)/2 + top
bm2.rad = (bot-top)/1

local beamp1 = tri(b1.ax,b1.ay,b1.bx,b1.by,b1.cx,b1.cy,color)
local beamp2 = tri(b2.ax,b2.ay,b2.bx,b2.by,b2.cx,b2.cy,color)


if cld == true then
checkpolcol(bm1,bm1.rad)
checkpolcol(bm2,bm2.rad)
end
end

end

function checkpolcol(obj,objrad)

local seperation = 0

if (polsprtn(char.pt1,obj.position,objrad)) then

if
(polcol(char.pt1,obj)) or
(polcol(char.pt2,obj)) or
(polcol(char.pt3,obj))or
(polcol(char.pt4,obj))or
(polcol(char.pt5,obj)) then
if st > 30 then
gotHit()
end
end
end

end

function polcol(point,shape)

local firstPoint = true
local lastPoint = 0
local rotatedPoint = 0
local onRight = 0
local onLeft = 0
local xCrossing = 0

for index,shapePoint in ipairs(shape.points) do
rotatedPoint = rotatedpointfunc(shapePoint, 0)

if firstPoint then
lastPoint = rotatedPoint
firstPoint = false
else

startPoint = {
x = lastPoint.x,
y = lastPoint.y,
}

endPoint = {
x = rotatedPoint.x,
y = rotatedPoint.y
}

if ((startPoint.y >= point.y) and (endPoint.y < point.y))
or ((startPoint.y < point.y) and (endPoint.y >= point.y)) then


if (startPoint.x <= point.x) and (endPoint.x <= point.x) then
onLeft = onLeft + 1
elseif (startPoint.x >= point.x) and (endPoint.x >= point.x) then
onRight = onRight + 1
else
if (startPoint.y ~= endPoint.y) then
xCrossing = startPoint.x +
((point.y - startPoint.y)
* (endPoint.x - startPoint.x)
/ (endPoint.y - startPoint.y))
if (xCrossing >= point.x) then
onRight = onRight + 1
else
onLeft = onLeft + 1
end
end
end
end

lastPoint = rotatedPoint
end

end
if (onRight % 2) == 1 then

return true
else
return false
end

end

function polsprtn(pnt1,pnt2,sprtn)

local seperationSq = sprtn*sprtn
local distanceSq =
((pnt1.x - pnt2.x) * (pnt1.x - pnt2.x)) +
((pnt1.y - pnt2.y) * (pnt1.y - pnt2.y))
return(distanceSq <= seperationSq)
end

function staticParticle(x,y,amnt,d,rep,color)

for i = 1,amnt do

if (staticpartcount <= amnt)and (rep==false) then

staticpartcount = staticpartcount + 1
local p = {}
p.x = x
p.y = y
p.rx = x + math.random(-d,d)
p.ry = y + math.random(-d,d)
p.t = 0
p.rad = math.random(2,3)
p.color = color
table.insert(staticparticle,p)
end

if (rep == true) then


local p = {}
p.x = x
p.y = y
p.rx = x + math.random(-d,d)
p.ry = y + math.random(-d,d)
p.xs = math.random(1,15)
p.xy = math.random(1,15)

p.t = 0
p.color = color
table.insert(staticparticle,p)
end
end
end

function staticint()
for i,p in pairs(staticparticle) do


p.t = p.t + 1

rect(
p.rx,
p.ry,
p.xs,
p.xy,
p.color
)

if (p.t == 5) then
table.remove(staticparticle,i)
end

end
end

function bmaddParticle(x,y,color)

for i = 1,5 do

if (bmpartcount <= 5) then

bmpartcount = bmpartcount + 1
local p = {}
p.x = x
p.y = y
p.rx = x + math.random(-30,30)
p.ry = y + math.random(-50,-1)
p.t = 0
p.rad = math.random(2,4)
p.color = color
table.insert(bmparticle,p)
end

end


end

function bmadd()
for i,p in pairs(bmparticle) do


p.x = lerp(p.x,p.rx,0.05)
p.y = lerp(p.y,p.ry,0.05)
p.t = p.t + 1
p.rad = p.rad - 0.2

circ(
p.x,
p.y,
p.rad,
p.color
)

if (p.rad <= 0) then
table.remove(bmparticle,i)
end

end
end

function bladdParticle(x,y,amnt,d,rep,color)

for i = 1,amnt do

if (blpartcount <= amnt)and (rep==false) then

blpartcount = blpartcount + 1
local p = {}
p.x = x
p.y = y
p.rx = x + math.random(-d,d)
p.ry = y + math.random(-d,d)
p.t = 0
p.rad = math.random(2,3)
p.color = color
table.insert(blparticle,p)
end

if (rep == true) then


local p = {}
p.x = x
p.y = y
p.rx = x + math.random(-d,d)
p.ry = y + math.random(-d,d)
p.t = 0
p.color = color
p.rad = math.random(2,3)
table.insert(blparticle,p)
end

end


end

function blburst()
for i,p in pairs(blparticle) do


p.x = lerp(p.x,p.rx,0.05)
p.y = lerp(p.y,p.ry,0.05)
p.t = p.t + 1
p.rad = p.rad - 0.05

circ(
p.x,
p.y,
p.rad,
p.color
)

if (p.rad <= 0) then
table.remove(blparticle,i)
end

end
end

function laserwarn()

if beamlor == 1 then

bmslopedist = bmrandomx - randomslopedist1

bw1 = {
ax = bmslopedist,
ay = 140,
bx = bmrandomx,
by = 1,
cx = bmrandomx,
cy = 1,
x = bmx,
t = 0,
lor = 1,
slope = bmslopedist
}


local beamp1 = tri(bw1.ax,bw1.ay,bw1.bx,bw1.by,bw1.cx,bw1.cy,8)

table.insert(beams,bw1)

end



if beamlor == 2 then

bmslopedist = bmrandomx + randomslopedist1

local midpoint = bmrandomx

local bw1 = {
ax = bmslopedist,
ay = 140,
bx = midpoint,
by = 1,
cx = midpoint,
cy = 1,
x = bmx,
t = 0,
lor = 2,
slope = bmslopedist
}


local beamp1 = tri(bw1.ax,bw1.ay,bw1.bx,bw1.by,bw1.cx,bw1.cy,8)
table.insert(beams,bw1)

end

end

function ticlaserwarn()

for i,bw1 in pairs(beams) do
local beamp1 = tri(bw1.ax,bw1.ay,bw1.bx,bw1.by,bw1.cx,bw1.cy,8)
bw1.t = bw1.t + 1


if (bw1.t>=50) then
finxval = bw1.bx
finslopeval = bw1.slope
finbeamlor = bw1.lor
table.remove(beams,i)
end




end
end

function lightning(slope)

local slope1b = slope - rlslope
local slope1t = slope1b - rlslope

local slope2b = slope1t - bmlength
local slope2t = slope2b + bmlength + rlslope

local slope3b = slope2t - bmlength
local slope3t = slope2b - rlslope

local rlh2 = rlh + rlh

spawnLaserBeam(slope1t, slope1b, 0, rlh, lcolorch,true,false)
spawnLaserBeam(slope2t, slope2b, rlh, rlh2, lcolorch,true,false)
spawnLaserBeam(slope3t, slope3b, rlh2, 140, lcolorch,true,false)
bladdParticle(slope3t,140,20,150,false,15)

end

function lightningobs(x,randomed)

lighttimer = lighttimer + 1

if lighttimer == 1 then
rlslope = math.random(-15,2)
rlh = math.random(20,50)
rx = math.random(30,150)
wrx = rx - 10

if randomed == false then
rx = x
end

if lfirst == true then
rx = 140
lighttimer = 50
lfirst = false
end

end

if lighttimer < 50 then
rectb(wrx,-2,30,140,4)
end


if lighttimer > 50 and lighttimer < 70 then
lightning(rx)
end

if lighttimer == 60 then
lcolorch = 1
end

if lighttimer == 120 then
blpartcount = 0
lighttimer = 0
lcolorch = 15
end


blburst()
end

function Intro()

t = t + 1

spr(256,3,0,1,2,0,0,10,3)

if t>0 and t < 101 then
spr(16,wb.x,wb.y,1,wb.size)
print("> Play", 3,50,15,1,1)
end

if t == 2 then
sfx(2,46,5,3)
end

if t == 50 then
sfx(2,45,5,3)
end


if t>50 then
spr(17,wb.x,wb.y,1,wb.size)
end

if t==100 then
t = 0
end

print("Game Concept by Maku Santiran", 3,130,1)

if t > 101 then
print("> Play", 3,50,15,1)
spr(math.random(16,17),wb.x,wb.y,1,wb.size)
end



if t > 200 then
initstscrn(false,0)
statictimer = 0
end

if t == 300 then
onTUTORIAL = true
onMENU = false
end

if btnp(4) and xcheck() then
t = 101
xbtnpressed = true
music(3,0)
end



end

function teleporteff(x,y,rot,clr)

drawShield(marvinetp, clr)
marvinetp.rotation = marvinetp.rotation + rot
marvinetp.position.x = x
marvinetp.position.y = y


end

function shieldedint()

drawShield(shield, 7)
shield.rotation = shield.rotation + 0.01
shield.position.x = char.x+4
shield.position.y = char.y+3.5


end

function beamint(stop)

ticlaserwarn()
beamsptimer = beamsptimer + 1
spawnLaserBeam(finxval,finslopeval,140,1,15,true)
bmadd()
bmaddParticle(finslopeval,140,15)

if beamsptimer > 15 then
beamsptimer = 0
bmrandomx = math.random(30,240)
randomslopedist1 = math.random(20,60)
bmlength = 10
beamlor = math.random(1,2)
end

if stop ~= true then
if beamsptimer > 10 then
laserwarn()
end

end

if beamsptimer > 10 then
bmpartcount = 0
end

if beamrel < 100 then
beamrel = beamrel+1
end



end

function hitkl(x,y,size)
if x+size > char.x and x-size/2.3 < char.x then
if y+size > char.y and y-size/2.3 < char.y then
gotHit()
end
end
end

function kladdParticle(x,y)

klpartcount = klpartcount + 1
local p = {}
p.x = x
p.y = y
p.s = 20
p.t = 0
table.insert(klparticle,p)


end


function klburst()
for i,p in pairs(klparticle) do

p.s = p.s - 1
fpx = p.x - p.s/2
fpy = p.y - p.s/2

rect(
fpx,
fpy,
p.s,
p.s,
math.random(4,6)
)

hitkl(fpx,fpy,p.s)

if p.s == 0 then
table.remove(klparticle,i)
end

end
end

local lavapartcount = 0
local lavaparticle = {}

function lavaaddParticle(x,y,amnt,size,dir,color)

for i = 1,amnt do

local p = {}
p.x = x
p.y = y
p.t = 0
p.color = color
p.s = size
table.insert(lavaparticle,p)

if (dir == "left") then
p.rx = x + math.random(3,50)
p.ry = y + math.random(-50,50)
end
if (dir == "right") then
p.rx = x + math.random(-50,3)
p.ry = y + math.random(-50,50)
end

end

end

function lavaburst()
for i,p in pairs(lavaparticle) do


p.x = lerp(p.x,p.rx,0.05)
p.y = lerp(p.y,p.ry,0.05)
p.t = p.t + 1
p.s = p.s - 0.3

rect(
p.x,
p.y,
p.s,
p.s,
p.color
)

hitkl(p.x,p.y,p.s)


if (p.s <= 0) then
table.remove(lavaparticle,i)
end

end
end

local slshbxh = 10

local targetx = char.x
local targety = char.y

function hitslash(x,y,sizex,sizey)
if x+sizex > char.x and x-sizex/2.8 < char.x-3 then
if y+sizey > char.y and y-sizey < char.y-3 then
gotHit()
end
end
end

function slashbx(x,y)
if slshbxh ~= 0 then

local rectwidth = 20
rect(
x,
y,
rectwidth,
slshbxh,
15
)

slshbxh = slshbxh - 2

hitslash(x,y,rectwidth,slshbxh)

end
end

function targetmaku(x,y,enable)

if enable == true then
rectb(
x-2,
y-2,
12,
12,
8
)

end
end

function marvanimate(name, mx, my, mspd)


spr(marvine.state,marvine.x, marvine.y,0,1,marvine.rot,0,2,2)

local speed = 0.1

if mspd ~= nil then
speed = mspd
end

marvine.x = lerp(marvine.x,mx ,speed)
marvine.y = lerp(marvine.y,my ,speed)

blburst()

if name == "orbl" then
marvtimer = marvtimer + 1

if musno == 20 or musno == 21 then
if marvine.rot == 0 then
spawnLaserBeam(140,0,0,160,15,true)
end

if marvine.rot == 1 then
spawnLaserBeam(90, 240,0,160,15,true)
end
end


if marvtimer == 5 and marvfinished == false then
marvtimer = 0
orbmove = false
marvine.state = marvine.state + 2

if marvine.state <= 196 then

if marvine.rot == 0 then
marvine.x = lerp(marvine.x,marvine.x-50 ,0.05)
orb1.position.x = marvine.x
else
marvine.x = lerp(marvine.x,marvine.x+50 ,0.05)
orb1.position.x = marvine.x + 20
end

orb1.position.y= marvine.y - 20
bladdParticle(orb1.position.x,orb1.position.y,10,70,false,15)
end

if marvine.state >= 200 then
orbmove = true
end

if marvine.state == 206 then
marvtimer = 0
marvine.state = 192
marvfinished = true
end

end
end


if name == "switchltr" then
marvtimer = marvtimer + 1

if marvfinished == false then
if marvtimer == 10 then
marvine.state = 206
end

if marvtimer == 20 and marvine.rot == 0 then
marvine.state = 192
marvine.rot = 1
marvfinished = true
end

if marvtimer == 20 and marvine.rot == 1 and marvfinished == false then
marvine.state = 192
marvine.rot = 0
marvfinished = true
end

end
end

if name == "slashtp" then
if marvfinished == false then
marvtimer = marvtimer + 1

if marvtimer == 1 then
marvine.state = 160
targetx = char.x
targety = char.y
showtarget = true
end

if marvtimer == 25 then
marvine.state = 162
marvine.x = targetx
marvx = targetx
marvine.y = targety-5
showtarget = false
slshbxh = 10

if marvine.rot == 0 then
bladdParticle(marvine.x+20,marvine.y+3,5,30,false,15)
end
if marvine.rot == 1 then
bladdParticle(marvine.x-10,marvine.y+3,5,30,false,15)
end

end

if marvtimer == 29 then
marvine.state = 164
end

if marvtimer == 33 then
marvine.state = 166
marvfinished = true
marvtimer = 0
end

blburst()
targetmaku(targetx,targety,showtarget)

end
end


end


function marvattackltr1()

atr = atr + 1


if atr == 10 and marvfinished == true then
marvfinished = false
marvst = "orbl"
marvtimer = 0
bmlength = 10
end

if atr == 40 then
marvtimer = 0
marvfinished = false
blpartcount = 0
marvst = "switchltr"
marvx = 200
blpartcount = 0
end

if atr == 60 then
marvtimer = 0
marvfinished = false
marvst = "orbl"
bmlength = 10
end

if atr == 105 then
marvtimer = 0
marvfinished = false
marvst = "switchltr"
marvx = 20
end


if atr == 119 then
atr = 0
blpartcount = 0
end


marvanimate(marvst,marvx,marvy)

end

function marvattackltr2()

atr = atr + 1

if atr == 10 and marvfinished == true then
marvinetp.x = 999
marvfinished = false
marvst = "orbl"
marvtimer = 0
bmlength = 10
orbspeed = 100
end

if atr == 40 then
marvtimer = 0
marvst = ""
marvine.state = 206
blpartcount = 0
marvx = 120
marvy = 180
blpartcount = 0
end

if atr == 52 then
marvtimer = 0
marvfinished = false
marvine.state = 192
marvine.rot = 1
marvx = 200
marvy = 50
blpartcount = 0
end


if atr == 63 then
marvinetp.x = 999
marvst = "orbl"
marvtimer = 0
marvfinished = false
blpartcount = 0
marvx = 200
marvy = 50
blpartcount = 0
bmlength = 10
end


if atr == 100 then
marvtimer = 0
marvst = ""
marvine.state = 206
blpartcount = 0
marvx = 120
marvy = 10
blpartcount = 0
end

if atr == 112 then
marvtimer = 0
marvfinished = false
marvine.state = 192
marvine.rot = 0
marvx = 20
marvy = 50
blpartcount = 0
end


if atr == 120 then
atr = 0
marvfinished = true
blpartcount = 0
end


marvanimate(marvst,marvx,marvy)
klburst()
if atr > 40 and atr < 62 then
kladdParticle(marvine.x+7,marvine.y+9)
teleporteff(marvine.x+7,marvine.y+9,2,15)
end

if atr > 100 and atr < 130 then
kladdParticle(marvine.x+7,marvine.y+9)
teleporteff(marvine.x+7,marvine.y+9,-2,15)
end

end



function marvattackswrd()
atr = atr + 1

marvanimate(marvst,marvx,marvy)


slashbx(marvine.x-6,marvine.y+4)


if atr == 1 then
marvfinished = false
marvine.rot = 1
marvst = "slashtp"
bmlength = 5
oldmarvposx = marvx
oldmarvposy = marvy
slashtpadj = 0

end


if atr == 25 then
marvx = targetx
marvy = targety
end

if atr == 40 then
marvtimer = 0
marvst = ""
marvine.state = 206
blpartcount = 0
marvx = targetx-50
marvy = targety+50
end

if atr == 52 then
marvtimer = 0
marvfinished = false
marvine.state = 192
marvx = targetx-50
marvy = targety-50
blpartcount = 0
end


if atr == 60 then
slashtpadj = 10
bmlength = 5
marvtimer = 0
marvfinished = false
marvst = "slashtp"
marvine.rot = 0
oldmarvposx = marvx
oldmarvposy = marvy
end


if atr == 85 then
marvx = targetx
marvy = targety
end

if atr == 100 then
marvtimer = 0
marvst = ""
marvine.state = 206
blpartcount = 0
marvx = targetx+50
marvy = targety+50
blpartcount = 0
end

if atr == 112 then
marvtimer = 0
marvfinished = false
marvine.state = 192
marvx = targetx+50
marvy = targety-50
blpartcount = 0
end



if atr == 120 then
marvfinished = false
atr = 0
blpartcount = 0
end

klburst()

if atr > 40 and atr < 60 or atr > 100 and atr < 120 then
kladdParticle(marvine.x+7,marvine.y+9)
teleporteff(marvine.x+7,marvine.y+9,0.2,15)
end

if atr > 25 and atr < 40 or atr > 85 and atr < 100 then


spr(
128,
oldmarvposx,
oldmarvposy,
0,
1,
marvine.rot,
0,
2,
2
)

spawnLaserBeam(
oldmarvposx+slashtpadj,
targetx+slashtpadj,
targety+10,
oldmarvposy+10,
15,
true
)

end

end


function marvattackswrd2()


atr = atr + 1
marvanimate(marvst,marvx,marvy)
slashbx(marvine.x-6,marvine.y+4)

if atrrun == false then
atrrun = true
atr = 120
marvine.x = 30
end


if atr == 1 then
marvtimer = 0
marvfinished = false
marvine.rot = 1
marvst = "orbl"
followmaku = true
end

if atr == 20 then
followmaku = false
end

if atr == 30 then
marvx = char.x+3
marvy = 110
end

if atr == 50 then
marvx = char.x-10
marvy = marvy-90
marvfinished = false
marvst = ""
end

if atr == 60 then
marvtimer = 0
marvst = "slashtp"
slashtpadj = 10
oldmarvposx = marvx
oldmarvposy = marvy
end

if atr == 80 then
marvx = targetx
marvy = targety
end


if atr == 100 then
marvtimer = 0
marvst = ""
marvine.state = 206
blpartcount = 0
marvx = targetx-50
marvy = targety+50
end

if atr == 112 then
followmaku = true
marvine.rot = 0
marvy = targety-50
marvfinished = false
end

if atr == 112 then
marvine.rot = 0
marvy = targety-50
end

if atr == 120 then
followmaku = true
marvfinished = false
marvtimer = 0
marvine.rot = 0
marvst = "orbl"
marvine.state =192
blpartcount = 0
end


if atr == 160 then
marvtimer = 0
followmaku = false
marvx = char.x+40
marvst = ""
blpartcount = 0
end


if atr == 170 then
followmaku = true
marvine.rot = 1
marvfinished = false
marvy = char.y+30
end

if atr == 180 then
marvtimer = 0
marvst = "slashtp"
oldmarvposx = marvx
oldmarvposy = marvy
bmlength = 10
end

if atr == 200 then
followmaku = false
marvx = targetx
marvy = targety
end

if atr == 220 then
marvtimer = 0
marvst = ""
marvine.state = 206
blpartcount = 0
marvx = targetx+50
marvy = targety+100
end

if atr == 232 then
marvine.state = 192
marvx = marvx
marvy = 50
end

if atr == 240 then
bmlength = 10
atr = 0
end

if followmaku == true then
if marvine.rot == 1 then
marvx = char.x+20
end

if marvine.rot == 0 then
marvx = char.x-45
end

end

klburst()

if
atr > 40 and atr < 60 or
atr > 100 and atr < 120 or
atr > 160 and atr < 180 or
atr > 220 and atr < 250
then
kladdParticle(marvine.x+7,marvine.y+9)
teleporteff(marvine.x+7,marvine.y+9,0.3,15)
end

if
atr > 80 and atr < 100 or
atr > 200 and atr < 220
then
spr(
128,
oldmarvposx,
oldmarvposy,
0,
1,
marvine.rot,
0,
2,
2
)

spawnLaserBeam(
oldmarvposx+slashtpadj,
targetx+slashtpadj,
targety+10,
oldmarvposy+10,
15,
true
)
end

end



function marvattackfin(harder)

atr = atr + 1
marvanimate(marvst,marvx,marvy,mrvspd)
slashbx(marvine.x-6,marvine.y+4)
klburst()

if atr == 1 then
marvx = 161
marvy = 120
marvine.rot = 1
marvfinished = false
marvtimer = 0
marvst = "slashtp"
oldmarvposx = marvx
oldmarvposy = marvy
bmlength = 10
slashtpadj = 10
end


if atr == 25 then
marvx = targetx
marvy = targety
end


if atr == 40 then
marvtimer = 0
marvst = ""
marvine.state = 206
blpartcount = 0
marvx = 161
marvy = 20
end

if atr == 52 then
marvtimer = 0
marvfinished = false
marvine.state = 192
marvx = 161
marvy = 120
blpartcount = 0
end

if atr == 100 then
targetx = char.x
targety = char.y
mrvspd = 0.7
marvx = targetx
marvy = targety
end

if atr == 115 then
violntmarv = false
mrvspd = 0.5
marvx = 161
marvy = 120
end

if atr == 117 then
atr = 0
mrvspd = 0.1
end

if atr > 40 and atr < 130 then
kladdParticle(marvine.x+7,marvine.y+9)
teleporteff(marvine.x+7,marvine.y+9,marvspin,15)
end

if atr > 70 and atr < 100 then
marvine.x = marvine.x + math.random(-2,2)
marvine.y = marvine.y + math.random(-2,2)
marvspin = marvspin + 0.05
violntmarv = true
end

if violntmarv == true then
bladdParticle(marvx+5,marvy,1,40,true,math.random(4,6))
end

if atr > 25 and atr < 40then
spr(
128,
oldmarvposx,
oldmarvposy,
0,
1,
marvine.rot,
0,
2,
2
)

spawnLaserBeam(
oldmarvposx+slashtpadj,
targetx+slashtpadj,
targety+10,
oldmarvposy+10,
15,
true
)
end

end



function scenemf()


if musno == 20 then
bgmsg("YOU NEED ME",16,8,3,1)

closein(-10,0.08)
closein(315,-0.2)
spawnorb1()
marvattackltr1()
spkheight = spkheight + 0.15
spike(190,135,10,10,80-spkheight)
obstcle(0,135,250,2,4)
obstcle(0,0,250,2,4)
end

if musno == 21 then
bgmsg("WE CAN END PAIN",28,8,2,1)

closein(-10,0.08)
closein(315,-0.2)
spawnorb1()
marvattackltr2()
spkheight = spkheight + 0.15
spike(190,135,10,10,80-spkheight)
obstcle(0,135,250,2,4)
obstcle(0,0,250,2,4)
end


if musno == 22 then
bgmsg("JUST STOP RESISTING",5,8,2,1)

closein(-10,0.1)
closein(315,-0.1)
marvattackswrd()
spkheight = spkheight + 0.15
spike(190,135,10,10,80-spkheight)

obstcle(0,135,250,2,4)
obstcle(0,0,250,2,4)
end
if musno == 23 then
print("I CAN FILL",26+shakex,30,8,1,3)
bgmsg("YOUR EMPTINESS",33,8,2,1)
closein(-10,0.42)
closein(317,-0.1)
marvattackswrd()
obstcle(0,135,250,2,4)
obstcle(0,0,250,2,4)      
end

if musno == 24 then
gravity()
marvattackfin(false)
bgmsg("I AM YOU",45,8,3,1)
print("Press A or Z to switch gravity",40,67,1)
end

if musno == 25 then
gravity()
obstcle(0,0,250,2,4)
closein(-20,0.15)
closein(315,-0.2)
bgmsg("UNBOUND",53,8,3,1)
print("YOU WILL NEVER",35+shakex,30,8,1,2)
marvattackfin(false)


spkheight = spkheight + 0.15
spike(190,135,10,10,130-spkheight)
end

if musno == 26 then
onVOID = false
onENDING = true
end

end



function obstch(x1,x2,y1,y2)

local adjx = char.x + 8
local adjy = char.y + 8

if x1 > char.x and x2 < adjx then
if y1 > char.y and y2 < adjy then
gotHit()
end
end

end

function obstcle(x,y,sizex,sizey,col)

rect(
x,
y,
sizex,
sizey,
col
)

local finalx = x + sizex
local finaly = y + sizey
obstch(finalx,x,finaly,y)

end

function biglaserbm(x)
bgbmx = x + math.random(-1,1)
obstcle(bgbmx,0,bgbmsize,140,4)

bladdParticle(x+5,140,1,40,true,4)
blburst()


end

function obs1()

if obstimer == 1 then
obsx1 = 115
obsy1 = 90
end

if obstimer > 2 then
obsy1 = lerp(obsy1,140,0.05)
end


if obstimer > 30 then
obsy1 = lerp(obsy1,40,0.05)
end


if obstimer > 120 then
obsy1 = lerp(obsy1,-20,0.05)
end

if obstimer > 150 then
obsy1 = lerp(obsy1,195,0.05)
end


if obstimer == 240 then
obstimer = 0
end

obstcle(obsx1,obsy1,10,10,4)

bladdParticle(obsx1+5,obsy1+5,1,10,true,4)
blburst()

return true

end

function obs2()


if obstimer == 1 then
obsx2 = 40
obsx3 = 188
obsy2 = 90
end



if obstimer > 2 then
obsy2 = lerp(obsy2,30,0.05)
end

if obstimer > 30 then
obsy2 = lerp(obsy2,150,0.05)
end


if obstimer > 120 then
obsy2 = lerp(obsy2,190,0.05)
end


if obstimer > 150 then
obsy2 = lerp(obsy2,0,0.05)
end



if obstimer == 240 then
obstimer = 0
end

obstcle(obsx2,obsy2,10,10,4)
obstcle(obsx3,obsy2,10,10,4)

bladdParticle(obsx3+5,obsy2+5,1,10,true,4)
bladdParticle(obsx2+5,obsy2+5,1,10,true,4)
blburst()

end

function bgbmattack()
if obstimer > 1 and obstimer < 120 then
biglaserbm(75)
end

if obstimer > 120 then
biglaserbm(153)
end

end

function resetstatic()
screenstatic = false
statictimer = 0
end

function resetttrl()
ttrltimer = 0
ttrltrck = 0
ttrlslctn = 0
allwans = false
crrctans = false
ttrltrck5val = 0
ttrlobspos = 0
ttrlfail = false
end

function resetclosein(s,x)
closeinsize = s
closeinx = x
closeinsize2 = s
closeinx2 = x
lavapartcount = 0
lavaparticle = {}

end

function closein(x,mv)

if mv >= 3 then
closeinsize = closeinsize + mv
obstcle(x,0,closeinsize,140,4)
lavaaddParticle(closeinsize-x,math.random(0,140),5,20,"left",4)
end

if mv < 3 and mv > 0 then
closeinsize = closeinsize + mv
obstcle(x,0,closeinsize,140,4)
lavaaddParticle(closeinsize-40,math.random(0,140),5,20,"left",4)
end

if mv < 0 then
closeinsize2 = closeinsize2 + mv
obstcle(x+closeinsize2,0,x,140,4)
lavaaddParticle(closeinsize2 + x,math.random(0,140),5,20,"right",4)
end

lavaburst()

end

function bgbmattack2()
if obstimer > 1 and obstimer < 120 then
biglaserbm(70)
bgbmattack2x = 70
end

if obstimer > 120 and obstimer < 240 then
biglaserbm(120)
bgbmattack2x = 120
end


if obstimer > 240 and obstimer < 360 then
biglaserbm(190)
bgbmattack2x = 190
end


if obstimer > 360 then
biglaserbm(120)
bgbmattack2x = 120
end


bladdParticle(bgbmattack2x+10,140,1,70,true,4)
blburst()


end

function scene2()

obstimer = obstimer + 1
stracker = stracker + 1
if stracker == 1 then
lightenab = true
closeinsize = 5
lavapartcount = 0
lavaparticle = {}

end

if stracker == 480 then
lightenab = true
bgbmenab2 = true
obstimer = 0
bgbmsize = 20
stracker = 0
end

if lightenab then
lightningobs(90,true)
end

if bgbmenab2 then
bgbmattack2()
end

if stracker > 430 then
closein(0,3)
end

end


function scene1()

obstimer = obstimer + 1
stracker = stracker + 1

if isTouched == false then

if stracker == 1 then
obs1enab = true
end

if stracker == 480 then
obs1enab = false
obs2enab = true
end

if stracker == 480*2 then
obs1enab = true
obs2enab = true
end

if stracker == 480*3 then
obs1enab = true
obs2enab = true
bgbmenab = true
end
end

if obs1enab == true then
obs1()
end

if obs2enab == true then
obs2()
end

if bgbmenab == true then
bgbmattack()
end

end

function spike(xp,yp,s1,s2,h)

local spkvar = {
position = {
x = xp,
y = yp,
},

points = {
{x =xp, y = yp-h},
{x =xp-s1, y =yp},
{x =xp+s2,y =yp},
{x =xp,y =yp-h},
},
rad = xp-s1+xp+s2
}

tri(
xp,yp-h,
xp-s1,yp,
xp+s2,yp,
4
)

checkpolcol(spkvar,spkvar.rad)

end

function scene3()

obstimer = obstimer + 1


if obstimer == 480 and isTouched == false then
stracker = stracker+1
obstimer = 0
resetclosein(0,5)
spkheight = 0
finxval = 998
finslopeval = 998
char.y=90
char.x= 20
end

if stracker == 0 then
gravity()
spkheight = spkheight + 0.06
spike(130,135,30,50,80+spkheight)
obstcle(0,0,250,2,4)
closein(300,-0.2)
end

if stracker == 1 then

gravity()
spkheight = spkheight + 0.035

spike(180,135,30,20,50+spkheight)
spike(130,135,30,50,50+spkheight)
spike(80,135,30,50,50+spkheight)

spike(100,0,30,50,-50-spkheight)
spike(150,0,30,50,-50-spkheight)
spike(200,0,30,20,-50-spkheight)

closein(300,-0.2)


end

if stracker >= 2 and stracker < 6 then

if obstimer < 420 then
beamint(false)
end

if obstimer >= 420 and obstimer < 480 then
beamint(true)
end

end

if stracker == 3 then
spkheight = spkheight + 0.12
spike(190,135,10,10,80-spkheight)
closein(-20,0.3)

end

if stracker == 4 then
gravity()
obstcle(0,0,250,2,4)
obstcle(80,134,250,2,4)
closein(-20,0.2)
end

if stracker == 5 then
gravity()
spkheight = spkheight + 0.09

spike(190,135,30,10,10+spkheight)
spike(160,135,30,10,10+spkheight)
spike(120,135,10,20,10+spkheight)
spike(89,135,10,20,10+spkheight)

spike(230,0,30,20,-10-spkheight)
spike(190,0,30,10,-10-spkheight)
spike(160,0,30,10,-10-spkheight)
spike(120,0,10,20,-10-spkheight)
spike(89,0,10,20,-10-spkheight)

closein(300,-0.1)
closein(-20,0.2)
end
end

function scene4()

if musno == 12 then
bgmsg("just do it..",47,15,2,1)
end
if musno == 13 then
bgmsg("nothing will be lost",0,15,2,1)
end
if musno == 14 then
bgmsg("all people do it",24,15,2,1)
end
if musno == 15 then
bgmsg("STOP RESISTING",35,8,2,1)
end
if musno == 16 then
char.x = 20

scene4timer = scene4timer + 1

if scene4timer > 0 and scene4timer < 150 then
print("THATS IT",41,50,8,1,3)
end

if scene4timer > 150 and scene4timer < 300 then
print("IM GOING TO MAKE YOU DO IT",42,50,8,1,1)
rstcnttimer()
end

initstscrn(true,0)

if scene4timer == 1 then statictimer = 0 end
if scene4timer == 150 then statictimer = 0 end
if scene4timer == 300 then statictimer = 0 end
if scene4timer == 320 then st = 479 scene4timer = 0 musno = 17 end
end


if musno == 18 then

scene4timer = scene4timer + 1
mudat = mudat + 1


spr(170,bodyx,bodyy,0,1,0,0,2,2)

char.x = 20
teleporteff(msc4x,msc4y,tpspd,15)

if scene4timer > 1 and scene4timer < 50 then
msc4x = lerp(msc4x,200,0.05)
bodyy = lerp(bodyy,20,0.05)
end

if scene4timer > 120 and scene4timer < 240 then
print("This is your body right?",45,50,8,1,1)
marvinetp.x = 999
end

if scene4timer > 240 and scene4timer < 360 then
print("now it is..",82,50,8,1,1)
end

if scene4timer > 360 and scene4timer < 480 then
print("mine!",math.random(84,85),50,8,1,2)
mudat = 120
tpspd = 0.3
enablevhseff = true
blburst()
bladdParticle(msc4x,msc4y,2,100,true,math.random(4,6))
sfx(6,3,-1,3)


if scene4timer > 400 then
msc4x = lerp(msc4x,115,0.09)
msc4y = lerp(msc4y,-15,0.09)
end
end


kladdParticle(msc4x,msc4y)
klburst()

if mudat > 0 and mudat < 50 then
msc4y = lerp(msc4y,102,0.05)
end

if mudat > 50 then
msc4y = lerp(msc4y,98,0.05)
end

if mudat == 100 then mudat = 0 end
end

if musno == 19 then
if mudat > 110 then cls(15) sfx(7,60,-1,3) mudat = 1 scene4timer =0 bodyspr = 174 end

scene4timer = scene4timer + 1
mudat = mudat + 1

spr(bodyspr,bodyx,bodyy,0,1,0,0,2,2)

blburst()
bladdParticle(msc4x,msc4y,2,100,false,math.random(4,6))
char.x = 20

if scene4timer > 0 and scene4timer < 120 then
print("Now I will destroy your will",35,50,8,1,1)
print("will",179,50,15,1,1)
enablevhseff = false
end

if scene4timer > 120 and scene4timer < 240 then
print("And take control over you",46,50,8,1,1)
end

if scene4timer > 240 and scene4timer < 360 then
print("So I could watch those videos",33,50,8,1,1)
end

if scene4timer > 360 and scene4timer < 479 then
bodyspr = 206
teleporteff(msc4x,msc4y,tpspd,15)
bladdParticle(msc4x,msc4y,2,100,true,math.random(4,6))
print("And gain",math.random(43,44),50,8,1,3)
print("unlimited pleasure!",math.random(6,7),75,4,1,2)

sfx(6,3,-1,3)
statictimer = 0
end

if scene4timer > 479 then
sfx(7,60,-1,3)
statictimer = 0
initstscrn(true,math.random(4,6))
fonVOID2 = true
end

if mudat > 0 and mudat < 50 then
bodyy = lerp(bodyy,22,0.05)
end

if mudat > 50 then
bodyy = lerp(bodyy,18,0.05)
end

if mudat == 100 then mudat = 0 end


end

end


function rstobstmr(f)
obstimer = 0
if f then
stracker = 0
end
end

function musictiming()


if (st==479) then
--music(10)
emptypart()
spkheight = 0

if noclr == 15 and isTouched == false then
resetclosein(0,5)
cls(15)
rstcnttimer()

if musno<24 then
char.x = 20
end

statictimer = 0

goingup = false
goingdown = true

end
end


initstscrn(false,15)

if (st>=480) and cntdwnvar > 0 then

if isTouched == false then
musno = 1+ musno
end

if musno < 4 then
music(0,0)
atr = 0
end

if musno == 4 or musno == 5 then
music(0,1)
atr = 0
char.x = 20
rstobstmr(true)
end

if musno == 6 or musno == 7 then
music(0,2)
atr = 0
char.x = 20
end


if musno == 8 or musno == 9 then
music(0,3)
atr = 0
char.x = 20
end


if musno == 10 or musno == 11 then

music(0,4)
atr = 0
char.x = 20
end


if musno > 11 and musno < 16 then

music(0)
atr = 0
char.x = 20
char.y = 90
end

if musno == 16 then
music(0,5)
atr = 0
char.x = 20
end

if musno > 16 and musno < 20 then
music(0,6)
atr = 0
char.x = 20
char.y = 90
end

if musno == 20 then
music(0,7)
atr = 0
char.x = 20
char.y = 90
end

if musno == 21 then
music(0,8)
atr = 0
char.x = 20
char.y = 90
end

if musno == 22 or musno == 23 then
music(0,9)
atr = 0
char.x = 20
char.y = 90
marvx = 50
marvine.x = 100
atr = 0
targetx = 0
targety = 0
end

if musno == 24 or musno == 25 then
music(0,10)
atr = 0
char.x = 20
char.y = 90
end


st = 0
end

end



function conchar()
spr(chrspr,char.x,char.y,0,1)

if isTouched == false then

if musno < 26 then
if btnp(4) and (goingdown==true) then
goingdown = false
goingup = true
elseif btnp(4) and (goingup==true) then
goingup = false
goingdown = true
end

if btn(2) and (char.x>0)then char.x=char.x-1 end
if btn(3) and (char.x<232) then char.x=char.x+1 end
end

char.pt1.x = char.x
char.pt1.y = char.y

char.pt2.x = char.x + 7
char.pt2.y = char.y

char.pt3.x = char.x + 7
char.pt3.y = char.y + 4

char.pt4.x = char.x + 4
char.pt4.y = char.y + 7

char.pt5.x = char.x
char.pt5.y = char.y + 4

end
end



function gravity()
if (char.y>0) and (goingup == true) then char.y=char.y-2 end
if (char.y<128) and (goingdown == true) then char.y=char.y+2 end
effect.goingup_efx() 
effect.goingdown_efx() 
end


function initstscrn(am,clr)

if statictimer < 20 then
screenstatic = true
enablevhseff = true

if am == true then
sfx(16,60,2,3)
end

if clr == 0 then
cls(15)
end

staticParticle(-1,0,50,250,true,clr)
staticint()

statictimer = statictimer + 1

shakex = math.random(-1,1)

if statictimer >= 19 then
emptypart()
screenstatic = false
shakex = oldshakex
enablevhseff = false
end
end
end

function xcheck()
if xbtnpressed == false then
return true
end
end

local optime = 0
local enabopani = false


function Opening()

print("This game contains flashing lights that",3,0)
print("might not be recommended for anyone",3,10)
print("who is prone to epilepsy.",3,20)

print("press a or z to continue",105,130,1)


if btnp(4) and xcheck() then
xbtnpressed = true
enabopani = true
end

if enabopani == true then
optime = optime + 1
initstscrn(false,0)

if optime == 20 then
xbtnpressed = false
firstStart = false
onMENU = true
end

end

end


function chtd1()
print("> Very boring today.", 3+shakex,0)
enablevhseff = false
end
function chtd2()
print("> Let's just visit it again.",3+shakex,10)
end
function chtd3()
print("> This isn't right",3+shakex,20)
end
function chtd3f1()
print("> Sure",3,20)
end
function chtd3f2()
print("> We're going to feel gooOOD", 3,30)
end
function chtd4()
print("> What do you mean not right?", 3+shakex,30)
end
function chtd5()
print("> It's normal to watch those videos", 3+shakex,40)
end
function chtd6f1()
print("> sigh, fine maybe just another one..",3,50)
end
function chtd6f2()
print("> Once? that's a lie ;)", 3+shakex,60)
end
function chtd6()
print("> I had enough", 3+shakex,50)
end
function chtd7()
print("> Alot of people do it", 3+shakex,60)
end
function chtd8()
print("> and its normal", 3+shakex,70)
end
function chtd9()
print("> I DONT WANT ANY MORE OF THIS", 3+shakex,80)
end
function chtd9f1()
print("> normal? THEN WHY AM I STOPPING MYSELF?!", 3+shakex,80)
end
function chtd9f2()
print("> now let's watch it :)", 3+shakex,90)
end
function chtd10()
print("> I DONT CARE MAKU", 3+shakex,90,8)
end
function chtd11()
print("> WE'RE DOING THIS RIGHT NOW", 3+shakex,100,8)
end
function chtd12()
print("> AND YOU'RE GOING TO WATCH THOSE VIDEOS", 3+shakex,110,8)
end

function ttrlcht1()

if ttrltrck == 0 and ttrltimer == 30 then
ttrltrck = 1
sfx(16,20,3)
end

if ttrltrck == 1 then
chtd1()
--music(99,0)
end

if ttrltrck == 1 and ttrltimer > 180 then
if ttrltimer == 182 then sfx(16,20,3) end

chtd2()

if ttrltimer > 250 then

allwans = true
print("> Press Left or Right to select a choice.",3+shakex,30,1)

if ttrlslctn == 0 then
print("> Sure",3,20,1)
crrctans = false
else
print("> This isn't right",3,20,1)
crrctans = true
end
end
end
end

function ttrlcht2()

if ttrltrck == 2 and ttrlfail then
chtd3f1()
chtd2()
chtd1()

--music(99,0)

if ttrltimer > 130 then
chtd3f2()
end

if ttrltimer > 250 then
initstscrn(true,0)
end

if ttrltimer == 130 then sfx(16,20,3) end
if ttrltimer == 270 then resetttrl() death = death + 1 end

end



if ttrltrck == 2 and ttrlfail == false then
chtd3()
chtd2()
chtd1()

--music(99,0)

if ttrltimer > 130 then
chtd4()
end

if ttrltimer > 250 then
chtd5()
end




if ttrltimer > 300 then

allwans = true

if ttrlslctn == 0 then
print("> YES",3,50,1)
crrctans = false
end

if ttrlslctn == 1 then
print("> Y E S",3,50,1)
crrctans = false
end

if ttrlslctn == -1 then
print("> I had enough",3,50,1)
crrctans = true
end

end


if ttrltimer == 130 then sfx(16,20,3) end
if ttrltimer == 250 then sfx(16,20,3) end

end
end

function ttrlcht3()

if ttrltrck == 3 and ttrlfail then
chtd6f1()
chtd5()
chtd4()
chtd3()
chtd2()
chtd1()

--music(99,0)

if ttrltimer > 130 then
chtd6f2()
end

if ttrltimer > 250 then
initstscrn(true,0)
end

if ttrltimer == 130 then sfx(16,20,3) end
if ttrltimer == 270 then resetttrl() death = death + 1 end

end


if ttrltrck == 3 and ttrlfail == false then

--music(99,0)
chtd6()
chtd5()
chtd4()
chtd3()
chtd2()
chtd1()


if ttrltimer > 130 then
chtd7()
end

if ttrltimer > 250 then
chtd8()
end



if ttrltimer > 300 then

allwans = true

if ttrlslctn == 0 then
print("> yes",3,80,14)
crrctans = false
end

if ttrlslctn == 1 then
print("> it",3,80,14)
crrctans = false
end

if ttrlslctn == 2 then
print("> is",3,80,14)
crrctans = false
end

if ttrlslctn == 3 then
print("> normal",3,80,14)
crrctans = false
end

if ttrlslctn == 4 then
print("> and",3,80,14)
crrctans = false
end

if ttrlslctn == 5 then
print("> I",3,80,14)
crrctans = false
end

if ttrlslctn == 6 then
print("> very",3,80,14)
crrctans = false
end

if ttrlslctn == 7 then
print("> much",3,80,14)
crrctans = false
end

if ttrlslctn == 8 then
print("> like",3,80,14)
crrctans = false
end

if ttrlslctn == 9 then
print("> watching",3,80,14)
crrctans = false
end

if ttrlslctn == 10 then
print("> those",3,80,14)
crrctans = false
end

if ttrlslctn == 11 then
print("> self",3,80,6)
crrctans = false
end

if ttrlslctn == 12 then
print("> tying",3,80,8)
crrctans = false
end

if ttrlslctn == 13 then
print("> videos",3,80,14)
crrctans = false
end

if ttrlslctn == 14 then
print("> I DONT WANT ANY MORE OF THIS",3,80,1)
crrctans = true
end


end

if ttrltimer == 130 then sfx(16,20,3) end
if ttrltimer == 250 then sfx(16,20,3) end

end
end

function ttrlcht4()

if ttrltrck == 4 and ttrlfail then
chtd9f1()
chtd8()
chtd7()
chtd6()
chtd5()
chtd4()
chtd3()
chtd2()
chtd1()

--music(99,0)

if ttrltimer > 130 then
chtd9f2()
end

if ttrltimer > 250 then
initstscrn(true,0)
end

if ttrltimer == 130 then sfx(16,20,3) end
if ttrltimer == 270 then resetttrl() death = death + 1 end

end


if ttrltrck == 4 and ttrlfail == false then


--music(99,0)
chtd9()
chtd8()
chtd7()
chtd6()
chtd5()
chtd4()
chtd3()
chtd2()
chtd1()


sfx(16,7,3)

if ttrltimer > 0 and ttrltimer < 130 then
initstscrn(true,15)
end

if ttrltimer > 130 then
chtd10()
end

if ttrltimer > 250 then
chtd11()
end

if ttrltimer > 370 and ttrltimer < 530 then
chtd12()
statictimer = 0
end

if ttrltimer > 490 then
initstscrn(true,0)
end

if ttrltimer == 530 then ttrltrck = 5 ttrltimer = 0 end


if ttrltimer == 130 then sfx(16,20,3) end
if ttrltimer == 250 then sfx(16,20,3) end
if ttrltimer == 370 then sfx(16,20,3) end

end
end

function rstcnttimer()
cntdwntmr = 0
cntdwnvar = 4
cntdwnvar2 = 8
end


function countDownNumber(value)
local cntdrawcolor = 1
if value == 2 then cntdrawcolor = 9 end
if value < 2 then cntdrawcolor = 8 end

print(value, 160, 130, cntdrawcolor)


end

function bgmsg(msg,x,clr,sz,cntdwn)

print(msg,x+shakex,50,clr,1,sz)
print("YES",15,90,yesclr)
print("NO",210,90,noclr)


if cntdwn == 2 then
print("Selecting current option in : ",2,130,outtime)
countDownNumber(cntdwnvar2)

cntdwntmr = cntdwntmr + 1

if cntdwntmr == 120 then
cntdwntmr = 0
cntdwnvar2 = cntdwnvar2 - 1
end
end

if cntdwn == 1 then
print("Selecting current option in : ",2,130,outtime)
countDownNumber(cntdwnvar)

cntdwntmr = cntdwntmr + 1

if cntdwntmr == 119 then
cntdwntmr = 0
cntdwnvar = cntdwnvar - 1
end
end

if onVOID then

if char.x > 203 and char.x < 300 then
noclr = 15
yesclr = 1
end

if char.x < 30 and char.x > 0 then
noclr = 1
yesclr = 15
end


if cntdwnvar == 0 and noclr == 1 then
outtime = 8
music(6)
gotHit()

end

end


if onTUTORIAL then
if cntdwnvar == 0 or cntdwnvar2 == 0 then

if char.x == 5 then
if ttrltrck5val == 0 or ttrltrck5val == 1 then
char.x = 5
statictimer = 0
rstcnttimer()
ttrltimer = 0
ttrlfail = true
ttrltrck = 4
end
end

if char.x == 200 then
if ttrltrck5val == 0 or ttrltrck5val == 1 then
char.x = 5
statictimer = 0
ttrltrck5val = ttrltrck5val + 1
statictimer = 0
rstcnttimer()
ttrltimer = 0
if ttrltrck5val == 2 then
music(2)
char.x = 200
ttrltrck5val = 2
end
end
end
end
end
end
char.x = 5

function tutorial()

if ttrltimer < 600 then
ttrltimer = ttrltimer + 1
end


ttrlcht1()
ttrlcht2()
ttrlcht3()
ttrlcht4()


if ttrltrck == 5 and ttrlfail == false then

if ttrltrck5val == 0 then
if isTouched == false then
sfx(16,7,3)
end
bgmsg("WATCH IT",45,15,3,1)
end

if ttrltrck5val == 1 then

if isTouched == false and cntdwnvar2>4 then
sfx(16,7,3)
end

initstscrn(true,0)
bgmsg("WATCH IT",45,8,3,2)
enablevhseff = true
obstcle(199,ttrlobspos,10,10,4)

if ttrltimer > 0 then
ttrlobspos = 87
end

if ttrltimer > 50 then
ttrlobspos = 100
end

if ttrltimer == 100 then ttrltimer = 2 end
end

spr(chrspr,char.x,char.y-2,0,1)

if char.x == 5 then
noclr = 1
yesclr = 15
else
noclr = 15
yesclr = 1
end


if ttrltrck5val == 2 then
allwans = false

char.x = lerp(char.x,113,0.05)
char.y = lerp(char.y,60,0.05)

print("FIRST URGE RESISTED",65,110)
initstscrn(false,15)

if ttrltimer < 70 then
statictimer = 0
end

if ttrltimer > 90 then
print("MAKU'S WILL RECOVERED",60,120)

end

if ttrltimer == 90 then chrspr = 1 end
if ttrltimer == 110 then chrspr = 2 end
if ttrltimer == 120 then chrspr = 1 end

if ttrltimer > 135 then
--music(80)

if ttrltimer > 160 then
print("Press A or Z to proceed",56,130,1)
end

if btnp(4) then
music(0)
char.x = 20
char.y = 90
rstcnttimer()
onVOID = true
onTUTORIAL = false
end
end

end


if ttrltimer == 1 then
if ttrltrck5val == 1 then
music(4)
crrctans = false
end
allwans = true
end

end


if isTouched == false then
if btnp(2)then
if allwans then

if ttrltrck == 5 then
char.x = 5
sfx(0,47,-1,2)
crrctans = false
end

if ttrltrck == 1 and ttrlslctn == 1 then
ttrlslctn = 0
sfx(0,47,-1)
end

if ttrltrck == 2 and ttrlslctn > -1 then
ttrlslctn = ttrlslctn - 1
sfx(0,47,-1)
end

if ttrltrck == 3 and ttrlslctn > 0 then
ttrlslctn = ttrlslctn - 1
sfx(0,47,-1)
end

end
end

if btnp(3) then
if allwans then

if ttrltrck == 5 then
char.x = 200
sfx(0,48,-1,2)
crrctans = true
end

if ttrltrck == 1 and ttrlslctn == 0 then
ttrlslctn = 1
sfx(0,48,-1)
end


if ttrltrck == 2 and ttrlslctn < 1 then
ttrlslctn = ttrlslctn + 1
sfx(0,47,-1)
end

if ttrltrck == 3 and ttrlslctn < 14 then
ttrlslctn = ttrlslctn + 1
sfx(0,47,-1)
end
end
end

if btnp(4) and allwans then

if crrctans == true then
sfx(0,48,-1)
ttrltimer = 0
allwans = false
ttrlslctn = 0
statictimer = 0
if ttrltrck == 5 then

if ttrltrck5val == 1 then
ttrltrck5val = 2
music(2)
end

if ttrltrck5val == 0 then
char.x = 5
statictimer = 0
ttrltrck5val = 1
rstcnttimer()
end
end

if ttrltrck == 3 then
ttrltrck = 4
end

if ttrltrck == 2 then
ttrltrck = 3
end

if ttrltrck == 1 then
ttrltrck = 2
end
end

if crrctans == false then
sfx(0,48,-1)
ttrltimer = 0
allwans = false
ttrlslctn = 0
ttrlfail = true
statictimer = 0

if ttrltrck == 5 then
ttrltrck = 4
ttrlfail = true
end

if ttrltrck == 3 then
ttrltrck = 4
end

if ttrltrck == 2 then
ttrltrck = 3
end

if ttrltrck == 1 then
ttrltrck = 2
end
end
end
end

end

local energyarr = {}
local energypartcount = 0

function suckenerg(x,y,xd,clr)

energypartcount = energypartcount + 1
local p = {}
p.x = x
p.y = y
p.ry = y+ math.random(-10,10)
p.xd = xd
p.t = 0
p.clr = clr
table.insert(energyarr,p)


end

function dupenerg()
for i,p in pairs(energyarr) do

p.x = lerp(p.x,p.xd,0.05)

line(p.x,p.ry,p.x+10,p.ry,p.clr)

p.t = p.t + 1

if (p.t == 50 ) then
table.remove(energyarr,i)
end

end
end

function endingscene()
if endscetimer == 0 then
marvine.state = 192
marvx = 161
marvy = 120

marvine.x = 161
marvine.y = 120

marvine.rot = 1
statictimer = 0
allwans = false

energyarr = {}
energypartcount = 0
end


if endscetimer == 150 then statictimer = 0 marvine.state = 174 marvine.rot = 0 end
if endscetimer == 400 then statictimer = 0 marvine.state = 206 marvine.rot = 0 end
if endscetimer == 500 then sfx(0,48,-1,2) hidmsg1 = true end

marvanimate("", marvx, marvy)

if endscetimer < 501 then
endscetimer = endscetimer + 1
end

mudat = mudat + 1

musno = 26

if endscetimer < 150 then
print("ENOUGH!",55,50,8,1,3)
end

if endscetimer > 150 and endscetimer < 400 then
print("JUST ACCEPT YOU'LL",13,30,8,1,2)
print("NEVER UNBOUND",5,50,8,1,3)
resetclosein(0,5)
end

if endscetimer > 400 then

if hidmsg2 == false then

if isTouched == false then
print("FROM ME",54,50,8,1,3)
else
print("See?",82,50,8,1,3)
end

end

if hidmsg2 == true then
endscetimer = endscetimer + 1
end

if hidmsg2 == false then
updtradcol()

if isTouched == false then
char.x = 117
char.y = 120
closein(-20,0.2)
closein(260,-0.2)
sfx(6,3,15,3)
end

if btnp(4) and (isTouched == false) then
hitonce = false
gthttmr = 0
isTouched = true
end

if closeinsize  > 82 then
allwans = true
end

end
end

if endscetimer > 650 and endscetimer < 670 then
print("WHAT?",75,50,8,1,3)
marvine.state = 174
bodyy = 20
bodyx = 130
end

if endscetimer > 720 then

if endscetimer > 720 and endscetimer < 1001 then
marvine.state = 142

print("NOOOOOO",55+shakex,50,8,1,3)
music(1)
bladdParticle(bodyx+7,bodyy+9,math.random(4,6),200,true,5)
suckenerg(bodyx+7,marvine.y+9,marvine.x-10,math.random(4,6))

marvx = 20
bodyx = lerp(bodyx,200,0.05)

teleporteff(marvine.x+7,marvine.y+9,0.5,7)
teleporteff(bodyx+7,bodyy+9,0.5,6)


if endscetimer > 720 then
print("> Multiple urges resisted!",2+shakex,80)
end
if endscetimer > 780 then
print("> Maku's Progamming skills recovered!",2+shakex,90)
end
if endscetimer > 840 then
print("> Maku's Vivid daydream recovered!",2+shakex,100)
end
if endscetimer > 900 then
print("> Maku's dopamine receptor recovered!",2+shakex,110)
end
if endscetimer > 960 then
print("> Reversed Phobia greatly reduced!",2+shakex,120)
end
if endscetimer > 980 then
print("> Rebooting..?",2+shakex,130)
end
end

if endscetimer == 1000 then
music(6)
end
if endscetimer == 1100 then
marvine.state = 225
end
if endscetimer == 1200 then
makuSprite = 138
end



if endscetimer == 1231 or
endscetimer == 1450 or
endscetimer == 1700
then
sfx(16,20,3)
end

if endscetimer > 1700 and endscetimer <= 1703 then 
music(7)
marvine.state = 229
cls(4)
char.x = 100
char.y = 25
rndmchrlrpx = char.x+math.random(20,30)
rndmchrlrpy = char.y+math.random(-30,30)
resetclosein(0,5)
gthttmr = 0
end




if endscetimer > 1230 and endscetimer <= 1450 then
print("Will to say NO?",70,50,8,1,1)
end


if endscetimer > 1450 and endscetimer <= 1700 then
print("That might be your",62,50,8,1,1)
print("BIGGEST MISTAKE",71+math.random(0,1),60+math.random(0,1),8,1,1)
end

if endscetimer > 1700 and endscetimer <= 5000 then
closein(-20,0.001)
closein(260,-0.001)  

if endscetimer > 1700 and endscetimer <= 2200 then
line(webcenterpoint+40,0,webcenterpoint-155,210,4)
line(webcenterpoint+20,0,webcenterpoint-10,210,4)
line(webcenterpoint+10,0,webcenterpoint+40,210,4)
bodyy = 20
bodyx = 104
spr(chrspr,char.x,char.y,0,1)

makuSprite = 234
print("You see Maku, even if you have",27,50,8,1,1)
print("WILLPOWER",89,60,15,1,1)
end

if endscetimer > 2200 and endscetimer <= 2400 then
bodyy = 20
bodyx = 104
marvine.x = 150
marvine.state = 166
print("I also have it as well",50,50,8,1,1)
bladdParticle(marvine.x+20,marvine.y+3,5,30,false,15)

spr(chrspr,char.x,char.y,0,1)
dthlstnr_ending()

if endscetimer > 2200 and endscetimer <= 2220 then
spawnLaserBeam(30,150,bodyy+10,20+10,15,true)
spr(128,20,marvine.y,0,1,marvine.rot,0,2,2)
end

end

if endscetimer > 2400 and endscetimer <= 3300 then
char.y = -100
marvine.state = 134
marvx = 106

teleporteff(marvine.x+8,marvine.y+8,tpspd,15)
bladdParticle(marvine.x+8,marvine.y+8,2,100,true,math.random(4,6))

if endscetimer > 2400 and endscetimer <= 2700 then
spr(makuSprite,bodyx,bodyy,0,1,0,0,2,2)
kladdParticle(marvine.x+8,marvine.y+8)
klburst()
print("and I     get",76,50,8,1,1)
print("WILL",110,50,15,1,1)
print("what I want",80+math.random(0,1),60+math.random(0,1),4,1,1)
funny_guiy = 135
end

if endscetimer > 2700 and endscetimer <= 2750 then
funny_guiy = lerp(funny_guiy, 80, 0.05)
print("Re",funny_guix,funny_guiy,15,1,2)
rect(funny_guix+25,funny_guiy-2,60,15,4)
print("Bound",funny_guix+26,funny_guiy,2,1,2)
enablevhseff = true
end



end

if btn(4) and endscetimer < 2200 then
char.y = 25 + math.random(0,1)
char.x = 100 + math.random(0,1)
bodyy = 20 + math.random(0,1)
bodyx = 104 + math.random(0,1)
webcenterpoint = 99 + math.random(0,1)
end


end

if endscetimer < 2400 then
spr(makuSprite,bodyx,bodyy,0,1,0,0,2,2)
end 

blburst()
dupenerg()
shakex = math.random(-1,1)
statictimer = 0

if endscetimer == 2750 then
enablevhseff = false
music(6,0)
endscetimer = 0
musno = 0
onTHUMBNAIL = true
onENDING = false
end
end




if endscetimer > 670 and endscetimer < 730 then
bladdParticle(marvine.x+7,marvine.y+9,5,200,true,5)
end

if endscetimer > 670 and endscetimer < 680 then cls(15) marvx = 0 end
if endscetimer == 670 then sfx(7,60,-1,3)blburst() end
if endscetimer > 700 and endscetimer < 710 then cls(15) marvx = 200 end
if endscetimer == 700 then sfx(7,60,-1,3) blburst() end
if endscetimer > 720 and endscetimer < 730 then cls(15)marvx = 0 end
if endscetimer == 720 then sfx(7,60,-1,3) blburst() end

if endscetimer < 670 then
conchar()

if hidmsg1 == false then
print("YES",15,90,1)
else
print("YES i know",15,90,15)
end

if isTouched == true then
print("YES i know",15,90,8)
end

if hidmsg2 == false then
if allwans == false then
print("NO",210,90,1)
end

if allwans then
print("but I have the will to say NO",70,90.5,1)
end
end

if hidmsg2 then
print("but I have the will to say NO",70,90.5,15)
end

end

if endscetimer > 0 and endscetimer < 500 then
initstscrn(true,0)
end


if btn(3) and allwans then
if fmsg == false and (isTouched == false) then
fmsg = true
hidmsg2 = true
sfx(0,48,-1,2)
end
end

if mudat > 0 and mudat < 50 then
marvy = 110
if endscetimer > 398 then
marvy = 20
bodyy = lerp(bodyy,23,0.05)
if endscetimer < 600 then
marvx = 112
end
end
end

if mudat > 50 then
marvy = 113
if endscetimer > 400 then
marvy = 23
bodyy = lerp(bodyy,20,0.05)
end
end

if mudat == 100 then mudat = 0 end
end



function trueEnding()

end



function voidScenes()

st = st + 1
musictiming()
conchar()
dthlstnr()
updtradcol()

if st == 1 then
char.x = 20
end


if fonVD then
cls(15)
outtime = 1
if st == 1 then
sfx(7,60,-1,3)
stracker = 0

if musno < 5 then
music(0)
end

if musno > 5 and musno <= 7 then
music(0,2)
end

if musno > 7 and musno <= 9 then
music(0,3)
stracker = 2
end

if musno > 9  and musno <= 11 then
music(0,4)
stracker = 4
end

if musno > 11 and musno <= 15 then
music(0)
stracker = 0
end

if musno > 19 and musno <= 21 then
music(0,7)
end

if musno >= 22 then
music(0,9)
end

end

if st == 20 then
fonVD = false
end
end

if musno < 4 then
scene1()
bgmsg("WATCH IT",45,15,3,1)
end


if musno == 4 or musno == 5 then
scene2()
bgmsg("WATCH IT",45,15,3,1)
end

if musno > 5 and musno < 12 then
scene3()
bgmsg("You'll feel good",22,15,2,1)

if musno == 6 then
print("Press A or Z to switch gravity",40,65,1)
end
end

if musno > 11 and musno < 20 then
scene4()
end

scenemf()
end


function fnlscene()
if endscetimer < 130 then
endscetimer = endscetimer + 1
end

if
endscetimer == 50 or
endscetimer == 100 or
endscetimer == 110 then
sfx(16,20,3)
if endscetimer == 110 then
music(5)
end
end

if endscetimer > 50 then
print("> afterevents() function initiated!",3,0)
end

if endscetimer > 100 then
print("> The journey still continues after that,",3,10)
print("> Maku then encounters a mysterious person",3,20)
print("> to help him overcome his obsessions.",3,30)
print("> __________________________________________________",3,40)
end


if endscetimer > 110 then
print("> Your statistics:",3,50)
print("> Total Failures:",3,60)
print("> "..death.."",3,70)
print("> Rank:",3,80)

if death == 0 then
print("S+",7,90,math.random(6,7),1,3)
print(" ASDFGHJKLXCBDS HOW!?",3,110,math.random(6,7),1)
mdlspr=36
end

if death > 0 and death <= 5 then
print("S",7,90,7,1,3)
print(" You're insane!",3,110,7,1)
mdlspr=38
end

if death > 5 and death <= 10 then
print("A",7,90,13,1,3)
print(" A PRO indeed!",3,110,13,1)
mdlspr=40
end

if death > 10 and death <= 20 then
print("B",7,90,12,1,3)
print(" Yeah BOII!",3,110,12,1)
mdlspr=42
end

if death > 20 and death <= 30 then
print("C",7,90,11,1,3)
print(" its ok, its cool.",3,110,11,1)
mdlspr=44
end

if death > 30 then
print("F",7,90,8,1,3)
print(" Aint much but honest work!",3,110,8,1)
mdlspr=46
end

spr(mdlspr,150,50,0,5,0,0,2,2)

print("> Press A or Z to reset",3,120)

if btnp(4) and endscetimer > 120 then
cls(15)
musno = 0
statictimer = 99
resetttrl()
resetTutovar()
resetVOIDvar()
death = 0
endscetimer = 0
--music(80)
chrspr = 2
t = 0
atr = 0
st = 0
char.x = 5
onMENU = true
onFINAL = false
end
end
end


function scenesequencer()
if firstStart then
Opening()
end

if onMENU then
Intro()
end

if onTUTORIAL then
tutorial()
dthlstnr()
updtradcol()
end

if onVOID then
voidScenes()
end

if onENDING then
dthlstnr()
endingscene()
end

if onFINAL then
fnlscene()
end

if onTHUMBNAIL then
thumbnail()
end
end

function thumbnail()
spr(256,78,50,1,1,0,0,10,3)

thumbnailTimer = thumbnailTimer + 1

if thumbnailTimer == 200 then
thumbnailTimer = 0
endscetimer = 0
onTHUMBNAIL = false
onFINAL = true
end
end

function TIC()
cls(0)
scenesequencer()
rect(-1,0,2,200,15)
rect(239,0,2,200,15)
end


function scanline(row)
if enablevhseff then
poke(0x3FF9,math.random(-1,1))
else
poke(0x3FF9,0)
end
end