02-26-2024, 01:31 PM
(02-22-2024, 07:20 PM)johnno56 Wrote: "more advanced"...
more advanced...perhaps a 3D-Pool
I just realized that making a 3D-Pool need a lot of different angles of 3D sprite sheet balls
... and when I tried to animate a 3D ball rotated on its axis ... it exploded [ Just my fantasy ]
Code:
'Source :
'3D Ball Sprite Sheet https://emunix.emich.edu/~evett/GameProgramming/BookCode/chapter11.new/multithread/sphere.bmp
'Explosion Sprite Sheet http://www.nordenfelt-thegame.com/blog/wp-content/uploads/2011/11/explosion_opaque.png
'----------------
' INITIALIZATION
'----------------
#win32
set window "Ball",200,200,false
set redraw off
cGreen = [0,128,0]
cWhite = [255,255,255]
'Sprite class definition
Sprite =
[
'---- Properties ----
img :loadimage("img/ball.png",8,4),
x :width(primary)/2-30,
y :height(primary)/2-30,
sf :0 'speed factor of rotation
]
Ball = copy(Sprite)
Explosion = copy(Sprite)
Explosion.img = loadimage("img/explosion.png",5,5)
Explosion.x = Sprite.x-60
Explosion.y = Sprite.y-60
'----------------
' MAIN PROGRAM
'----------------
do
set color cGreen;cls;set color cWhite
'ball rotates on its axis
'the state of rotation : fast, slow then stop.
for i = 0 to 31
'set color cWhite
draw image Ball.img,Ball.x,Ball.y,i
redraw
Ball.speed = 200 - Ball.sf
set caret 10,10;wln "Speed : "+Ball.speed
fwait Ball.speed
next
'explosion visual effect
Ball.sf = Ball.sf + 5
if Ball.speed = 5 then
for i = 0 to 24
draw image Explosion.img,Explosion.x,Explosion.y,i
fwait 10
redraw
next
end
endif
loop