TGC Codebase Backup



Shootingtetris/were getting there by Rasdini

17th Feb 2005 23:01
Summary

Shoot the squares from bottom row, align colors in a row to clear color. (Work in progress)



Description

A 3D tetris type game in which you shoot blocks from the bottom attempting to line up a row of colors to drop cubes. (Work in progress.)



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    Rem Project: Shooting tetris
Rem Created: 2/17/2005 3:00:41 PM

Rem ***** Main Source File *****

Rem this is a test save
set text size 8
hide mouse
set display mode 800,600,16
sync on
set physics frame rate 60
backdrop on
color backdrop rgb(0,0,0)
autocam off
ink RGB(119,119,255),0
cls
make object box 1000,2,2,20:color object 1000,RGB(15,179,240)
set object collision off 1000
position object 1000,0,10,-100

create bitmap 2,50,50
ink rgb(0,0,0),0
for x=0 to 50:line x,0,x,50:next x
ink RGB(0,255,255),0
for y=20 to 30:line 0,y,40,y:next y
for x=35 to 50:line x,25,35,0:line x,25,35,50:next x
get image 1001,0,0,50,50
delete bitmap 2

make object plain 1001,30,4

rem load image "arrow.bmp",1001

texture object 1001,1001

set object transparency 1001,1001
ghost object on 1001
set object collision off 1001

remstart
load image "red.bmp",1
load image "green.bmp",2
load image "blue.bmp",3
load image "orange.bmp",4
load image "purple.bmp",5
remend

dim blockang#(400)
dim c(6)
dim color(400)
dim column(400)
dim row(400)
dim rowcount(100)
dim objx(400):dim objy#(400):dim objz(400)
dim pick(6)
dim ccount(6)
dim blocklanded(400)
dim fspeedy#(400):dim falldiry#(400)
dim fspeedx#(400):dim falldirx#(400)
dim emdur(200):dim emx(200):dim emy(200)
dim emz(200)
dim ptlife(200)


position camera 5,20,-200
pitch camera up 24

for x=1 to 400
   objz(x)=100
   if x<7 then pick(x)=1:ccount(x)=1
next x

freq=500:speed#=.25:color=2:color1=1:rotate#=0:block=1:time=200
level=1:loopit=1:pause=-1:dump=50:zapper=0:limit#=5:aroset#=0:ardir#=.0125
limitnew=5:falling=0:lives=5:arangx#=0:bonus=0:levelchange=0:lchangenew=20
arscy#=40:adiry#=2
instruc=-1
dim zapscdir#(400):dim zapscale#(400)
for x=1 to 400:zapscdir#(x)=-.5:next x
   Rem main loop
do

if limit#<limitnew then inc limit#,.00125
if limit#>limitnew then dec limit#,.00125
if limit#<>limitnew
   if limit#>(limitnew-.005) and limit#<(limitnew+.005)
      limit#=limitnew
   endif
endif

inc arscy#,adiry#
if arscy#<40 or arscy#>300 then adiry#=adiry#*-1

if limit#<>limitnew
   inc arangx#,1:if arangx#>360 then arangx#=0
   rotate object 1001,arangx#,180,0
endif
scale object 1001,100,arscy#,100
position object 1001,-42,(limit#*10)+aroset#,100

if limit#=limitnew
   inc aroset#,ardir#:if aroset#<-2 or aroset#>3 then ardir#=ardir#*-1
   rotate object 1001,0,180,0
endif

if delayzap>0 then dec delayzap:goto skipzap
if zapper=0 and totallanded>10+limit#/2 and level>4 and falling=0 and lives>0
   changezap=rnd(500)
   if changezap=250
      zapper=1
      t6=0
      trycoloragain:
      zappercolor=rnd(color)+1
      if zappercolor>color then goto trycoloragain

      if zappercolor=1 then red=255:green=0:blue=0
      if zappercolor=2 then red=0:green=255:blue=0
      if zappercolor=3 then red=0:green=60:blue=180
      if zappercolor=4 then red=255:green=128:blue=0
      if zappercolor=5 then red=255:green=0:blue=255

      zapx#=100:zapy#=800:zdiry#=1:deg#=0:zaposetz#=0:zhit=0:zaprad#=0:zaposety#=0:raddir#=2

      for x=1 to 400
         if object exist(x)=1
            if color(x)=zappercolor
               zapscale#(x)=75+rnd(25)
            endif
         endif
      next x

      make object cube 8000,10
      color object 8000,rgb(red,green,blue)
      remstart
      texture object 8000,zappercolor
      position object 8000,zapx#,zapy#,80
      remend
   endif
endif
skipzap:

if zapper=1 and falling=0 and lives>0
   if zapy#>50 then dec zapy#,zdiry#
   if zapy#<51 then zapy#=50
   if zapy#=50
      inc zaprad#,raddir#
      if zaprad#<-80 or zaprad#>80 then raddir#=raddir#*-1
      inc deg#,1:if deg#>360 then deg#=1
      zaposety#=sin(deg#)*zaprad#
      zaposetz#=cos(deg#)*zaprad#

      for x=1 to 400
         if object exist(x)=1
            if color(x)=zappercolor
               inc zapscale#(x),zapscdir#(x)
               if zapscale#(x)<40 or zapscale#(x)>120 then zapscdir#(x)=zapscdir#(x)*-1
               scale object x,zapscale#(x),zapscale#(x),zapscale#(x)
            endif
         endif
      next x
   endif
   position object 8000,zapx#,zapy#+zaposety#,80+zaposetz#
   pitch object up 8000,.5
   roll object right 8000,.5
endif

if inkey$()<>"p" and inkey$()<>"P" then releasepause=0

if inkey$()="p" and releasepause=0 or inkey$()="P" and releasepause=0
   releasepause=1
   pause=pause*-1
endif

if inkey$()<>"i" and inkey$()<>"I" then releaseinst=0
if inkey$()="i" and releaseinst=0 or inkey$()="I" and releaseinst=0
   releaseinst=1
   instruc=instruc*-1
endif

zrotate object 1000,rotate#*5


if delayshoot>0 then dec delayshoot

if upkey()=1 and object exist(500)=0 and delayshoot=0 and pause=-1 and instruc=-1 and falling=0 and lives>0
   delayshoot=400-level*8:if delayshoot<50 then delayshoot=50
   make object sphere 500,3:color object 500,rgb(255,0,0)
   position object 500,object position x(1000),10,-90
endif

          rem delete same colors when zapping
if zapper=1 and object exist(500)=1 and falling=0 and lives>0
   if zapy#=50
      position object 500,object position x(500),10,object position z(500)+1+(level*.0025)+(totallanded*.015)
      t5=object collision(500,0)
      if t5>0 and t5<401
         t6=t5
         if color(t5)=zappercolor
            if zappercolor=1 then red=255:green=0:blue=0
            if zappercolor=2 then red=0:green=255:blue=0
            if zappercolor=3 then red=0:green=60:blue=220
            if zappercolor=4 then red=255:green=128:blue=0
            if zappercolor=5 then red=255:green=0:blue=255
            zapper=0:zapy#=0:delete object 500
            delayzap=1000-level*50
            for pick=601 to 800
               if object exist(pick)=0
                  emx(pick-600)=int(object position x(8000))
                  emy(pick-600)=int(object position y(8000))
                  emz(pick-600)=int(object position z(8000))-20
                  make basic emitter pick,20
                  set object collision off pick
                  position object pick,emx(pick-600),emy(pick-600),emz(pick-600)
                  set emitter rate pick,10000
                  set emitter particle color pick,red,green,blue,255
                  set emitter explode pick,1
                  set emitter particle velocity pick,150,0
                  set emitter particle size pick,1.25,0
                  set emitter particle life pick,100,0
                  emdur(pick-600)=310:pick=800
               endif
            next pick
            delete object 8000
            for x=1 to 400
               if object exist(x)=1
                  if color(x)=zappercolor
                     color(x)=0:inc blocktotal
                     blocklanded(x)=0
                     dec ccount(column(x))
                     for pick=601 to 800
                        if object exist(pick)=0
                           emx(pick-600)=int(object position x(x))
                           emy(pick-600)=int(object position y(x))
                           emz(pick-600)=int(object position z(x))-20
                           make basic emitter pick,10
                           set object collision off pick
                           position object pick,emx(pick-600),emy(pick-600),0
                           set emitter rate pick,10000
                           set emitter particle color pick,red,green,blue,255
                           set emitter explode pick,1
                           set emitter particle velocity pick,90,50
                           set emitter particle size pick,1.25,50
                           set emitter particle life pick,100,0
                           emdur(pick-600)=310:pick=800
                           endif
                     next pick
                     delete object x
                     for y=1 to 400
                        if object exist(y)=1
                           if column(x)=column(y)
                              if row(y)>row(x)
                                 blocklanded(y)=0
                                 dec row(y)
                                 if row(y)=1 then set object collision on y
                              endif
                           endif
                        endif
                     next y
                  endif
               endif
            next x
            zappercolor=0
         endif
      endif
   endif
endif

for x=601 to 800
   if object exist(x)=1
      position object x,emx(x-600),emy(x-600),emz(x-600)
      dec emdur(x-600)
      if emdur(x-600)=300 then set emitter rate x,0
      if emdur(x-600)=0 then delete emitter x
   endif
next x

   rem check for bullet hit.  Does bullet exist?
if object exist(500)=1 and pause=-1 and instruc=-1 and falling=0 and lives>0
      rem yes there is a bullet. Move it.
   if zapper=0 then position object 500,object position x(500),10,object position z(500)+1+(level*.0025)+(totallanded*.015)
   if zapper=1 and zapy#>50 then position object 500,object position x(500),10,object position z(500)+1+(level*.0025)+(totallanded*.015)
   rem if t6>1 and t6<401 and zapper=1 then position object 500,object position x(500),10,object position z(500)+1+(level*.125)+(blockcount/400)
      rem check for collision.
   t1=object collision(500,0)
      rem did we hit a cube? (objects 1 to 400)
   if t1>0 and t1<401
         rem yes, we hit a cube. Dec # of cubes in that column by 1.
      dec ccount(column(t1))
      inc levelchange
      if color(t1)=1 then red=255:green=0:blue=0
      if color(t1)=2 then red=0:green=255:blue=0
      if color(t1)=3 then red=0:green=60:blue=220
      if color(t1)=4 then red=255:green=128:blue=0
      if color(t1)=5 then red=255:green=0:blue=255
      for pick=601 to 800
          if object exist(pick)=0
             emx(pick-600)=int(object position x(t1))
             emy(pick-600)=int(object position y(t1))
             emz(pick-600)=int(object position z(t1))-20
             make basic emitter pick,20
             set object collision off pick
             position object pick,emx(pick-600),emy(pick-600),emz(pick-600)
             set emitter rate pick,10000
             set emitter particle color pick,red,green,blue,255
             set emitter explode pick,1
             set emitter particle velocity pick,100,50
             set emitter particle size pick,1.25,50
             set emitter particle life pick,100,0
             emdur(pick-600)=310:pick=800
          endif
      next pick
         rem we must set blocks in motion above shot block.
      for x=1 to 400
            rem do we have a cube?
         if object exist(x)=1
               rem yes we do. x<>t1 makes sure were not chechking the object we just shot
            if x<>t1
                  rem it was a cube other than the one we shot, is it in the same column
               if column(x)=column(t1)
                     rem why, yes it is! Lets start droping cube again
                  blocklanded(x)=0
                     rem lower cubes destinationrow
                  dec row(x)
                     rem are we dropping to level 1? If yes turn collision on
                     rem so we can shoot cube.
                  if row(x)=1 then set object collision on x
               endif
            endif
         endif
      next x
         rem delete cube we shot and our bullets.
      delete object t1:delete object 500
      blocklanded(t1)=0
      color(t1)=0:inc blocktotal
   endif
      rem is there still a bullet?
   if object exist(500)=1
         rem did we miss past the cubes? if yes delete bullet so we can fire again.
      if object position z(500)>110 then delete object 500
   endif
endif

   rem I am zeroing out our row counts
for x=1 to 100
   rowcount(x)=0
next x
   rem check for full rows here
for x=1 to 400
      rem check through all objects and total our row counts
   if object exist(x)=1
         rem only landed blocks qualify.  Thus reducing rowcount(x) below 6
         rem meaning we shouldn't check later to see if colors
         rem match as it is not a full row.
      if blocklanded(x)=1
            rem inc # of objects in that row
         inc rowcount(row(x))
      endif
   endif
next x

if rowcount(limitnew)=6 and falling=0
   falling=1:hide object 1001
   if object exist(8000)=1 then delete object 8000
   if object exist(500)=1 then delete object 500
   zapper=0
   for x=1 to 400
      if object exist(x)=1
         scale object x,100,100,100
         fspeedy#(x)=(row(x)/10)     :falldiry#(x)=.0025
         if blocklanded(x)=1 then fspeedy#(x)=fspeedy#(x)*-1
         if fspeedy#(x)>-1 and blocklanded(x)=1 then fspeedy#(x)=-1
         if blocklanded(x)=0 then fspeedy#(x)=.5

         if object position x(x)<0
            fspeedx#(x)=.025
            chng=rnd(3):if chng=1 then fspeedx#(x)=.05
         endif
         if object position x(x)>0
            fspeedx#(x)=-.025
            chng=rnd(3):if chng=1 then fspeedx#(x)=-.05
         endif
         blocklanded(x)=0
      endif
   next x
endif

if falling=1
   for x=1 to 400
      if object exist(x)=1
         inc fspeedy#(x),falldiry#(x)
         rem if fspeedy#(x)<-.95 then fspeedy#(x)=-.95
         if object position y(x)<0
            fspeedy#(x)=(fspeedy#(x)*-1)+1
            if fspeedy#(x)>-1
               fspeedy#(x)=-1
               cng=rnd(7)
               if cng=1 then dec fspeedy#(x),.15
               if cng=2 then dec fspeedy#(x),.23
               if cng=3 then inc fspeedy#(x),.25
               if cng=4 then dec fspeedy#(x),.28
               if cng=5 then dec fspeedy#(x),.3
               if cng=6 then inc fspeedy#(x),.25
            endif
         endif

         if object position x(x)<-30 or object position x(x)>40
            falldirx#(x)=falldirx#(x)*-1
         endif

         zoset#=rnd(4)*.0115
         position object x,object position x(x)+fspeedx#(x),object position y(x)-fspeedy#(x),object position z(x)-(.00125+zoset#)
         rotate object x,blockang#(x),blockang#(x),0
         inc blockang#(x),2:if blockang#(x)>360 then blockang#(x)=1
         inc fspeedx#(x),falldirx#(x)

         if object position z(x)<35
            if color(x)=1 then red=255:green=0:blue=0
            if color(x)=2 then red=0:green=255:blue=0
            if color(x)=3 then red=0:green=60:blue=220
            if color(x)=4 then red=255:green=128:blue=0
            if color(x)=5 then red=255:green=0:blue=255
            for pick=601 to 800
                if object exist(pick)=0
                   emx(pick-600)=int(object position x(x))
                   emy(pick-600)=int(object position y(x))
                   emz(pick-600)=int(object position z(x))-20
                   make basic emitter pick,20
                   set object collision off pick
                   position object pick,emx(pick-600),emy(pick-600),emz(pick-600)
                   set emitter rate pick,10000
                   set emitter particle color pick,red,green,blue,255
                   set emitter explode pick,1
                   set emitter particle velocity pick,100,50
                   set emitter particle size pick,1.25,50
                   set emitter particle life pick,100,0
                   emdur(pick-600)=310:pick=800
                endif
            next pick
            delete object x
         endif
      endif
   next x
endif

if falling=1
   checkall=0
   for x=1 to 400
      if object exist(x)=1 then inc checkall
   next x
   if checkall=0
      for x=1 to 400
         color(x)=0:
         objz(x)=100
         if x<7 then pick(x)=1:ccount(x)=1:c(x)=0
      next x
      if level<30
         inc limitnew,2
      endif

      if loopit<1 then loopit=1
      if level>37
         inc limitnew,3
         dec loopit
      endif
      dec lives
      falling=0
      block=1
      if level<20 then dump=50
      if level>20 then dump=20
      if level>10 then speed#=speed#-(speed#*.25)
      if level>30 then speed#=speed#-(speed#*.25)

      show object 1001
   endif
endif

   rem check all possible rows.
if pause=-1 and instruc=-1 and falling=0 and lives>0
for x=1 to 100
         rem assign is our 6 cubes colors.(yes this sentence is proper English)
      assign=1
         rem did we get a full row when we checked?
      if rowcount(x)=6
            rem yes, full row. Check all objects in row and assign their colors
         for y=1 to 400
            if object exist(y)=1
                  rem is it in the same row?
               if row(y)=x and assign<7
                     rem yes it is in the same row. Assign color
                  c(assign)=color(y)
                     rem inc to get 2nd cubes color and so on until we get all 6
                  inc assign:if assign>6 then y=400
               endif
            endif
         next y
            rem were all cubes the same color
         if c(1)=c(2) and c(1)=c(3) and c(1)=c(4) and c(1)=c(5) and c(1)=c(6)
            if c(1)=1 then red=255:green=0:blue=0
            if c(1)=2 then red=0:green=255:blue=0
            if c(1)=3 then red=0:green=60:blue=220
            if c(1)=4 then red=255:green=128:blue=0
            if c(1)=5 then red=255:green=0:blue=255
               rem yes all cubes are the same color, lets delete all objects in row
            inc levelchange,6
            for y=1 to 400
                  rem is cube in our row? If yes, delete it
               if object exist(y)=1
                  if row(y)=x
                     rem yes, same row, delete it. I always use object exist() to make
                     rem sure I don't try to delete an object that doesn't exist
                     rem technically it shouldn't happen.
                     color(y)=0:inc blocktotal
                     for pick=1 to 200
                        if object exist(pick+600)=0
                           emx(pick)=int(object position x(y))
                           emy(pick)=int(object position y(y))
                           emz(pick)=int(object position z(y))-20
                           make basic emitter pick+600,10
                           set object collision off pick+600
                           position object pick+600,emx(pick),emy(pick),0
                           set emitter rate pick+600,10000
                           set emitter particle color pick+600,red,green,blue,255
                           set emitter explode pick+600,1
                           set emitter particle velocity pick+600,100,50
                           set emitter particle size pick+600,1.25,50
                           set emitter particle life pick+600,100,0
                           emdur(pick)=310:pick=200
                        endif
                     next pick
                     if object exist(y)=1 then delete object y
                     rem dec count of column we deleted cube from
                     dec ccount(column(y))
                  endif
               endif
            next y
               rem drop all cubes above row x
            for y=1 to 400
                  rem does it exist.
               if object exist(y)=1
                     rem yes it exist. Is it above row being deleted.
                  if row(y)>x
                        rem yes it is above. Start block falling again
                     blocklanded(y)=0
                        rem lower block 1 row
                     dec row(y)
                        rem is block in first row. If yes set collision on.
                     if row(y)=1 then set object collision on y
                  endif
               endif
            next y
               rem delete same colors
            for x=1 to 400
               if object exist(x)=1
                  if c(1)=color(x)
                     inc levelchange
                     color(x)=0:inc blocktotal
                     blocklanded(x)=0
                     dec ccount(column(x))
                     for pick=1 to 200
                        if object exist(pick+600)=0
                           emx(pick)=int(object position x(x))
                           emy(pick)=int(object position y(x))
                           emz(pick)=int(object position z(x))-20
                           make basic emitter pick+600,20
                           set object collision off pick+600
                           position object pick+600,emx(pick),emy(pick),0
                           set emitter rate pick+600,10000
                           set emitter particle color pick+600,red,green,blue,255
                           set emitter explode pick+600,1
                           set emitter particle velocity pick+600,100,50
                           set emitter particle size pick+600,1.25,50
                           set emitter particle life pick+600,100,0
                           emdur(pick)=310:pick=200
                        endif
                     next pick
                     delete object x
                     for y=1 to 400
                        if object exist(y)=1
                           if column(x)=column(y)
                              if row(y)>row(x)
                                 blocklanded(y)=0
                                 dec row(y)
                                 if row(y)=1 then set object collision on y
                              endif
                           endif
                        endif
                     next y
                  endif
               endif
            next x
         endif
      endif
   next x
endif

dec rotate#,speed#*2:if rotate#>360 then rotate#=0
if leftkey()=0 then release1=0
if leftkey()=1 and release1=0 and pause=-1
   release1=1
   if object position x(1000)>-20 then position object 1000,object position x(1000)-10,10,-100
endif
if rightkey()=0 then release2=0
if rightkey()=1 and release2=0 and pause=-1
   release2=1
   if object position x(1000)<30 then position object 1000,object position x(1000)+10,10,-100
endif

if delay1>0 then dec delay1:goto skipcube1
intro=rnd(freq)
if intro=freq/2 and pause=-1 and instruc=-1 and falling=0 and lives>0 or dump>0 and pause=-1 and instruc=-1 and falling=0 and lives>0
   if dump>0 then dec dump
   for lp=1 to loopit
      delay1=time
      tryagain1:
      pickit=rnd(5)+1
      if pick(pickit)=0 then goto tryagain1
      pick(pickit)=0
      make object cube block,9
      set object collision off block
      blockang#(block)=rnd(360)
      blocklanded(block)=0
      column(block)=pickit
      row(block)=ccount(pickit)
      if row(block)=1 then set object collision on block
      inc ccount(pickit)
      objx(block)=(pickit*10)-30
      objy#(block)=800
      color(block)=color1

      if color(block)=1 then color object block,RGB(255,0,0)
      if color(block)=2 then color object block,RGB(0,255,0)
      if color(block)=3 then color object block,RGB(0,0,255)
      if color(block)=4 then color object block,RGB(255,128,0)
      if color(block)=5 then color object block,RGB(255,0,255)
         remstart
      if color(block)=1 then texture object block,1
      if color(block)=2 then texture object block,2
      if color(block)=3 then texture object block,3
      if color(block)=4 then texture object block,4
      if color(block)=5 then texture object block,5
         remend
      if zapper=1
         if color(block)=zappercolor
            zapscale#(block)=75+rnd(20)
         endif
      endif

      inc color1:if color1>color then color1=1

      position object block,objx(block),objy#(block),objz(block)
      tryblockagain:
      inc block:if block>400 then block=1
      if object exist(block)=1 then goto tryblockagain
      check1=0
      for x=1 to 6
      if pick(x)=1 then inc check1
      next x
      if check1=0
         for x=1 to 6
            pick(x)=1
         next x
      endif
   next lp
endif
skipcube1:

 rem lets move falling cubes
if pause=-1 and instruc=-1 and falling=0 and lives>0
   for x=1 to 400
         rem does cube exist?
      if object exist(x)=1 and blocklanded(x)=0
            rem yes it does, is it falling?
         if object position y(x)>row(x)*10 and blocklanded(x)=0
               rem yes the cube is falling, move it at current speed.
            dec objy#(x),speed#+(level*.025)+(totallanded*.0025)
            position object x,objx(x),int(objy#(x)),objz(x)
               rem rotate cube while we are falling
            rotate object x,-blockang#(x),0,0
            inc blockang#(x),.25:if blockang#(x)>360 then blockang#(x)=1
               rem are we landed?  If yes then set blocklanded(x) to 1
               rem and rotate object to 0,0,0 and
               rem objy#(x)=int(objy#(x)), this rounds our landed objects y value to row*10
            if int(objy#(x))<=row(x)*10 then blocklanded(x)=1:rotate object x,0,0,0:objy#(x)=row(x)*10:position object x,objx(x),objy#(x),objz(x)
         endif
      endif
   next x
endif

blockcount=0
totallanded=0
for x=1 to 400
   if object exist(x)=1
      inc blockcount
      if blocklanded(x)=1 then inc totallanded
   endif
next x

set cursor 0,0:ink RGB(119,119,255),0
print "LIVES-------------------->";lives
print "LEVEL-------------------->";level
print "TOTAL BLOCKS PRESENT----->";blockcount
print "TOTAL BLOCKS LANDED------>";totallanded
print "TOTAL BLOCKS OBLITERATED->";blocktotal
set cursor 0,screen height()-60
print "Press 'i' for instructions.";
set cursor 0,screen height()-40
print "Press 'p' to pause the game.";

if falling=0 and lives>0
   set cursor object screen x(1001)-(80+(limitnew)),object screen y(1001)-6
   print "LIMIT:";limitnew
endif
if lives=0
   set cursor screen width()/2-50,screen height()/2
   print "GAME OVER!!!!"
   set cursor screen width()/2-50,screen height()/2+20
   print "PLAY AGAIN(y/n)?"
   if inkey$()="n" or inkey$()="N" then end
   if inkey$()="y" or inkey$()="Y"
      for x=1 to 400
         objz(x)=100
         if x<7 then pick(x)=1:ccount(x)=1
      next x
      freq=500:speed#=.25:color=2:color1=1:rotate#=0:block=1:time=200:blocktotal=0
      level=1:loopit=1:pause=-1:instruc=-1:dump=50:zapper=0:limit#=5:aroset#=0:ardir#=.0125
      limitnew=5:falling=0:lives=5:arangx#=0:bonus=0:levelchange=0:lchangenew=20
      arscy#=40:adiry#=1
   endif
endif

if pause=1 or instruc=1
   if pause=1 and instruc=-1
      set cursor screen width()/2-40,screen height()/2-8
      print "!!!GAME PAUSED!!!"
   endif
   if instruc=1
      set cursor 0,200:ink rgb(255,0,0),0
      print "                    Pretty simple."
      ink RGB(0,255,0),0
      print "          Move left and right with arrow keys."
      print "          Shoot with the up arrow key."
      ink rgb(0,0,255),0
      print "          Shoot out the bottom blocks to drop blocks in any column."
      ink RGB(255,128,0),0
      print "          Line up any row across with the same color"
      print "          and you've destroyed all blocks of that color."
      ink RGB(128,0,255),0
      print "          When colored block drops from right and cubes pulsate,"
      print "          shoot that color to destroy all blocks of that color."
      ink rgb(255,0,0),0
      print "          Press 'p' to pause and unpause game."
      print "          Press 'i' to show or hide instructions."
   endif
   for x=1 to 400
       if object exist(x)=1
          if blocklanded(x)=0
             rotate object x,rotate#,rotate#,rotate#
          endif
       endif
   next x
endif

if levelchange>lchangenew
   levelchange=0
   inc level
   if level>10 and lchangenew=20 then lchangenew=50
   if level>30 and lchangenew=50 then lchangenew=100
   if level>3 and level<7 then inc color
   if level=10 then limitnew=10
   if level=15 then inc limitnew,5
   if level=18 then inc limitnew,5
   if level>5 then inc speed#,.025
   if speed#>.5 then speed#=.5
   if level=2 then inc loopit
   if level=5 then inc loopit
   if level=6 then inc loopit
   if level>10 then inc loopit
   if loopit>8 then loopit=8
   if level>20 and level<26 then inc limitnew,2
   if level>25 then dec limitnew,2
   if level>25 and limitnew<4 then limitnew=4
   if level>30 and limitnew=4 then limitnew=6
   if level=5 then dec freq,100
   if level=10 then dec freq,100
   if level>20 then dec freq,50
   if freq<50 then freq=50
   if level>40 then dec loopit,2
   if level>50 then dec loopit,4
endif

if blocktotal>500 and bonus=0
   bonus=1
   inc lives
endif
if blocktotal>1000 and bunus=1
   bonus=2
   inc lives
endif
if blocktotal>1500 and bonus=2
   bonus=3
   inc lives
endif
if blocktotal>2000 and bonus=3
   bonus=4
   inc lives,5
endif

update physics
sync
loop