cmania.bmx 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. Rem
  2. Another Oldskool demo thingy, by FlameDuck and Razorien of Binary Therapy
  3. End Rem
  4. Strict
  5. Type rasterBar
  6. Field angle:Double,angleadd:Double,color[],freq:Double
  7. Function addRasterBar(aSpeed:Double, aFreq:Double, aColor[], aList:TList)
  8. Local temp:rasterBar = New rasterBar
  9. temp.angle=0
  10. temp.angleadd=aSpeed
  11. temp.freq=aFreq
  12. temp.color = aColor
  13. aList.addLast(temp)
  14. End Function
  15. Method drawRasterBar(xstart:Int, ycenter:Int, scale:Double)
  16. SetBlend LIGHTBLEND
  17. SetColor(color[0],color[1],color[2])
  18. angle:+angleadd
  19. For Local i:Int = 0 To 736
  20. Local temp:Int = i+xstart
  21. If temp > 0 Or temp < 799
  22. DrawImage rastaImage, temp, ycenter + Sin((i+angle)*freq)*scale
  23. End If
  24. Next
  25. End Method
  26. End Type
  27. Type polarVector
  28. Field length:Double, angle:Double
  29. Function Create:polarVector(aLength:Double, anAngle:Double)
  30. Local temp:polarVector = New polarVector
  31. temp.length=aLength;temp.angle=anAngle
  32. Return temp
  33. End Function
  34. End Type
  35. Type baseEntity
  36. Field offset:polarVector, angvel:Double
  37. Method update(anx:Double, any:Double) Abstract
  38. End Type
  39. Type circleBob
  40. Field velocity:polarVector
  41. Field x:Double,y:Double
  42. Field life:Int
  43. Function CreateCircleBob:circleBob(anx:Double, any:Double, avelocity:polarVector)
  44. Local temp:circleBob = New circleBob
  45. temp.x=anx;temp.y=any;temp.velocity=avelocity
  46. temp.life=20
  47. Return temp
  48. End Function
  49. Method update()
  50. x:+Cos(velocity.angle)*velocity.length
  51. y:+Sin(velocity.angle)*velocity.length*yaspect
  52. life:-1
  53. SetAlpha life/40!
  54. DrawImage cmBob, x, y
  55. End Method
  56. Method isDead:Int()
  57. If life < 1
  58. Return True
  59. Else If x < 0 Or x > 799
  60. Return True
  61. Else If y < 0 Or y > 599
  62. Return True
  63. End If
  64. Return False
  65. End Method
  66. End Type
  67. Type spawn Extends baseEntity
  68. Field cBobs:TList
  69. Method update(anx:Double,any:Double)
  70. offset.angle:+ angvel
  71. anx:+Cos(offset.angle)*offset.length
  72. any:+Sin(offset.angle)*offset.length*yaspect
  73. Local temp:circleBob = circleBob.createCircleBob(anx,any, polarVector.Create(Rnd(4,8),ATan2((320-any),(368-anx))))
  74. cBobs.addlast(temp)
  75. For Local mycBob:circleBob = EachIn cBobs
  76. mycBob.update()
  77. If myCBob.isDead()
  78. cBobs.remove(mycBob)
  79. End If
  80. Next
  81. End Method
  82. Function Create:spawn(anAngle:Double, anAngvel:Double, aRadius:Double)
  83. Local temp:spawn = New spawn
  84. temp.cBobs = New TList
  85. temp.offset = polarVector.Create(aRadius, anAngle)
  86. temp.angvel=anAngvel
  87. Return temp
  88. End Function
  89. End Type
  90. Type anchor Extends baseEntity
  91. Field spawns:TList
  92. Method update(anx:Double, any:Double)
  93. offset.angle:-angvel
  94. For Local mySpawn:spawn = EachIn spawns
  95. mySpawn.update(anx+Cos(offset.angle)*offset.length, any+Sin(offset.angle)*offset.length*yaspect)
  96. Next
  97. End Method
  98. Function Create:anchor(anAngle:Double, anAngvel:Double, aRadius:Double, numSpawns:Int)
  99. Local ddeg:Double = 360:Double/numSpawns
  100. Local myAnchor:anchor = New anchor
  101. myAnchor.spawns=New TList
  102. myAnchor.offset = PolarVector.Create(aRadius, anAngle)
  103. myAnchor.angvel=anAngvel
  104. For Local i = 1 To numSpawns
  105. Local temp:spawn = spawn.Create(ddeg*i, anAngvel, aRadius/2)
  106. myAnchor.spawns.addlast temp
  107. Next
  108. Return myAnchor
  109. End Function
  110. End Type
  111. Type root
  112. Field anchors:TList
  113. Method update()
  114. For Local myAnchor:anchor = EachIn anchors
  115. myanchor.update(368,320)
  116. Next
  117. SetAlpha 1
  118. End Method
  119. Function Create:root(anAngvel:Double, aRadius:Double, numAnchors:Int, numSpawns:Int)
  120. Local ddeg:Double = 360:Double/numSpawns
  121. Local myRoot:root=New root
  122. myRoot.anchors = New TList
  123. For Local i = 1 To numAnchors
  124. Local temp:anchor = anchor.Create(ddeg*i, anAngvel, aRadius, numSpawns)
  125. myRoot.anchors.addlast temp
  126. Next
  127. Return myRoot
  128. End Function
  129. End Type
  130. Type imageStrip
  131. Field effectImages:TImage[16]
  132. Field counter:Int
  133. Function loadImages:imageStrip(name:String)
  134. Local temp:imageStrip = New imageStrip
  135. For Local i:Int = 0 To 15
  136. Local fname:String = name+String(i)+".png"
  137. temp.effectImages[i] = LoadImage(fname)
  138. Next
  139. temp.counter = 0
  140. Return temp
  141. End Function
  142. Method update(x:Int,y:Int)
  143. counter:-1
  144. If counter < 0
  145. counter=15
  146. EndIf
  147. DrawImage effectImages[counter],x,y
  148. End Method
  149. End Type
  150. Graphics 800,600,32
  151. Global yaspect:Double = 3/5!
  152. Global rastaImage:TImage = LoadImage("rasta.png")
  153. Global logo:TImage = LoadImage("cmanialogo.png")
  154. Global cmBob:TImage = LoadImage("circlebob.png")
  155. MidHandleImage logo
  156. Global maskEffect:imageStrip = imageStrip.LoadImages("anim")
  157. Local myRBList:TList = New TList
  158. rasterBar.addRasterBar(3!,2!, [255,0,0], myRBList)
  159. rasterBar.addRasterBar(5!,1.5!, [0,255,0], myRBList)
  160. rasterBar.addRasterBar(7!,1!, [0,0,255], myRBList)
  161. Local angle:Double = 0
  162. Local effectRoot:root = root.Create(4, 200, 6, 6)
  163. While Not KeyHit(KEY_ESCAPE)
  164. Cls
  165. Local xpos:Int = 124 * Sin(angle)
  166. For Local i:rasterBar = EachIn myRBList
  167. i.drawRasterBar(xpos+32 , 28!, 28!)
  168. Next
  169. SetBlend ALPHABLEND
  170. DrawImage logo, 400 + xpos,58
  171. angle:+4
  172. angle:Mod 360
  173. Local temp = 255*Abs((-180+angle)/180!)
  174. SetColor temp,temp,temp
  175. DrawLine 0,116,799,116
  176. SetColor 255,255,255
  177. effectRoot.update
  178. Flip
  179. End While