Author Topic: Screen destruction  (Read 1500 times)

MrTAToad

  • Guest
Screen destruction
« on: 2010-May-12 »
Again, you can only compile this if you've got the beta (although I have included the executable).

Press a key to see the graphic break.

You will notice a speed up as soon as the first few graphics reach the alpha limit - if there was a rate limiter, then it wouldn't happen.  I cant include it as the extended type system doesn't like values being assigned to variables yet :)

Code: (glbasic) [Select]
// --------------------------------- //
// Project: TestDestruction
// Start: Wednesday, May 12, 2010
// IDE Version: 7.341

TYPE tBlock
image%
x
y
dirX
dirY
alpha
angle
scale
scaleDir
finish%
ENDTYPE

TYPE TDestruction
block[] AS tBlock

FUNCTION TDestruction_Initialise%:
LOCAL stp%=32
LOCAL screenWidth%
LOCAL screenHeight%
LOCAL block AS tBlock

DIM self.block[0]
GETSCREENSIZE screenWidth%,screenHeight%

FOR y%=0 TO screenHeight%-1 STEP stp%
FOR x%=0 TO screenWidth%-1 STEP stp%
block.image%=GENSPRITE()
IF block.image%<0 THEN RETURN FALSE

GRABSPRITE block.image%,x%,y%,stp%-1,stp%-1

block.x=x%*1.0
block.y=y%*1.0
block.dirX=0.0
WHILE block.dirX=0.0
block.dirX=RND(4.0)-2.0
WEND

block.dirY=0.0
WHILE block.dirY=0.0
block.dirY=RND(4.0)-2.0
WEND

block.alpha=-1.0
block.angle=0.0
block.scale=1.0

block.scaleDir=0.0
WHILE block.scaleDir=0.0
block.scaleDir=RND(2.0)-1.0
WEND

block.finish%=FALSE
DIMPUSH self.block[],block
NEXT
NEXT

RETURN TRUE
ENDFUNCTION

FUNCTION TDestruction_Process%:speed
LOCAL loop AS tBlock
LOCAL finish%

finish%=0
FOREACH loop IN self.block[]
IF loop.finish%=FALSE
ALPHAMODE loop.alpha
ROTOZOOMSPRITE loop.image,loop.x,loop.y,loop.angle,loop.scale

INC loop.alpha,speed*0.0025
INC loop.x,loop.dirX*speed
INC loop.y,loop.dirY*speed
INC loop.angle,speed*0.5
IF loop.angle>=360.0 THEN loop.angle=0.0

INC loop.scale,loop.scaleDir*speed*0.025
IF loop.scale<=0.0 OR loop.alpha>-0.01
loop.finish%=TRUE
ENDIF
ELSE
INC finish%
ENDIF
NEXT

IF finish%=BOUNDS(self.block[],0)
RETURN TRUE
ELSE
RETURN FALSE
ENDIF
ENDFUNCTION
ENDTYPE

LIMITFPS 0
SETSCREEN 1024,768,0

LOCAL destruction AS TDestruction

LOADBMP "Media/Screen.png"
SHOWSCREEN
destruction.TDestruction_Initialise()

CLEARSCREEN 0
KEYWAIT

WHILE KEY(1)=0
destruction.TDestruction_Process(1.0)
SHOWSCREEN
WEND

[attachment deleted by admin]

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4158
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: Screen destruction
« Reply #1 on: 2010-May-12 »
Oh no! My screen exploded!

Nice :)
I came. I saw. I played.

MrTAToad

  • Guest
Re: Screen destruction
« Reply #2 on: 2010-May-13 »
It needs a bit of work to make it somewhat more pleasant, and a sound effect wouldn't go amiss either :)

Offline trucidare

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1377
  • Bachelor of Fail
    • View Profile
Re: Screen destruction
« Reply #3 on: 2010-May-13 »
uhm KungPhoo? i need the beta gpc for mac ide :/ cant compile type methods
MacBook Pro 2,2 GHz Core 2 Duo, 4 GB RAM, 160 GB HDD, 8600M GT
Core i3 - 3,07 GHz, 8 GB Ram, 2.5 TB HDD, Geforce GTX 260+ OC