-
-
' Don't draw sprites on screen until explicitly told to do so
-
TextMode (TEXT_BUFFERED)
-
-
' Load the ball texture
-
dim ballTex = LoadTex (".\Data\Ball.png")
-
-
' Check to see whether texture loaded correctly
-
if ballTex = 0 then print "Failed to load texture": end: endif
-
-
' Declare variables & Constants for drawing routine here
-
dim i, texture, y, x, spacing, yPosition
-
-
const maxBalls = 32 ' Maximum number of balls
-
-
spacing = 16 ' The amount of empty space between each ball
-
yPosition = (480 / 2) ' The height placement of each ball
-
-
' Ball structure
-
Struc SBall
-
dim sprite ' Number of current sprite
-
dim x# ' Horizontal position of current sprite
-
EndStruc
-
-
dim SBall balls(maxBalls) ' Use our structure
-
-
' Routine to initially draw sprites on screen
-
for x = 0 to maxBalls
-
-
' Create a sprite for each ball
-
balls (i).sprite = NewSprite (ballTex)
-
-
' Position each ball on the screen
-
balls (i).x# = (x * spacing) + 64
-
SprSetPos (balls (i).x#, yPosition)
-
-
' Get ready to setup the next ball
-
i = i + 1
-
-
next
-
-
' Declare variables for main loop here
-
dim amplitude, frequency, angle
-
-
amplitude = 90 ' Height of wave, try using values like, 0, 30, 60, 90.
-
frequency = 15 ' Number of waves, try using values like 15, 30, 45, 60
-
-
' Main game loop
-
while true
-
-
' Routine which places sprites at new positions
-
for i = 0 to maxBalls
-
-
' Reposition the sprite
-
BindSprite (balls (i).sprite)
-
SprSetY (amplitude * Sind(angle + (frequency * i)) + yPosition)
-
-
next
-
-
' Draw the sprites on the screen
-
DrawText ()
-
-
' Timing synchronisation
-
while SyncTimer (5)
-
-
' Increase the angle otherwise the balls won't move
-
angle = (angle % 360) + 1
-
-
wend
-
-
wend
-
Comments (0)
You don't have permission to comment on this page.