Post by tsh73 on Jan 10, 2019 21:31:31 GMT
Recreating thing created in Scratch2 in JB.
(only thing - Scratch had cat and star instead of caveman and pizza. And better undersea BG
And I did not made animation in Scratch, though sprites had frames)
Indeed things like "when hit the edge change direction" is hard to beat...
But without ability to copy paste between projects Scratch looks like a toy for me
(only thing - Scratch had cat and star instead of caveman and pizza. And better undersea BG
And I did not made animation in Scratch, though sprites had frames)
Indeed things like "when hit the edge change direction" is hard to beat...
But without ability to copy paste between projects Scratch looks like a toy for me
'kind of game
'tsh73 Jun 2019
nomainwin
WindowWidth = 640
WindowHeight = 480
UpperLeftX=1
UpperLeftY=1
sprPath$="sprites\" 'from jb folder
'sprPath$="C:\progs\Just BASIC v1.01\SPRITES\" 'from other folder - absolute path
open "Crab game" for graphics_nsb_nf as #gr
#gr "trapclose [quit]"
#gr "fill white; flush; down"
#gr "home; posxy cx cy"
#gr "setfocus"
loadbmp "UnderTheSea", sprPath$+"BG3.bmp"
#gr "background UnderTheSea"
dim crabVx(3),crabVy(3)
crabVx(1)=4:crabVy(1)=3
crabVx(2)=5:crabVy(2)=4
crabVx(3)=6:crabVy(3)=5
loadbmp "crab1", sprPath$+"crab1.bmp"
loadbmp "crab2", sprPath$+"crab2.bmp"
loadbmp "crab3", sprPath$+"crab3.bmp"
#gr "addsprite crab1 crab1 crab2 crab3"
#gr "cyclesprite crab1 1"
#gr "spritexy crab1 50 50";
#gr "spritemovexy crab1 ";crabVx(1);" ";crabVy(1)
#gr "spriteorient crab1 mirror"
crabW=61
crabH=51
#gr "addsprite crab2 crab1 crab2 crab3"
#gr "cyclesprite crab2 1"
#gr "spritexy crab2 -200 50";
'#gr "spritemovexy crab2 ";crabVx(2);" ";crabVy(2)
#gr "spriteorient crab2 mirror"
#gr "spritescale crab2 125"
#gr "addsprite crab3 crab1 crab2 crab3"
#gr "cyclesprite crab3 1"
#gr "spritexy crab3 -200 150";
'#gr "spritemovexy crab3 ";crabVx(3);" ";crabVy(3)
#gr "spriteorient crab3 mirror"
#gr "spritescale crab3 150"
loadbmp "cave1", sprPath$+"cave1.bmp"
loadbmp "cave2", sprPath$+"cave2.bmp"
#gr "addsprite cave cave1 cave2"
#gr "cyclesprite cave 1"
#gr "spritexy cave 550 400"
manW=43
manH=74
manV=7
loadbmp "pizza", sprPath$+"pizza.bmp"
#gr "addsprite pizza pizza"
#gr "spritexy pizza 300 200"
pizzaW=31
pizzaH=30
#gr "when mouseMove [Move]"
hp=10
points=0
msg$=space$(10)
#gr "font 20 bold"
timer 100, [nxt]
pizzaOff=0
hit=0
isRun=1
[nxt]
if (hit=0) and isRun then
#gr "spritexy? cave x y"
d = sqr((toX-x)^2+(toY-y)^2)
if d = 0 then d=1 'prevent div/0
dx = (toX-x)/d*manV
dy = (toY-y)/d*manV
#gr "spritexy cave ";x+dx;" ";y+dy
if dx <0 then
#gr "spriteorient cave mirror";
else
#gr "spriteorient cave normal";
end if
end if
#gr "spritecollides cave list$"
if instr(list$, "pizza") then
t2Return=time$("ms")+2000
#gr "spritevisible pizza off"
#gr "spritexy pizza -200 0"
pizzaOff=1
points=points+1
if points=5 then 'crab2
'release The Kraken
px=int(rnd(0)*(2*cx-crabW))
py=int(rnd(0)*(2*cy-crabH))
#gr "spritexy crab2 ";px;" ";py
#gr "spritemovexy crab2 ";crabVx(2);" ";crabVy(2)
end if
if points=10 then 'crab3
px=int(rnd(0)*(2*cx-crabW))
py=int(rnd(0)*(2*cy-crabH))
#gr "spritexy crab3 ";px;" ";py
#gr "spritemovexy crab3 ";crabVx(3);" ";crabVy(3)
end if
end if
if pizzaOff and (time$("ms")>t2Return) then
#gr "spritevisible pizza on"
px=int(rnd(0)*(2*cx-pizzaW))
py=int(rnd(0)*(2*cy-pizzaH))
#gr "spritexy pizza ";px;" ";py
pizzaOff=0
end if
if isRun and hit=0 then
if instr(list$, "crab") then
t2Return=time$("ms")+1000
hit=1
msg$=" Ouch! "
'1234567890
hp=hp-1
if hp <1 then'die
isRun=0
msg$="Game over!"
#gr "spriteorient cave flip"
#gr "spritemovexy cave 0 -3"
#gr "cyclesprite cave 0"
end if
end if
end if
if isRun and hit and (time$("ms")>t2Return) then
hit=0
msg$=space$(10)
end if
#gr "spritexy? crab1 x y"
crabVChanged=0
if (x+crabW>2*cx ) or (x<0) then crabVx(1)=0-crabVx(1): crabVChanged=1
if (y+crabH>2*cy ) or (y<0) then crabVy(1)=0-crabVy(1): crabVChanged=1
if crabVChanged then
#gr "spritemovexy crab1 ";crabVx(1);" ";crabVy(1)
if crabVx(1) >0 then
#gr "spriteorient crab1 mirror";
else
#gr "spriteorient crab1 normal";
end if
end if
#gr "spritexy? crab2 x y"
crabVChanged=0
if (x+crabW>2*cx ) or (x<0) then crabVx(2)=0-crabVx(2): crabVChanged=1
if (y+crabH>2*cy ) or (y<0) then crabVy(2)=0-crabVy(2): crabVChanged=1
if crabVChanged then
#gr "spritemovexy crab2 ";crabVx(2);" ";crabVy(2)
if crabVx(2) >0 then
#gr "spriteorient crab2 mirror";
else
#gr "spriteorient crab2 normal";
end if
end if
#gr "spritexy? crab3 x y"
crabVChanged=0
if (x+crabW>2*cx ) or (x<0) then crabVx(3)=0-crabVx(3): crabVChanged=1
if (y+crabH>2*cy ) or (y<0) then crabVy(3)=0-crabVy(3): crabVChanged=1
if crabVChanged then
#gr "spritemovexy crab3 ";crabVx(3);" ";crabVy(3)
if crabVx(3) >0 then
#gr "spriteorient crab3 mirror";
else
#gr "spriteorient crab3 normal";
end if
end if
#gr "DRAWSPRITES"
'stats
#gr "place 0 0"
#gr "\\";using("###",points)
#gr "place 250 0"
#gr "\\";msg$
#gr "place 550 0"
#gr "\\";using("###",hp)
wait
[Move]
toX = MouseX
if toX>2*cx-manW then toX=2*cx-manW
toY = MouseY
if toY>2*cy-manH then toY=2*cy-manH
wait
[quit]
timer 0
close #gr
end