i made this breaker from earth save GWS : It works a little bit but needs more works on it.
Regards
' Creative Basic - A Simple Direct X Window
def w:window
def style,n,n1,n2,run,sprite_Raquette,Ballon:int
def sx,sy,sw,sh:int
def score,launched,count,lost:int
def Ballonx,Ballony,dt,ts:float
def BallonSpeedx,BallonSpeedy:float
def Raquettex,Raquettey,RaquetteSpeed:float
def sprite:int
sw = 1024 :' screen width
sh = 768 :' screen height
declare "kernel32",GetTickCount(),int
' game timing ..
TicksPerSecond = 40 :' number of frames per second
ts = 1.0 / TicksPerSecond :' game frame interval (sec)
dt = 1000.0 * ts :' game update interval (msec)
def test1,test2,down,newgame,gametime:int
type Brick
def fx:int
def fy:int
def fspr:int
endtype
' specify the number of bricks
n1 = 10
n2 = 10
def f[n1+1,n2+1]:Brick :'briques
style = @NOAUTODRAW|@NOCAPTION
window w,0,0,1024,768,style,0,"Creative Basic Direct X",main
setwindowcolor w,0
' Create a DirectX screen
createscreen(w,1024,768,32)
frontpen w,rgb(0,80,120)
setfont w,"Times New Roman",20,400,@SFITALIC
drawmode w, @TRANSPARENT
run = 1
centerwindow w
launch
' hide the cursor
setcursor w,@CSCUSTOM,0
' Charge l'image de fond
if DXNEWMAP(w,GETSTARTPATH + "stars.jpg",1024,768,1) = 0
messagebox w, "Could not load the background image","Error"
closewindow w
end
endif
' create a blank map filled with tile#0 ...
DXCREATEMAP w,1,1,0
DXDRAWMAP w
' Charge les briques
for i = 0 to n1
for j=1 to n2
f[i,j].fx = 92*i
f[i,j].fy = 17*j
f[i,j].fspr = dxsprite(w,getstartpath + "brick.bmp",90,15,1,0)
DXMOVESPRITE f[i,j].fspr,f[i,j].fx, f[i,j].fy
next j
next i
' Charge la raquette
sprite_Raquette=dxsprite(w,getstartpath + "raquette.bmp",90,15,0,0)
DXSETSPRITEDATA sprite_Raquette,@SDBLTTYPE, @BLTALPHA
DXSETSPRITEDATA sprite_Raquette,@SDTRANSKEY,0
' load the earth image ..
Ballon = dxsprite(w,getstartpath+"Ball.bmp",16,16,0,0)
DXSETSPRITEDATA Ballon,@SDBLTTYPE, @BLTALPHA
DXSETSPRITEDATA Ballon,@SDALPHA,0
waituntil run = 0
closewindow w
END
main:
select @CLASS
CASE @IDMOUSEMOVE
gosub mouse
CASE @IDCLOSEWINDOW
run = 0
CASE @idchar
' pressing the 'ESC'(ape) key will abort the program ...
key = @CODE
if (key = 27) then run = 0
CASE @IDTimer
' count down to new game ..
launched = launched - 1
if launched = 0
stoptimer w
gametime = GetTickCount()
endif
CASE @IDDXUPDATE
' display the score ..
setfont w,"Courier New",12,600
frontpen w,RGB(250,200,200)
move w, 30,10
print w, "Saved: ", score,"from: ", count, "starts"
' process graphics ..
if launched = 0
dxmovesprite Ballon, Ballonx, Ballony
' dxdrawsprite w,Ballon
else
setfont w,"Courier New",18,600
frontpen w,RGB(0,200,100)
move w, 400,300
print w, "Get Ready: ", launched
endif
DXMOVESPRITE sprite_Raquette, Raquettex,746
DXDRAWMAP w
DXDRAWALLSPRITES w
' update the ame status ..
if launched = 0 then update
'*******************
DXFLIP w
'*******************
endselect
return
sub Mouse
' update plasma position ..
Raquettex=@mousex
Raquettex = Raquettex + RaquetteSpeed * ts :' change plasma position
if Raquettex < 0 then Raquettex = 0
if Raquettex > sw - 120 then Raquettex = sw - 90
return
sub update
' update game status every 'dt' msec ..
if (GetTickCount() - gametime > dt)
BallonX = BallonX + BallonSpeedx * ts
BallonY = BallonY + BallonSpeedy * ts
' bounce the ball off the top, left, or right of the screen ..
' check for left side collision ..
if BallonX <= 0 then BallonSpeedx = - BallonSpeedx
' check for right side collision ..
if BallonX >= sw - 1 then BallonSpeedx = - BallonSpeedx
' check for top collision ..
if BallonY <= 0 then BallonSpeedy = - BallonSpeedy
' check for plasma collision ..
' only check for collision if the Earth is moving downwards
' and in the lower part of the screen ..
if (BallonSpeedy > 0) & (BallonY > 0.7 * sh)
' only check collision if sprites are suitably placed ..
test1 = ((BallonX +95) > RaquetteX) & (BallonX < (RaquetteX+95 ))
if test1 & (BallonY < RaquetteY+60)
' collision point is within 15 px of each side of the Earth sprite ..
if DXHITSPRITE(Ballon,Sprite_Raquette,1)
BallonSpeedy = - BallonSpeedy
Score = Score + 1
endif
endif
endif
'if BallonSpeedy < 0
sprite = DXHITANY(w, Ballon ,1)
if sprite <> Sprite_Raquette
DXREMOVESPRITE w, sprite
endif
' check for Earth lost from screen ..
if BallonY > sh
' pause for a short while ..
lost = timer
do: until (timer - lost) > 1
launch
endif
' reset gametime for next frame update ..
gametime = GetTickCount()
endif
return
sub RnFlip
' returns +1 or -1
def x:int
def ret: float
x = rnd(1000)
if (x < 500)
ret = +1.0
else
ret = -1.0
endif
return ret
sub launch
' routine to launch a new game ..
count = count + 1
'set intial values
Ballonx = sw / 2 - 125 :' earth starting x position
Ballony = sh / 2 - 125 :' earth starting y position
' set initial earth speed px/sec
BallonSpeedx = RnFlip() * (rnd(300.0) + 150)
BallonSpeedy = RnFlip() * (rnd(200.0) + 120)
' initial plasma positiom ..
Raquettey = sh - 50
Raquettex = (sw - 125) / 2
' start a new game ..
launched = 5 :' game launch in 2.5 seconds ..
starttimer w,500
return
You certainly have to change the path to load the images.
if you test it .give me some feedBack thanks