Login Register
Frontpage Code library Pastebin

Liquid - Vesitehoste

Author: MaGetzUb
Added: 12. huhtikuuta 2011 kello 22.08
Edited: 20. huhtikuuta 2011 kello 21.16
Category: Efektit

Description

Tämmöinen Ruuttu:n Fluidize-efektistä saadun inspiksen innoittamana koodattu efekti. Liput(Vakiot) LIQ_WATER <- Vesi efekti LIQ_FIRE <- Kohina efekti LIQ_HORWAVE <- Vaakasuuntainen aaltoiluefekti LiQ_VERWAVE <- Pystysuuntainen aaltoiluefekti LIQ_HORRIPPLE <- Vain vaakasuoraa kohinaa LIQ_VERRIPPLE <- Vain pystysuoraa kohinaa Funktiot: LiquidSettings(quality, amp, angspeed) <- Säädetään efektin asetuksia Liquid(tyyli = 0, mask = True)

Code

Select all
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
//effect by: MaGetzUb 2011

SCREEN 640, 480
SCREEN 640, 480, 32, 2

Const LIQ_WATER = 0
Const LIQ_FIRE = 1
Const LIQ_HORWAVE = 2
Const LIQ_VERWAVE = 3
Const LIQ_HORRIPPLE = 4
Const LIQ_VERRIPPLE = 5 

Global SW
Global SH
SW = ScreenWidth()
SH = ScreenHeight()

Global Liq_Quality      : Liq_Quality = 5 //(paras laatu on 1 [koska 1 pikseli per aalto])
Global Liq_Freq          : Liq_Freq = 20
Global Liq_Ang          : Liq_Ang = 0
Global Liq_AngSpeed     : Liq_AngSpeed = 2

Dim Liq(1) As Integer 
Dim EFFNAMES(5) As String 
EFFNAMES(LIQ_WATER) = "Vesi"
EFFNAMES(LIQ_FIRE) = "Lämpöväreily"
EFFNAMES(LIQ_HORWAVE) = "Horisontaaliset aallot"
EFFNAMES(LIQ_VERWAVE) = "Vertikaaliset aallot"
EFFNAMES(LIQ_HORRIPPLE) = "Horisontaalinen väreily"
EFFNAMES(LIQ_VERRIPPLE) = "Vertikaalinen väreily"

Liq(0) = MakeImage(SW, SH)
Liq(1) = CloneImage(Liq(0))


kartta = LoadMap("Media\cdm2.til","Media\tileset.bmp")
PlayObject kartta,0,0,1

ukko = LoadObject ("Media\guy.bmp",72)

SetupCollision ukko, kartta, 1, 4, 2

Freq = 2
LiquidSettings(1, Freq, 10)
Repeat
    ClearText
    AddText "FPS: "+FPS()
    AddText EFFNAMES(efekti)+" käytössä."
    AddText "Säädä aallon taajuutta hiiren rullasta."
    AddText "Säädä laatua näppäimillä W/S"
    AddText "Vaihda efektiä Enterillä"
    AddText "Nykyinen taajuus: "+Freq
    AddText "Nykyinen laatu: "+koko+"px"
    If LeftKey() Then TurnObject ukko,5
    If RightKey() Then TurnObject ukko,-5
    If UpKey() Then MoveObject ukko,2
    If DownKey() Then MoveObject ukko,-2

    UpdateGame

    CloneCameraPosition ukko

    DrawGame 
    
    Freq = Freq + MouseMoveZ()
    koko = koko + KeyHit(cbkeyW) - KeyHit(cbkeys)
    If koko < 1 Then koko = 1 
    LiquidSettings(koko, Freq, 10)
    
    efekti = efekti + KeyHit(28)
    If efekti > 5 Then efekti = 0 
    Liquid(efekti, True)

    Color cbwhite
    
     
    DrawScreen True
Forever
//------------------------------------------------//
//FUNKTIOT
//------------------------------------------------//

Function LiquidSettings(quality, Freq, angspeed)
    Liq_Quality = quality
    Liq_Freq = Freq
    Liq_AngSpeed = angspeed  
EndFunction 


Function Liquid(tyyli = 0, mask = 1)
    pixrgb = getRGB(3) + getRGB(1) Shl 16 + getRGB(2) Shl 8
    For i = 0 To 1
        DrawToImage Liq(i)
        Cls 
        DrawToScreen 
    Next i
    
    Select tyyli
    Case 0
    
        Liq_Ang = Liq_Ang + Liq_AngSpeed
        
        For x# = 0 To SW / Liq_Quality
            CopyBox Int(x) * Liq_Quality, 0, Liq_Quality, SH, Int(x)*Liq_Quality, Int(Sin(x+Liq_Ang)*Liq_Freq), SCREEN(), Image(Liq(0))
        Next x#
    
        For y# = 0 To SH / Liq_Quality
            CopyBox 0, Int(y) * Liq_Quality, SW, Liq_Quality,  Int(Sin(y+Liq_Ang)*Liq_Freq), Int(y)*Liq_Quality , Image(Liq(0)), Image(Liq(1))
        Next y#
        
    Case 1
    
        For x# = 0 To SW / Liq_Quality
            CopyBox Int(x) * Liq_Quality, 0, Liq_Quality, SH, Int(x)*Liq_Quality, Int(Rnd(-Liq_Freq, Liq_Freq)), SCREEN(), Image(Liq(0))
        Next x#
    
        For y# = 0 To SH / Liq_Quality
            CopyBox 0, Int(y) * Liq_Quality, SW, Liq_Quality,  Int(Rnd(-Liq_Freq, Liq_Freq)), Int(y)*Liq_Quality , Image(Liq(0)), Image(Liq(1))
        Next y#    
    
    Case 2

        Liq_Ang = Liq_Ang + Liq_AngSpeed
        
        For x# = 0 To SW / Liq_Quality
            CopyBox Int(x) * Liq_Quality, 0, Liq_Quality, SH, Int(x)*Liq_Quality, Int(Sin(x+Liq_Ang)*Liq_Freq), SCREEN(), Image(Liq(1))
        Next x#    
    
    Case 3
    
        Liq_Ang = Liq_Ang + Liq_AngSpeed
        
        For y# = 0 To SH / Liq_Quality
            CopyBox 0, Int(y) * Liq_Quality, SW, Liq_Quality,  Int(Sin(y+Liq_Ang)*Liq_Freq), Int(y)*Liq_Quality , SCREEN() , Image(Liq(1))
        Next y#
        
    Case 4
    
        For x# = 0 To SW / Liq_Quality
            CopyBox Int(x) * Liq_Quality, 0, Liq_Quality, SH, Int(x)*Liq_Quality, Int(Rnd(-Liq_Freq, Liq_Freq)), SCREEN(), Image(Liq(1))
        Next x#

    Case 5

        For y# = 0 To SH / Liq_Quality
            CopyBox 0, Int(y) * Liq_Quality, SW, Liq_Quality,  Int(Rnd(-Liq_Freq, Liq_Freq)), Int(y)*Liq_Quality , SCREEN(), Image(Liq(1))
        Next y#      
        
    EndSelect 

    If mask Then 
        Color cbblack
        Box 0, 0, SW, SH
    EndIf 
    
    DrawImage Liq(1), 0, 0

    Color 0, 0, pixrgb
    
EndFunction

Comments

No comments. You can be first!

Leave a comment

You must be logged in to comment.