Post by tsh73 on Aug 27, 2023 2:02:06 GMT -5
jumping card effect
without actual card images (just white squares)
For version with card images, check this thread
libertybasiccom.proboards.com/thread/2391/easy-draw-cards-lb-bitmaps
Run it, then select from the menu Game|JumpCards
without actual card images (just white squares)
For version with card images, check this thread
libertybasiccom.proboards.com/thread/2391/easy-draw-cards-lb-bitmaps
Run it, then select from the menu Game|JumpCards
'playing with card bitmaps
nomainwin
WindowWidth=590 'Windows solitaire size (consistent with card size)
WindowHeight=440
'bitmap size
w=72
h=96
x0=8
y0=4
menu #gr, "&Game", "Show 4", [mnuShow4],"JumpCards", [mnuJump], |, "E&xit", [mnuExit]
menu #gr, "&Help", "&About", [mnuAbout]
open "Cards" for graphics_nsb_nf as #gr
#gr "trapclose [quit]" 'set "close" handler
#gr "home; posxy cx cy"
#gr "down; fill darkgreen; flush" 'put pen down so we can draw
'make card blank
#gr "place ";x0; " ";y0
#gr "boxfilled ";w+x0-1;" "; h+y0
#gr "boxfilled ";w+x0;" "; h+y0 'right black 2 pixels width
#gr "getbmp back ";x0; " ";y0;" ";w;" ";h
' wait
gosub [show4]
'goto [jumpCards]
wait 'wait for close event (allow to see what we draw)
[quit]
timer 0
close #gr
end
[mnuExit]
goto [quit]
[mnuShow4]
timer 0
gosub [show4]
wait
[mnuJump]
timer 0
gosub [show4]
goto [jumpCards]
[mnuAbout]
notice "Cards!"+chr$(13)+ _
"Jumping card animation"+chr$(13)+ _
""+chr$(13)+ _
"now without cards"
wait
'-----------------------------------------
[show4]
#gr "cls;fill darkgreen; flush"
yy = 1
for xx = 4 to 7
left=x0+(xx -1) * 82
top=y0+(yy -1) * 20
#gr "drawbmp "; "back";" ";left;" ";top
next
#gr, "flush"
return
[jumpCards]
dim left(7), top(7), dx(7), dy(7)
card=0
for xx = 4 to 7
gosub [resetXX]
next
timer 30, [tick]
[tick]
for xx = 4 to 7
left(xx)=left(xx)+dx(xx)
top(xx)=top(xx)+dy(xx)
dy(xx)=dy(xx)+1
#gr "drawbmp "; "back";" ";left(xx);" ";top(xx)
'is card down?
if top(xx)>2*cy-h then top(xx)=top(xx)-dy(xx):dy(xx)=0-dy(xx)/2
'is card out?
if left(xx)<0-w or left(xx)>2*cx then gosub [resetXX]
next
wait
return
[resetXX]
left(xx)=x0+(xx -1) * 82
top(xx)=y0+(yy -1) * 20
do
dx(xx)=5-(rnd(0)*15) 'mostly negative
loop while abs(dx(xx))<2 'but not 0
dy(xx)=rnd(0)*10-10
card=card+1
if card>52+8 then timer 0 : wait 'over then 52 cards and 4 backs are out
#gr "discard"
return