UnderwareDESIGN

PlayBASIC => Resources => Source Codes => Topic started by: Draco9898 on December 20, 2007, 10:31:05 AM

Title: Video feedback copyrect screen effect
Post by: Draco9898 on December 20, 2007, 10:31:05 AM
[pbcode]
; PROJECT : dmgnums
; AUTHOR  : Trevor
; CREATED : 10/2/2007
; EDITED  : 10/2/2007
; ---------------------------------------------------------------------
setfps 60
openscreen 800,600,32,2

LoadFont  "Arial",1,35,0

`loadsound "C:\slash2.ogg",1

Type tDmgNums
   X#, Y#, baseY#
   YVelo#
   alive, life
   THIS$
EndType
Dim DmgNums(80) As tDmgNums
Global DmgNumsBounce=0

Surf=New3Dimage(GetScreenWidth(),GetScreenHeight())

BaseDMG=600
Dim HitTimes(22)
HitTimes(0)=2
HitTimes(1)=4
HitTimes(2)=8
HitTimes(3)=16
HitTimes(4)=32
HitTimes(5)=64
HitTimes(6)=12
HitTimes(7)=12
HitTimes(8)=12
HitTimes(9)=12
HitTimes(10)=12
HitTimes(11)=122

Sync
wait 1000

Counter=0
ThisNum = BaseDMG
TOTALDMG= TOTALDMG+ThisNum

Do
   
   If waitflag=0
      `text 20,GetScreenHeight()-30,"TOTAL DAMAGE: "+STR$(TOTALDMG)
      sync
      wait 2000
      waitflag=1
   Endif
   
   cls 0
   DRawAlphaIMage Surf,-2,-4,0.8,false

   HandleDamageNumbers()

   
   this=this+1
   If this>HitTimes(Counter)
      this=0
      Counter=Counter+1
      If Counter>11
         Counter=0
         TOTALDMG=0
      Endif
         ThisNum = BaseDMG
         TOTALDMG=TOTALDMG+ThisNum
         `playsound 1
         CreateDamageNumbers(300+THISRANGE,300,ThisNum)
   EndIf
   text 20,GetScreenHeight()-55,Counter+1
   text 20,GetScreenHeight()-30,"TOTAL DAMAGE: "+STR$(TOTALDMG)

   `copy rect to give the screen a fast global blurring effect
   CopyRect 0,0,0,GetScreenWidth(),GetSCreenHeight(),surf,1,1   
   Sync   
loop


Psub CreateDamageNumbers(LocX#,LocY#,ThisNumber)
   ThisNumber$ = Str$(ThisNumber)
   Numbers=Len(ThisNumber$)
   For Y=1 To Numbers
      For X=1 To GetArrayElements(DmgNums().tDmgNums,1)
         If DmgNums(x).life<=0
            DmgNums(x).life =90
            DmgNums(x).THIS$=Mid$(ThisNumber$,Y,1)
            DmgNums(x).X#=LocX# + (14*Y)
            DmgNums(x).baseY#=LocY#
            DmgNums(x).Y#= -14
            DmgNums(x).YVelo# = -4 - (0.32*Y)
            ExitFor
         EndIf
      Next x
   Next y
EndPsub

Psub HandleDamageNumbers()
  For X=1 To GetArrayElements(DmgNums().tDmgNums,1)
      If DmgNums(x).life>0
         DmgNums(x).life = DmgNums(x).life -1
         DmgNums(x).Y#= DmgNums(x).Y# + DmgNums(x).YVelo#
         If DmgNums(x).Y#>0
            DmgNums(x).Y#=0
            If Abs(DmgNums(x).YVelo#)<0.4
               DmgNums(x).YVelo#=0
            Else
               `dampen   
               DmgNums(x).YVelo# = DmgNums(x).YVelo#*0.47
               DmgNums(x).YVelo# = DmgNums(x).YVelo#*-1
            EndIf
         Else
            `gravity
            DmgNums(x).YVelo# = DmgNums(x).YVelo# + 0.3
         EndIf
         Text DmgNums(x).X#,DmgNums(x).baseY# + DmgNums(x).Y#,DmgNums(x).THIS$
      EndIf
   Next x
EndPsub
[/pbcode]