ubi44
New Member
Posts: 32
|
Post by ubi44 on Feb 15, 2024 11:28:48 GMT
A basic brick-breaker !
Screen _NewImage(800, 600, 32) _FullScreen _SquarePixels Randomize Timer Dim Shared Px, Py, Vx, Vy 'ball Position, Vector Dim Shared rX ' racket pos Dim Shared INCIDE INCIDE = 65 rX = _Width / 2 _MouseHide start: begin = 0 Life = 3 Lbrick = (_Width - 10 * 5 - 20 * 5) / 20 Hbrick = Lbrick / 2 yf = 2 + Int(Rnd * 7) xf = 10 + Int(Rnd * 10) ReDim b(xf, yf) For I = 1 To xf For j = 1 To yf b(I, j) = Int(Rnd * 2) If b(I, j) = 1 Then b(I, j) = 1.5 Next j, I speed = 0 Do
Cls , _RGB(25, 25, 25) For I = 50 To 0 Step -1 mi = (1 - I / 50) * 25 Line (0, _Height - I)-(_Width, _Height - I), _RGB(25 - mi, 25 - mi, 25 - mi) Next I
win = 1 For I = 1 To xf For j = 1 To yf x = _Width / 2 - 4 * xf - ((xf / 2) * Lbrick) + 10 + I * Lbrick + I * 5 y = 100 + j * Hbrick + j * 5 If Px >= x - Lbrick / 2 - 5 And Px <= x + Lbrick / 2 + 5 And Py >= y - Hbrick / 2 - 5 And Py <= y + Hbrick / 2 + 5 And b(I, j) <= 1.5 Then Left = -Px + (x - Lbrick / 2 - 5): Right = -(x + Lbrick / 2 + 5) + Px: Top = -Py + (y - Hbrick / 2 - 5): Bot = -(y + Hbrick / 2 + 5) + Py If Left >= Right And Left >= Top And Left >= Bot Then Px = x - Lbrick / 2 - 7 Vx = -Vx If Vx * Vx > 1 Then Vx = Sgn(Vx) * (1 - Rnd * .1) Vy = Sqr(1 - Vx * Vx) * Sgn(Vy) End If If Right >= Left And Right >= Top And Right >= Bot Then Px = x + Lbrick / 2 + 7 Vx = -Vx If Vx * Vx > 1 Then Vx = Sgn(Vx) * (1 - Rnd * .1) Vy = Sqr(1 - Vx * Vx) * Sgn(Vy) End If If Top > Bot And Top > Left And Top > Right Then Py = y - Hbrick / 2 - 7 Vy = -Vy If Vy * Vy > 1 Then Vy = Sgn(Vy) * (1 - Rnd * .1) Vx = Sqr(1 - Vy * Vy) * Sgn(Vx) End If If Bot > Top And Bot > Left And Bot > Right Then Py = y + Hbrick / 2 + 7 Vy = -Vy If Vy * Vy > 1 Then Vy = Sgn(Vy) * (1 - Rnd * .1) Vx = Sqr(1 - Vy * Vy) * Sgn(Vx) End If b(I, j) = b(I, j) + 1 End If If b(I, j) <= 1.5 Then For fx = 0 To Lbrick / 2 Step 2 For fy = 0 To Hbrick / 2 Step 2 cl = (fx / (Lbrick / 2)) * 128 + (fy / (Hbrick / 2)) * 128 If b(I, j) >= 1 Then b(I, j) = b(I, j) + .1 / fps If b(I, j) > 1.5 Then b(I, j) = 1.5 lm = 1 - (b(I, j) - 1) Line (x - fx, y - fy)-(x + fx, y + fy), _RGB(cl * lm, cl * lm, cl * lm), B Else Line (x - fx, y - fy)-(x + fx, y + fy), _RGB(cl, cl, cl), B End If Next fy, fx win = 0 End If If b(I, j) >= 2 And b(I, j) <= 3 Then lm = 1 - (b(I, j) - 2) b(I, j) = b(I, j) + 2.5 / fps For fx = 0 To Lbrick / 2 Step 2 For fy = 0 To Hbrick / 2 Step 2 cl = (fx / (Lbrick / 2)) * 128 + (fy / (Hbrick / 2)) * 128 Line (x - fx * lm, y - fy * lm)-(x + fx * lm, y + fy * lm), _RGB(cl / 2, cl / 2, cl / 2), B Next fy, fx win = 0 End If Next j, I Do: Loop While _MouseInput
frX = _MouseX If frX < 0 Then frX = 0 If frX > _Width Then frX = _Width If _FullScreen = 0 Then _MouseMove frX, _Height / 2 If Life > 0 And begin = 1 Then rX = frX ' If oldrx > frX Then rX = rX - (1 / fps) * 640 Else rX = rX + (1 / fps) * 640 oldrx = rX If rX < 60 Then rX = 60 If rX > _Width - (60) Then rX = _Width - (60) Line (rX - (50), _Height - 24)-(rX + (50), _Height - 23), _RGB(105, 105, 105), B Line (rX - (50), _Height - 21)-(rX + (50), _Height - 21), _RGB(55, 55, 75) For mo4 = 1 To 10 Line (rX - (50 - mo4 * .5), _Height - 25 + mo4)-(rX + (50 - mo4 * .5), _Height - 25 + mo4), _RGB(125 - mo4 * 10, 125 - mo4 * 10, 125 - mo4 * 10) Next mo4 ti = ti + (1 / fps) * 640 If ti > _Pi * 2 Then ti = 0 cv = 175 * Abs(Cos(ti)) For th = -50 To 50 cvv = (1 - Abs(th) / 50) * cv PSet (rX + th, _Height - 22), _RGB(cvv, cvv, cvv) Next th
If begin = 1 Then moveBalls Else Px = rX + (((frX - _Width / 2)) / (_Width / 2)) * 45: Py = _Height - 32 Vx = -((rX - Px) / INCIDE) If Vx * Vx > 1 Then Vx = Sgn(Vx) * (1 - Rnd * .1) Vy = -Sqr(1 - Vx * Vx) End If
Line (10, 20)-(_Width - 10, 20), _RGB(150, 150, 150) Line (10, 20)-(10, _Height - 40), _RGB(150, 150, 150) Line (_Width - 10, 20)-(_Width - 10, _Height - 40), _RGB(150, 150, 150)
Line (0, 0)-(_Width, 19), _RGB(75, 75, 75), BF Line (_Width - 9, 0)-(_Width, _Height - 41), _RGB(75, 75, 75), BF Line (0, 0)-(9, _Height - 41), _RGB(75, 75, 75), BF
Line (10, _Height - 40)-(0, _Height - 40), _RGB(150, 150, 150), B Line (_Width - 10, _Height - 40)-(_Width, _Height - 40), _RGB(150, 150, 150), B
For u = 0 To 7 Step .3 ccl = (255 - 33 * u) * .9 Circle (Px, Py), u, _RGB(ccl, ccl, ccl) Next u Circle (Px, Py), u - 4, _RGB(128, 128, 128)
Color _RGB(255, 255, 255), _RGB(25, 25, 25) If win = 1 And begin = 1 And tim < Timer Then _PrintString (_Width / 2 - 7 * 8, _Height / 2), "Congratulation" _PrintString (_Width / 2 - 8 * 8, _Height / 2 + 16), "click to restart" fps = 100000 If _MouseButton(1) And tim < Timer Then tim = Timer + .5: GoTo start End If If Life = 0 Then _PrintString (_Width / 2 - 4 * 8, _Height / 2), "Game Over" _PrintString (_Width / 2 - 8 * 8, _Height / 2 + 16), "click to restart" fps = 100000 If _MouseButton(1) And tim < Timer Then tim = Timer + .5: GoTo start End If If begin = 0 And Life = 3 Then _PrintString (_Width / 2 - 7 * 8, _Height / 2 + 16), "click to start" If _MouseButton(1) And tim < Timer Then begin = 1: tim = Timer + .5 Color _RGB(255, 255, 255), _RGB(75, 75, 75) _PrintString (_Width / 2 - 4 * 8, 0), "Life: " For I = 1 To (Life) _PrintString (_Width / 2 - (-I) * 8 + I * 5, 0), "@ " Next I _Display frames = frames + 1 If oldtime < Timer(.00001) Then fps = frames frames = 1 oldtime = Timer(.00001) + 1 End If Loop Until _KeyDown(27) _MouseShow System 0 Sub moveBalls () Shared fps, Life, begin, speed If Px < 15 Then Px = 15 Vx = -Vx If Vx * Vx > 1 Then Vx = Sgn(Vx) * (1 - Rnd * .1) Vy = Sqr(1 - Vx * Vx) * Sgn(Vy) End If If Px > _Width - 15 Then Px = _Width - 15 Vx = -Vx If Vx * Vx > 1 Then Vx = Sgn(Vx) * (1 - Rnd * .1) Vy = Sqr(1 - Vx * Vx) * Sgn(Vy) End If If Py < 25 Then Py = 25 Vy = -Vy If Vy * Vy > 1 Then Vy = Sgn(Vy) * (1 - Rnd * .1) Vx = Sqr(1 - Vy * Vy) * Sgn(Vx) End If If Py > _Height - 25 Then If Abs(rX - Px) < 55 Then Vx = -((rX - Px) / INCIDE) If Vx * Vx > 1 Then Vx = Sgn(Vx) * (1 - Rnd * .1) Vy = Sqr(1 - Vx * Vx) * Sgn(-Vy) Py = _Height - 25 End If End If If Py > _Height - 15 Then If Py > _Height Then Life = Life - 1 begin = 0 speed = 0 End If End If speed = speed + .0025 Px = Px + Vx * (1 / fps) * (640 + speed) Py = Py + Vy * (1 / fps) * (640 + speed) End Sub
|
|
|
Post by bplus on Feb 15, 2024 12:27:12 GMT
Nice version of Break Out, that ball moves fast! I like how you move the bricks away from walls and ceiling so you can get up above and wreck hell with great brick bouncing action! I got bunches of versions of this game, here is one: _Title "Breakout simplify 2021-08" 'B+ redo trans '_Title "Breakout trans from SdlBasic" 'B+ tranlate 2019-03-25 'Breakout.sdlbas (B+=MGA) 2016-12-24 'adapted from just posted JB version add 3d modifications Randomize Timer
Const xmax = 700 '<==== drawing area width Const ymax = 560 '<==== drawing area height Screen _NewImage(xmax, ymax, 32)
' Recommend: If you go FULLSCREEN then MOUSEHIDE _FullScreen '_MouseHide ' You might want to keep mouse visible to see when it goes off screen in height
' wall is 50 pixels X 14 columns wide = 700 make screen width ' wall is 20 pixels X 8 rows = 160 = 1/3 screen height = 480 + 20 paddle height ' under paddle track score and lifes on one line padded by blank lines 540 = 27 ' so total height 480 to paddle 500 + 60 for 3 lines = 560 (text height 20)
Const br = 10 ' ball radius Const bkw = 50 ' brick width Const bkh = 20 ' brick height
'colors used Const red = &HFFFF0000 Const orange = &HFFFF6400 Const green = &HFF008000 Const yellow = &HFFFFFF00 Const silver = &HFFD0C6C6 Const white = &HFFFFFFFF Const black = &HFF000000
Dim Shared bx, by, dx, dy, px, py, pw, plf, prt, score, life, hits, obk, rbk, speedups bx = 0 ' ball x position by = 0 ' ball y position dx = 0 ' ball horizontal change dy = 0 ' ball vertical change restart: px = 350 ' paddle x py = 480 pw = 50 ' paddle width, 100 wide to start half that at certain point plf = 0 ' paddle left side prt = 0 ' paddle right side
score = 0 life = 5 ' (or balls left) only 3 allowed according to wiki hits = 0 'bricks busted obk = 0 ' first orange brick hits bool rbk = 0 ' first red brick hit bool, when this happens paddle width is cut in half! speedups = 0 ' count, bump up dy when hits = 4 and 8, then with first orange, then with first red scrn = 0
Dim Shared wc(13, 7), wp(13, 7) 'brick wall colors, brick wall points according to color ' get 448 points clear 1 screen/wall, perfect game is clearing 2 screens/walls
initwall 'load arrays with data initball 'set dx, dy, bx, by ball position and change drawtable updatescore While life And _KeyDown(27) = 0
drawtable drawpaddle drawball updatescore If hits = 112 And scrn = 0 Then 'setup new _Delay 1 scrn = 1 speedups = 0: obk = 0: rbk = 0: pw = 50 initwall drawtable initball Else If hits = 224 Then Color white Text 65, 200, 32, orange, "Congratulations on a perfect score!!!" Exit While End If End If _Display _Limit 40 '< adjust as needed for speed of your system Wend If _KeyDown(27) Then System Color white Text 260, 290, 48, orange, "Game Over" _Display Sleep 5 GoTo restart
Sub initwall Dim cr As _Unsigned Long For r = 0 To 7 Select Case r Case 0, 1: cr = red: p = 7 Case 2, 3: cr = orange: p = 5 Case 4, 5: cr = green: p = 3 Case 6, 7: cr = yellow: p = 1 End Select For c = 0 To 13 wc(c, r) = cr: wp(c, r) = p Next Next End Sub
Sub initball 'set ball in play with location and dx, dy bx = 350 by = 280 dx = rand(1, 4) If rand(0, 1) Then dx = -1 * dx dy = (3 + speedups) * -1 End Sub
Sub drawtable ' in JB don't want to redraw this every loop Cls For r = 0 To 7 For c = 0 To 13 If wp(c, r) Then For i = 1 To 10 'underneath Color _RGB32(120, 60, 60) Line (c * bkw + i, r * bkh + bkh + i)-(c * bkw + bkw + i, r * bkh + bkh + i) Color silver PSet (c * bkw + i, r * bkh + bkh + i) 'ink(white) 'sidewall Line (c * bkw + bkw + i, r * bkh + i)-(c * bkw + bkw + i, r * bkh + bkh + i) Next Color wc(c, r) Line (c * bkw, r * bkh)-(c * bkw + bkw, r * bkh + bkh), , BF Color white Line (c * bkw, r * bkh)-(c * bkw + bkw, r * bkh + bkh), , B End If Next Next End Sub
Sub drawpaddle ' update paddle to mouseY, paddle top and bottom are global 'erase last paddle, it is aligned with Blue Computer Goal Line 'Color black 'Line (px - pw, py)-(px + pw, py + ph), black, BF 'EllipseFill px, py + 10, pw, 20, black
While _MouseInput: Wend px = _MouseX 'update paddle location If _MouseY >= 300 And _MouseY < 480 Then py = _MouseY
'k$ = InKey$ 'If Len(k$) Then ' If Len(k$) = 2 And Asc(Right$(k$, 1)) = 75 Then px = px - 8 ' If Len(k$) = 2 And Asc(Right$(k$, 1)) = 77 Then px = px + 8 'End If
plf = px - pw prt = px + pw For i = 1 To 10 Color _RGB32(120, 60, 60) Line (px - pw + i, py + 10 + i)-(px + pw + i, py + 10 + i), _RGB32(120, 60, 60) Color silver 'PSet (c * bkw + i, r * bkh + bkh + i) 'ink(white) Line (px + pw + i, py + i)-(px + pw + i, py + 10 + i), silver Next
Line (px - pw, py)-(px + pw, py + 10), &HFFAA5533, BF 'For i = 20 To 1 Step -1 ' cc = 255 - i * 10 ' EllipseFill px, py + 10, pw - (20 - i), i, _RGB32(cc, .5 * cc, .25 * cc) 'Next End Sub
Sub drawball 'erase last ball, blend into table color CircleFill bx, by, br, black
'update bx = bx + dx If bx < br Then dx = dx * -1: bx = br + 1 If bx > xmax - br Then dx = dx * -1: bx = xmax - br - 1
by = by + dy If by + br > py Then 'ball past paddle line by = py - br 'don't let ball go into paddle or goal If bx + br < plf Or bx - br > prt Then 'paddle miss life = life - 1 ' if life = 0 then end game updatescore silverball bx, by _Delay 2.5 'reflect on position of ball and loss of life CircleFill bx, by, br, black initball 'get ball rolling again Else 'paddle hit ' redo according to distance from paddle center dy = dy * -1 If bx < px Then per = .5 * (px - bx) / pw dx = dx - 6 * per ElseIf bx > px Then per = .5 * (bx - px) / pw dx = dx + 6 * per 'Else dx remains same End If 'dx = dx + rand(-2, 2) If dx > 7 Then: dx = 7: If dx < -7 Then dx = -7 End If Else If by - br < 0 Then 'ball hits back border, reverse direction by = br: dy = dy * -1 Else If by - br < 160 Then 'in wall area, what row and column? starthits = hits 'maybe should check all 4 corners or smaller ball row = Int((by - br) / bkh): col = Int((bx - br) / bkw) handleBall row, col row = Int((by - br) / bkh): col = Int((bx + br) / bkw) handleBall row, col row = Int((by + br) / bkh): col = Int((bx - br) / bkw) handleBall row, col row = Int((by + br) / bkh): col = Int((bx + br) / bkw) handleBall row, col If hits <> starthits Then: dy = dy * -1: 'reverse ball direction End If End If End If silverball bx, by End Sub
Sub handleBall (row, col) If 0 <= row And row <= 7 And 0 <= col And col <= 13 Then If wp(col, row) Then 'brick just hit, lot's to do before update ball hits = hits + 1 If hits = 4 Or hits = 8 Or hits = 116 Or hits = 120 Then speedups = speedups + 1 If dy < 0 Then dy = dy - .25 Else dy = dy + .25 End If value = wp(col, row) If value = 5 Then 'first orange brick If obk = 0 Then 'flag first orange speed increase obk = 1 speedups = speedups + 1 If dy < 0 Then: dy = dy - .25 Else dy = dy + .25 End If End If If value = 7 Then 'flag first red, speed increase paddle decrease! If rbk = 0 Then rbk = 1 speedups = speedups + 1 If dy < 0 Then dy = dy - .25 Else: dy = dy + .25 pw = .75 * pw End If End If score = score + wp(col, row) 'update score with point value wp(col, row) = 0 'no points here now 'black out box Line (col * bkw, row * bkh)-(col * bkw + bkw, row * bkh + bkh), black, BF End If End If End Sub
Sub updatescore Line (0, 500)-(xmax, ymax), black, BF dxs$ = Right$(" " + Str$(Int(dx)), 3) dys$ = Right$(" " + Str$(Int(dy)), 3) scores$ = Right$(" " + Str$(score), 3) ms$ = " Ball dx,dy:" + dxs$ + "," + dys$ + " Lifes:" + Str$(life) + " Score:" + scores$ Text 0, 520, 32, silver, Space$(60) Text 0, 520, 32, silver, ms$ End Sub
Sub silverball (x, y) For i = 10 To 1 Step -1 cc = 255 - i * 20 CircleFill x, y, i, _RGB32(cc, cc, cc) Next End Sub
Function rand% (lo%, hi%) rand% = Int(Rnd * (hi% - lo% + 1)) + lo% End Function
Sub CircleFill (CX As Integer, CY As Integer, R As Integer, C As _Unsigned Long) ' CX = center x coordinate ' CY = center y coordinate ' R = radius ' C = fill color Dim Radius As Integer, RadiusError As Integer Dim X As Integer, Y As Integer Radius = Abs(R) RadiusError = -Radius X = Radius Y = 0 If Radius = 0 Then PSet (CX, CY), C: Exit Sub Line (CX - X, CY)-(CX + X, CY), C, BF While X > Y RadiusError = RadiusError + Y * 2 + 1 If RadiusError >= 0 Then If X <> Y + 1 Then Line (CX - Y, CY - X)-(CX + Y, CY - X), C, BF Line (CX - Y, CY + X)-(CX + Y, CY + X), C, BF End If X = X - 1 RadiusError = RadiusError - X * 2 End If Y = Y + 1 Line (CX - X, CY - Y)-(CX + X, CY - Y), C, BF Line (CX - X, CY + Y)-(CX + X, CY + Y), C, BF Wend End Sub
Sub Text (x, y, textHeight, K As _Unsigned Long, txt$) fg = _DefaultColor cur& = _Dest I& = _NewImage(8 * Len(txt$), 16, 32) _Dest I& Color K, _RGBA32(0, 0, 0, 0) _PrintString (0, 0), txt$ mult = textHeight / 16 xlen = Len(txt$) * 8 * mult _PutImage (x, y)-Step(xlen, textHeight), I&, cur& Color fg _FreeImage I& End Sub
That ball speeds up considerably as game progresses. I did a Halloween version with cruchinging sounds and spider crawling out of each broken brick. They crawl around until run over by the ball then splat sound and little bloody explosion
|
|
ubi44
New Member
Posts: 32
|
Post by ubi44 on Feb 15, 2024 14:04:11 GMT
Cute! I have to admit that my code is a bit messy. Using putimage is better than the loop line I use to draw the bricks.
Could you share your Halloween version! (maybe a few attached files)
|
|
|
Post by bplus on Feb 15, 2024 14:14:58 GMT
I can try but this forum has severe limit on attachments 1 MB fine for code, not so great for tons of assets like sound and image files.
|
|
|
Post by bplus on Feb 15, 2024 15:25:26 GMT
Lets see if 1.49 MB zip can ve attached? Nope! One sound is sucking up allot of MB. I will try without. Attachments:
|
|
|
Post by bplus on Feb 15, 2024 15:32:03 GMT
OK just one sound file removed, should fit now:
|
|
ubi44
New Member
Posts: 32
|
Post by ubi44 on Feb 15, 2024 17:32:15 GMT
Fun and creepy! The sound adds a lot to the gameplay. I'll try to build on it in my next update... Well done!
|
|
ubi44
New Member
Posts: 32
|
Post by ubi44 on Feb 24, 2024 22:24:39 GMT
A version with bonuses: multi ball, shot, and wide racket!
The final score is calculated based on the average time to destroy a brick and the number of lives remaining.
Must be compiled with QB64PE 3.1x because of _MouseMove issue.
(Next update adding sounds! I don't know where to find the right sounds...)
Screen _NewImage(800, 600, 32) _AllowFullScreen _SquarePixels , _Smooth Randomize Timer _MouseHide '_FullScreen _SquarePixels , _Smooth '_Font _LoadFont("./SuperMario256.ttf", 15) LargeurBrick = _Width / 20 HauteurBrick = LargeurBrick / 2 '''brick white Brick1& = _NewImage(LargeurBrick, HauteurBrick, 32) _Dest Brick1& For i = 0 To HauteurBrick / 2 Step 1.5 cl = (1 - (i / HauteurBrick)) * 255 Line (i, i)-(LargeurBrick - i, HauteurBrick - i), _RGB(cl, cl, cl), B Next i 'brick grey Brick2& = _NewImage(LargeurBrick, HauteurBrick, 32) _Dest Brick2& For i = 0 To HauteurBrick / 2 Step 1.5 cl = (1 - (i / HauteurBrick)) * 128 Line (i, i)-(LargeurBrick - i, HauteurBrick - i), _RGB(cl, cl, cl), B Next i '''tir DiametreBall = Int(_Width(0) / 80) tir& = _NewImage(DiametreBall, DiametreBall, 32) _Dest tir& For u = 0 To DiametreBall Step .3 ccl = (255 - (255 / DiametreBall) * u * .9) Line (DiametreBall * .5 - 1, u)-(DiametreBall * .5 + 1, u), _RGB(ccl, ccl, ccl) Next u '''ball DiametreBall = Int(_Width(0) / 57) Ball& = _NewImage(DiametreBall, DiametreBall, 32) _Dest Ball& For u = 0 To DiametreBall Step .3 ccl = (255 - (255 / DiametreBall) * u * .9) Circle (DiametreBall * .5, DiametreBall * .5), u * .5, _RGB(ccl, ccl, ccl) Next u 'bonus+2balls Diametrebb = Int(_Width(0) / 114) Bonus1& = _NewImage(Diametrebb * 3, Diametrebb * 2, 32) _Dest Bonus1& For u = 0 To Diametrebb Step .3 ccl = (255 - (255 / Diametrebb) * u * .9) Circle (Diametrebb * .5, Diametrebb * 1.5), u * .5, _RGB(ccl, ccl, ccl) Circle (Diametrebb * 3 - Diametrebb * .5, Diametrebb * 1.5), u * .5, _RGB(ccl, ccl, ccl) Circle (Diametrebb * 2 - Diametrebb * .5, Diametrebb * .5), u * .5, _RGB(ccl, ccl, ccl) Next u 'bonus larger LB = LargeurBrick Bonus2& = _NewImage(LB, LB, 32) _Dest Bonus2& For y = 1 To 10 c = 200 - y * 20 Line (_Width / 2 - (LB) + y * 5, _Height - 25 + y)-(_Width / 2 + (LB) - y * 5, _Height - 25 + y), _RGB(c, c, c) Next y 'bonus gun LB = LB * .8 Bonus3& = _NewImage(LB, LB / 2, 32) _Dest Bonus3& For y = 1 To 10 c = 200 - (y) * 20 Line (_Width / 2 - (LB) + y * 5, _Height - 10 + (y))-(_Width / 2 + (LB) - y * 5, _Height - 10 + (y)), _RGB(c, c, c) Next y For y = 0 To _Height - 10 c = 50 + (y / _Height) * 255 Line (5, y)-(7, y), _RGB(c, c, c), BF Line (_Width - 5, y)-(_Width - 7, y), _RGB(c, c, c), BF Next y ''plateau plateau& = _NewImage(800, 600, 32) _Dest plateau& Line (10, 20)-(_Width - 10, 20), _RGB(150, 150, 150) Line (10, 20)-(10, _Height - 40), _RGB(150, 150, 150) Line (_Width - 10, 20)-(_Width - 10, _Height - 40), _RGB(150, 150, 150)
Line (0, 0)-(_Width, 19), _RGB(75, 75, 75), BF Line (_Width - 9, 0)-(_Width, _Height - 41), _RGB(75, 75, 75), BF Line (0, 0)-(9, _Height - 41), _RGB(75, 75, 75), BF
Line (10, _Height - 40)-(0, _Height - 40), _RGB(150, 150, 150), B Line (_Width - 10, _Height - 40)-(_Width, _Height - 40), _RGB(150, 150, 150), B plateau& = _CopyImage(plateau&, 33) W& = _Width: H& = _Height Type ball PX As Single PY As Single VX As Single VY As Single active As _Unsigned _Byte End Type Type tir x As Single y As Single a As _Unsigned _Byte 'integer End Type start: begin = 0 TOTALBall = 1 ReDim ttir(0) As tir ReDim b(TOTALBall) As ball, Speed(TOTALBall) _Dest 0 _DisplayOrder _Software , _Hardware b(TOTALBall).PX = _Width / 2 b(TOTALBall).PY = _Height - 25 - DiametreBall b(TOTALBall).active = 1 Vx = Rnd - Rnd Vy = Sqr(1 - Vx * Vx) * -1 b(TOTALBall).VX = Vx b(TOTALBall).VY = Vy ReDim Shared rX ' ReDim Shared INCIDE INCIDE = 65 rX = _Width / 2 Life = 3 NBbrickL = 9 + Int(Rnd * 7) NBbrickH = 2 + Int(Rnd * 5) Type brick active As Single bonus As Integer End Type Type bon x As Single y As Single active As _Unsigned _Byte genre As _Unsigned Integer End Type ReDim br(NBbrickL, NBbrickH) As brick ReDim bb(NBbrickL * NBbrickH) As bon startX = _Width / 2 - ((NBbrickL) * .5) * LargeurBrick startY = HauteurBrick * 5 ptt = 0 pol = 0 For i = 1 To NBbrickL For j = 1 To NBbrickH br(i, j).active = 1 + Int(Rnd * 2) If br(i, j).active = 1 Then ptt = ptt + 30: pol = pol + 1 If br(i, j).active = 2 Then ptt = ptt + 60: pol = pol + 2
If Rnd < .2 Then bb(i * j).active = 1: bb(i * j).genre = Int(Rnd * 4) Next j, i ReDim ttir(0) As tir SCORE = 0 MAXpoints = (ptt) points = 10 pLL = 1 Do startYu = startY Cls , _RGB(25, 25, 25) For i = 50 To 0 Step -1 mi = (1 - i / 50) * 25 Line (0, _Height - i)-(_Width, _Height - i), _RGB(25 - mi, 25 - mi, 25 - mi) Next i Line (0, 0)-(_Width, 20), _RGB(75, 75, 75), BF _MapTriangle (0, 0)-(0, H&)-(W&, H&), plateau& To(0, 20)-(0, _Height)-(_Width, _Height) _MapTriangle (0, 0)-(W&, 0)-(W&, H&), plateau& To(0, 20)-(_Width, 20)-(_Width, _Height) Color _RGB(255, 255, 255), _RGB(75, 75, 75) tscore = Int(((SCORE / MAXpoints) * 15000)) If tscore > 1000 Then fs = Int(tscore / 1000): ds = Int(tscore - fs * 1000) If ds < 10 Then fr$ = "00" Else If ds < 100 Then fr$ = "0" Else If ds >= 100 Then fr$ = "" truscore$ = (Str$(fs)) + " " + LTrim$(fr$) + LTrim$(Str$(ds)) Else truscore$ = Str$(tscore) End If _PrintString (35, 5), "SCORE:" + truscore$ _PrintString (_Width / 2 - 6 * 8, 5), "Life : " For i = 0 To (Life - 1) _PrintString (_Width / 2 - 5 - (-i - 1) * 10 + (1 + i) * 5, 5), "@ " Next i
If win = 0 And begin = 1 Then gluck = ((Timer - starttime) / pLL) / (100 * Life) minute = Int((Timer - starttime) / 60) second = Int(Timer - starttime) - (minute * 60) End If If second < 10 Then k$ = "0" Else k$ = "" _PrintString (_Width - 80, 5), Str$(minute) + ":" + k$ + LTrim$(Str$(second)) 'Int(Timer - starttime)) frames = frames + 1 If oldtime < Timer(.00001) Then fps = frames frames = 1 oldtime = Timer(.00001) + 1 End If win = 1 For i = 1 To NBbrickL For j = 1 To NBbrickH For q = 1 To TOTALBall xmin = startX + (i - 1) * LargeurBrick - DiametreBall: xmax = xmin + LargeurBrick + DiametreBall ymin = startYu + (j - 1) * HauteurBrick - DiametreBall: ymax = ymin + HauteurBrick + DiametreBall px = b(q).PX + DiametreBall * .5: py = b(q).PY + DiametreBall * .5 If px >= xmin And px <= xmax And py >= ymin And py <= ymax And br(i, j).active >= 1 Then Left = -px + (xmin): Right = -(xmax) + px: Top = -py + (ymin): Bot = -(ymax) + py If Left >= Right And Left >= Top And Left >= Bot Then b(q).PX = xmin - DiametreBall * .5 b(q).VX = -Abs(b(q).VX) If b(q).VX * b(q).VX > 1 Then b(q).VX = Sgn(b(q).VX) b(q).VY = Sqr(1 - b(q).VX * b(q).VX) * Sgn(b(q).VY) End If If Right >= Left And Right >= Top And Right >= Bot Then b(q).PX = xmax + DiametreBall * .5 b(q).VX = Abs(b(q).VX) If b(q).VX * b(q).VX > 1 Then b(q).VX = Sgn(b(q).VX) b(q).VY = Sqr(1 - b(q).VX * b(q).VX) * Sgn(b(q).VY) End If If Top >= Bot And Top >= Left And Top >= Right Then b(q).PY = ymin - DiametreBall * .5 b(q).VY = -Abs(b(q).VY) If b(q).VY * b(q).VY > 1 Then b(q).VY = Sgn(b(q).VY) b(q).VX = Sqr(1 - b(q).VY * b(q).VY) * Sgn(b(q).VX) End If If Bot >= Top And Bot >= Left And Bot >= Right Then b(q).PY = ymax + DiametreBall * .5 b(q).VY = Abs(b(q).VY) If b(q).VY * b(q).VY > 1 Then b(q).VY = Sgn(b(q).VY) b(q).VX = Sqr(1 - b(q).VY * b(q).VY) * Sgn(b(q).VX) End If br(i, j).active = br(i, j).active - 1 SCORE = SCORE + Life * points pLL = pLL + 1 End If Select Case br(i, j).active Case 2: _PutImage (startX + (i - 1) * LargeurBrick, startYu + (j - 1) * HauteurBrick), Brick1&, 0, (1, 1)-(LargeurBrick - 1, HauteurBrick - 1): win = 0 Case 1: _PutImage (startX + (i - 1) * LargeurBrick, startYu + (j - 1) * HauteurBrick), Brick2&, 0, (1, 1)-(LargeurBrick - 1, HauteurBrick - 1): win = 0 End Select If br(i, j).active <= 0 And br(i, j).active >= -1 Then dd = Abs(br(i, j).active) * HauteurBrick * .5 _PutImage (startX + (i - 1) * LargeurBrick + dd, startYu + (j - 1) * HauteurBrick + dd)-(startX + (i) * LargeurBrick - dd, startYu + (j) * HauteurBrick - dd), Brick2&, 0, (1, 1)-(LargeurBrick - 1, HauteurBrick - 1) br(i, j).active = br(i, j).active - 3 / fps
End If If br(i, j).active < -1 And br(i, j).active <> -2 Then If bb(i * j).active = 1 Then bb(i * j).active = 2 bb(i * j).x = startX + (i - 1) * LargeurBrick bb(i * j).y = startYu + (j - 1) * HauteurBrick + HauteurBrick br(i, j).active = -2 End If End If Next q Next j, i Do: Loop While _MouseInput For o = 1 To NBbrickL * NBbrickH If bb(o).active = 2 Then bb(o).y = bb(o).y + (1 / (1 + fps)) * 125 If bb(o).y > _Height - 5 Then bb(o).active = 0 Select Case bb(o).genre Case 1 _PutImage (bb(o).x + _Width(Bonus1&) * .5, bb(o).y), Bonus1& If bb(o).y > _Height - 25 - DiametreBall * .5 Then If Abs(rX - bb(o).x) < (55 + add) And win = 0 Then bb(o).active = 0 TOTALBall = TOTALBall + 2 ReDim _Preserve b(TOTALBall) As ball ReDim _Preserve Speed(TOTALBall) b(TOTALBall).PX = Rnd * _Width b(TOTALBall).PY = _Height - 30 b(TOTALBall).VX = Rnd - Rnd b(TOTALBall).VY = Sqr(1 - b(TOTALBall).VX * b(TOTALBall).VX) * -1 b(TOTALBall).active = 1 Speed(TOTALBall) = 0 b(TOTALBall - 1).PX = Rnd * _Width b(TOTALBall - 1).PY = _Height - 30 b(TOTALBall - 1).VX = Rnd - Rnd b(TOTALBall - 1).VY = Sqr(1 - b(TOTALBall - 1).VX * b(TOTALBall - 1).VX) * -1 b(TOTALBall - 1).active = 1 Speed(TOTALBall - 1) = 0 End If End If Case 2 _PutImage (bb(o).x, bb(o).y), Bonus2& If bb(o).y > _Height - 25 - DiametreBall * .5 Then If Abs(rX - bb(o).x) < (55 + add) And win = 0 Then groout = Timer + 5 bb(o).active = 0 End If End If Case 3 _PutImage (bb(o).x, bb(o).y), Bonus3& If bb(o).y > _Height - 25 - DiametreBall * .5 Then If Abs(rX - bb(o).x) < (55 + add) And win = 0 Then grooTut = Timer + 5 bb(o).active = 0 End If End If End Select End If Next o If grooTut > Timer Then gtir = 1 Else If gtir = 1 Then For u = 1 To totir If ttir(u).a = 1 Then ttir(u).y = ttir(u).y - (1 / fps) * 354 _PutImage (ttir(u).x - _Width(tir&) * .5, ttir(u).y), tir& If ttir(u).y < 1 Then ttir(u).a = 0 For i = 1 To NBbrickL For j = 1 To NBbrickH xmin = startX + (i - 1) * LargeurBrick - DiametreBall * .5: xmax = xmin + LargeurBrick + DiametreBall ymin = startYu + (j - 1) * HauteurBrick - DiametreBall * .5: ymax = ymin + HauteurBrick + DiametreBall px = ttir(u).x + DiametreBall * .5: py = ttir(u).y + DiametreBall * .5 If px >= xmin And px <= xmax And py >= ymin And py <= ymax And br(i, j).active >= 1 Then br(i, j).active = br(i, j).active - 1 SCORE = SCORE + Life * points pLL = pLL + 1 ttir(u).a = 0 End If Next j, i End If Next u jk = 0 For u = 1 To totir If ttir(u).a = 1 Then jk = 1 Next u If jk = 0 Then gtir = 0 totir = 0 ReDim ttir(0) As tir End If End If End If If gtir = 1 Then If cadence < Timer Then If _MouseButton(1) And begin = 1 And grooTut > Timer Then totir = totir + 2 ReDim _Preserve ttir(totir) As tir ttir(totir).x = rX - 28 ttir(totir - 1).x = rX + 28 ttir(totir).y = _Height - 30 ttir(totir - 1).y = _Height - 30 ttir(totir).a = 1 ttir(totir - 1).a = 1 cadence = Timer + .5 End If End If For u = 1 To totir If u <= UBound(ttir) Then If ttir(u).a = 1 Then ttir(u).y = ttir(u).y - (1 / fps) * 354 _PutImage (ttir(u).x - _Width(tir&) * .5, ttir(u).y), tir& For i = 1 To NBbrickL For j = 1 To NBbrickH xmin = startX + (i - 1) * LargeurBrick - DiametreBall * .5: xmax = xmin + LargeurBrick + DiametreBall ymin = startYu + (j - 1) * HauteurBrick - DiametreBall * .5: ymax = ymin + HauteurBrick + DiametreBall px = ttir(u).x + DiametreBall * .5: py = ttir(u).y + DiametreBall * .5 If px >= xmin And px <= xmax And py >= ymin And py <= ymax And br(i, j).active >= 1 Then br(i, j).active = br(i, j).active - 1 SCORE = SCORE + Life * points pLL = pLL + 1 ttir(u).a = 0 End If Next j, i End If End If Next u End If If groout > Timer Then add = add + (1 / fps) * 25 Else add = add - (1 / fps) * 25 End If If add < 0 Then add = 0 If add > 25 Then add = 25 For y = 1 To 10 c = 200 - y * 20 Line (rX - (50 + add) + y, _Height - 25 + y)-(rX + (50 + add) - y, _Height - 25 + y), _RGB(c, c, c)
Next y co = co - (5 / fps) If co < 0 Then co = 0 Else For y = 0 To co c = 200 - y * 20 Line (rX - 30, _Height - 25 - y)-(rX - 25, _Height - 25 - y), _RGB(c, c, c) Line (rX + 30, _Height - 25 - y)-(rX + 25, _Height - 25 - y), _RGB(c, c, c) Next y
End If ti = ti + (1 / fps) * 640 If ti > _Pi * 2 Then ti = 0 cv = 175 * Abs(Cos(ti)) For th = -50 To 50 cvv = (1 - Abs(th) / 50) * cv PSet (rX + th, _Height - 22), _RGB(cvv, cvv, cvv) Next th
If grooTut > Timer Then co = co + (10 / fps) If co > 10 Then co = 10
Color _RGB(255, 255, 255), _RGB(25, 25, 25) If win = 1 Then
_PrintString (_Width / 2 - 7 * 8, _Height / 2), "Congratulation" _PrintString (_Width / 2 - 8 * 8, _Height / 2 + 16), "click to restart" a = Int(((SCORE / MAXpoints) * 15000) / gluck) u = Len(LTrim$((Str$(a)))) If u <= 3 Then truscore$ = Str$(a) If u > 3 And u < 7 Then tscore = Int(a) fs = Int(tscore / 1000): ds = Int(tscore - fs * 1000) If ds < 10 Then fr$ = "00" Else If ds < 100 Then fr$ = "0" Else If ds >= 100 Then fr$ = "" truscore$ = (Str$(fs)) + " " + LTrim$(fr$) + LTrim$(Str$(ds))
End If If u >= 7 Then tscore = Int(a) fs = Int(tscore / 1000000): ds = Int(tscore - fs * 1000000)
gs = Int(ds / 1000): hs = Int(ds - gs * 1000)
If gs < 10 Then fg$ = "00" Else If gs < 100 Then fg$ = "0" Else If gs >= 100 Then fg$ = ""
If hs < 10 Then fr$ = "00" Else If hs < 100 Then fr$ = "0" Else If hs >= 100 Then fr$ = "" truscore$ = (Str$(fs)) + " " + LTrim$(fg$) + LTrim$(Str$(gs)) + " " + LTrim$(fr$) + LTrim$(Str$(hs))
End If bodo = Len("SCORE : " + truscore$) * .5 _PrintString (_Width / 2 - bodo * 8, _Height / 2 + 32), "SCORE : " + truscore$ If _MouseButton(1) And tim < Timer Then tim = Timer + 1: GoTo start End If If Life = 0 Then
_PrintString (_Width / 2 - 4 * 8, _Height / 2), "Game Over" _PrintString (_Width / 2 - 8 * 8, _Height / 2 + 16), "click to restart" a = Int(((SCORE / MAXpoints) * 15000) / gluck) u = Len(LTrim$((Str$(a)))) If u <= 3 Then truscore$ = Str$(a) If u > 3 And u < 7 Then tscore = Int(a) fs = Int(tscore / 1000): ds = Int(tscore - fs * 1000) If ds < 10 Then fr$ = "00" Else If ds < 100 Then fr$ = "0" Else If ds >= 100 Then fr$ = "" truscore$ = (Str$(fs)) + " " + LTrim$(fr$) + LTrim$(Str$(ds))
End If If u >= 7 Then tscore = Int(a) fs = Int(tscore / 1000000): ds = Int(tscore - fs * 1000000)
gs = Int(ds / 1000): hs = Int(ds - gs * 1000)
If gs < 10 Then fg$ = "00" Else If gs < 100 Then fg$ = "0" Else If gs >= 100 Then fg$ = ""
If hs < 10 Then fr$ = "00" Else If hs < 100 Then fr$ = "0" Else If hs >= 100 Then fr$ = "" truscore$ = (Str$(fs)) + " " + LTrim$(fg$) + LTrim$(Str$(gs)) + " " + LTrim$(fr$) + LTrim$(Str$(hs))
End If bodo = Len("SCORE : " + truscore$) * .5 _PrintString (_Width / 2 - bodo * 8, _Height / 2 + 32), "SCORE : " + truscore$ If _MouseButton(1) And tim < Timer Then tim = Timer + 1: GoTo start End If
If begin = 0 And Life = 3 Then _PrintString (_Width / 2 - 7 * 8, _Height / 2 + 16), "click to start": starttime = Timer
frx = _MouseX: fry = _MouseY If fry < 5 Then fry = 5 If fry > _Height - 5 Then fry = _Height - 5 If frx < 5 Then frx = 5 If frx > _Width - 5 Then frx = _Width - 5 If tim < Timer Then _MouseMove frx, fry If Life > 0 And begin = 1 Then If oldrx > frx Then rX = rX - (1 / fps) * 1800 Else rX = rX + (1 / fps) * 1800 oldrx = rX If _MouseButton(1) And tim < Timer And begin = 0 Then begin = 1: tim = Timer + .1: _MouseMove _Width / 2, _Height / 2 If Life < 3 Then starttime = starttime + (Timer - endtime) End If If begin = 1 Then For q = 1 To TOTALBall If b(q).active = 1 Then moveBalls q _PutImage (b(q).PX - DiametreBall * .5, b(q).PY - DiametreBall * .5), Ball& End If Next q Else rX = _Width / 2 b(1).PX = _Width / 2 + ((_MouseX - _Width / 2) / (_Width / 2)) * 50: b(1).PY = _Height - 25 - DiametreBall * .5 b(1).VX = -((rX - b(1).PX) / INCIDE) If b(1).VX * b(1).VX > 1 Then b(1).VX = Sgn(b(1).VX) b(1).VY = -Sqr(1 - b(1).VX * b(1).VX) _PutImage (b(1).PX - DiametreBall * .5, b(1).PY - DiametreBall * .5), Ball& End If bb = 0 For q = 1 To TOTALBall If b(q).active = 1 Then bb = 1 Next q If bb = 0 Then TOTALBall = 1 ReDim b(TOTALBall) As ball b(TOTALBall).active = 1 If win = 0 Then Life = Life - 1 begin = 0 endtime = Timer End If For o = 1 To NBbrickL * NBbrickH If bb(o).active = 2 Then bb(o).active = 0 Next o grooTut = Timer - 1 tim = Timer + 1 End If
_Display Loop Until _KeyDown(27) System 0 Sub moveBalls (i) Shared fps, Life, begin, speed, DiametreBall, HauteurBrick, add Shared b() As ball, Speed() If b(i).PX < 15 - DiametreBall * .5 Then b(i).PX = 15 - DiametreBall * .5 b(i).VX = -b(i).VX b(i).VY = Sqr(1 - b(i).VX * b(i).VX) * Sgn(b(i).VY) End If If b(i).PX > _Width - 15 + DiametreBall * .5 Then b(i).PX = _Width - 15 + DiametreBall * .5 b(i).VX = -b(i).VX b(i).VY = Sqr(1 - b(i).VX * b(i).VX) * Sgn(b(i).VY) End If If b(i).PY < 20 + DiametreBall * .5 Then b(i).PY = 20 + DiametreBall * .5 b(i).VY = -b(i).VY b(i).VX = Sqr(1 - b(i).VY * b(i).VY) * Sgn(b(i).VX) End If If b(i).PY > _Height - 25 - DiametreBall * .5 Then If Abs(rX - b(i).PX) < (add + 55) Then b(i).VX = -((rX - b(i).PX) / INCIDE) If b(i).VX * b(i).VX > 1 Then b(i).VX = Sgn(b(i).VX) * .95 b(i).VY = Sqr(1 - b(i).VX * b(i).VX) * Sgn(-b(i).VY) b(i).PY = _Height - 25 - DiametreBall * .5 End If End If If b(i).PY > _Height - 15 Then If b(i).PY > _Height Then b(i).active = 0 Speed(i) = 0 Exit Sub End If End If Speed(i) = Speed(i) + (1 / fps) * 5 gro = (1 / (1 + fps)) * (344 + Speed(i)) If gro > HauteurBrick * .5 Then gro = HauteurBrick * .5 b(i).PX = b(i).PX + b(i).VX * gro b(i).PY = b(i).PY + b(i).VY * gro End Sub
|
|
Aaditya Parashar
Junior Member
Just somebody with an abnormal coding routine.
Posts: 95
|
Post by Aaditya Parashar on Feb 25, 2024 2:02:41 GMT
ubi44, You are going to complete this game bro, it's getting better. Btw, I haven't faced any mousemove issues yet...
|
|
ubi44
New Member
Posts: 32
|
Post by ubi44 on Feb 25, 2024 8:56:19 GMT
Ok thank you! The problem with _mousemove only happens in full screen !
|
|
ubi44
New Member
Posts: 32
|
Post by ubi44 on Feb 25, 2024 10:03:23 GMT
BreakoutSound.zip (442.09 KB) Final version with original arkanoid 8-bit sound old_film effect and Higher rate of fire!
|
|
|
Post by bplus on Feb 25, 2024 16:20:08 GMT
Yes coming along really nicely! Not sure why you need _MouseMove why not just set the ball(x, y) directly in code?
|
|
ubi44
New Member
Posts: 32
|
Post by ubi44 on Feb 25, 2024 16:57:04 GMT
At the start of each shot, the racquet is in the center and you can aim by moving the ball from one end of the racquet to the other, using the full width.
I use _mousemove especially on the first shot to keep the racquet in the center... but also to keep the mouse in the screen space! That said, I can do without it in full screen but in window mode it's necessary to stay in the screen!
here is code _without _mousemove to center the racquet on first shot !
Screen _NewImage(800, 600, 32) _AllowFullScreen _SquarePixels , _Smooth Randomize Timer _MouseHide '$Embed:'source\brick1.wav','brickF' '$Embed:'source\brick2.wav','brickS' '$Embed:'source\larger.wav','Larger' '$Embed:'source\loose.wav','Loose' '$Embed:'source\raquet.wav','raqueT' '$Embed:'source\start.wav','startT' '$Embed:'source\tir.wav','tirS' Randomize Timer Dim scratch1(100) As Long Dim scratch2(100) As Long For u = 0 To 100 dor = 10 + Rnd * 80 scratch1(u) = _NewImage(dor, dor, 32) _Dest scratch1(u) ax = Rnd * _Width: ay = Rnd * _Height PSet (ax, ay), _RGB(25, 25, 25) cor = Rnd * _Width * .1 coli = Rnd * 25 + 25 For i = 125 To 100 Step -1 ax = ax + Sin(Rnd - Rnd) * cor ay = ay + Cos(Rnd - Rnd) * cor Line -(ax, ay), _RGB(coli, coli, coli) Next i dor = 10 + Rnd * 80 scratch2(u) = _NewImage(dor, dor, 32) _Dest scratch2(u) ax = Rnd * _Width: ay = Rnd * _Height PSet (ax, ay), _RGB(25, 25, 25) cor = Rnd * _Width * .1 coli = Rnd * 25 + 25 For i = 125 To 100 Step -1 ax = ax + (Rnd - Rnd) * cor ay = ay + (Rnd - Rnd) * cor PSet (ax, ay), _RGB(coli, coli, coli) Next i Next u _Dest 0
'_FullScreen _SquarePixels , _Smooth '_Font _LoadFont("./SuperMario256.ttf", 15) LargeurBrick = _Width / 20 HauteurBrick = LargeurBrick / 2 '''brick white Brick1& = _NewImage(LargeurBrick, HauteurBrick, 32) _Dest Brick1& For i = 0 To HauteurBrick / 2 Step 1.5 cl = (1 - (i / HauteurBrick)) * 255 Line (i, i)-(LargeurBrick - i, HauteurBrick - i), _RGB(cl, cl, cl), B Next i 'brick grey Brick2& = _NewImage(LargeurBrick, HauteurBrick, 32) _Dest Brick2& For i = 0 To HauteurBrick / 2 Step 1.5 cl = (1 - (i / HauteurBrick)) * 128 Line (i, i)-(LargeurBrick - i, HauteurBrick - i), _RGB(cl, cl, cl), B Next i '''tir DiametreBall = Int(_Width(0) / 80) tir& = _NewImage(DiametreBall, DiametreBall, 32) _Dest tir& For u = 0 To DiametreBall Step .3 ccl = (255 - (255 / DiametreBall) * u * .9) Line (DiametreBall * .5 - 1, u)-(DiametreBall * .5 + 1, u), _RGB(ccl, ccl, ccl) Next u '''ball DiametreBall = Int(_Width(0) / 57) Ball& = _NewImage(DiametreBall, DiametreBall, 32) _Dest Ball& For u = 0 To DiametreBall Step .3 ccl = (255 - (255 / DiametreBall) * u * .9) Circle (DiametreBall * .5, DiametreBall * .5), u * .5, _RGB(ccl, ccl, ccl) Next u 'bonus+2balls Diametrebb = Int(_Width(0) / 114) Bonus1& = _NewImage(Diametrebb * 3, Diametrebb * 2, 32) _Dest Bonus1& For u = 0 To Diametrebb Step .3 ccl = (255 - (255 / Diametrebb) * u * .9) Circle (Diametrebb * .5, Diametrebb * 1.5), u * .5, _RGB(ccl, ccl, ccl) Circle (Diametrebb * 3 - Diametrebb * .5, Diametrebb * 1.5), u * .5, _RGB(ccl, ccl, ccl) Circle (Diametrebb * 2 - Diametrebb * .5, Diametrebb * .5), u * .5, _RGB(ccl, ccl, ccl) Next u 'bonus larger LB = LargeurBrick Bonus2& = _NewImage(LB, LB, 32) _Dest Bonus2& For y = 1 To 10 c = 200 - y * 20 Line (_Width / 2 - (LB) + y * 5, _Height - 25 + y)-(_Width / 2 + (LB) - y * 5, _Height - 25 + y), _RGB(c, c, c) Next y 'bonus gun LB = LB * .8 Bonus3& = _NewImage(LB, LB / 2, 32) _Dest Bonus3& For y = 1 To 10 c = 200 - (y) * 20 Line (_Width / 2 - (LB) + y * 5, _Height - 10 + (y))-(_Width / 2 + (LB) - y * 5, _Height - 10 + (y)), _RGB(c, c, c) Next y For y = 0 To _Height - 10 c = 50 + (y / _Height) * 255 Line (5, y)-(7, y), _RGB(c, c, c), BF Line (_Width - 5, y)-(_Width - 7, y), _RGB(c, c, c), BF Next y ''plateau plateau& = _NewImage(800, 600, 32) _Dest plateau& Line (10, 20)-(_Width - 10, 20), _RGB(150, 150, 150) Line (10, 20)-(10, _Height - 40), _RGB(150, 150, 150) Line (_Width - 10, 20)-(_Width - 10, _Height - 40), _RGB(150, 150, 150)
Line (0, 0)-(_Width, 19), _RGB(75, 75, 75), BF Line (_Width - 9, 0)-(_Width, _Height - 41), _RGB(75, 75, 75), BF Line (0, 0)-(9, _Height - 41), _RGB(75, 75, 75), BF
Line (10, _Height - 40)-(0, _Height - 40), _RGB(150, 150, 150), B Line (_Width - 10, _Height - 40)-(_Width, _Height - 40), _RGB(150, 150, 150), B plateau& = _CopyImage(plateau&, 33) W& = _Width: H& = _Height Type ball PX As Single PY As Single VX As Single VY As Single active As _Unsigned _Byte End Type Type tir x As Single y As Single a As _Unsigned _Byte 'integer End Type start: begin = 0 TOTALBall = 1 ReDim ttir(0) As tir ReDim b(TOTALBall) As ball, Speed(TOTALBall) _Dest 0 _DisplayOrder _Software , _Hardware b(TOTALBall).PX = _Width / 2 b(TOTALBall).PY = _Height - 25 - DiametreBall b(TOTALBall).active = 1 Vx = Rnd - Rnd Vy = Sqr(1 - Vx * Vx) * -1 b(TOTALBall).VX = Vx b(TOTALBall).VY = Vy ReDim Shared rX ' ReDim Shared INCIDE INCIDE = 65 rX = _Width / 2 Life = 3 NBbrickL = 9 + Int(Rnd * 7) NBbrickH = 2 + Int(Rnd * 5) Type brick active As Single bonus As Integer End Type Type bon x As Single y As Single active As _Unsigned _Byte genre As _Unsigned Integer End Type ReDim br(NBbrickL, NBbrickH) As brick ReDim bb(NBbrickL * NBbrickH) As bon startX = _Width / 2 - ((NBbrickL) * .5) * LargeurBrick startY = HauteurBrick * 5 ptt = 0 pol = 0 For i = 1 To NBbrickL For j = 1 To NBbrickH br(i, j).active = 1 + Int(Rnd * 2) If br(i, j).active = 1 Then ptt = ptt + 30: pol = pol + 1 If br(i, j).active = 2 Then ptt = ptt + 60: pol = pol + 2
If Rnd < .2 Then bb(i * j).active = 1: bb(i * j).genre = Int(Rnd * 4) Next j, i ReDim ttir(0) As tir SCORE = 0 MAXpoints = (ptt) points = 10 pLL = 1
Dim Shared As Long brickF, brickS, Larger, Loose, raqueT, starT, tirS brickF = _SndOpen("brick2.wav") brickS = _SndOpen("brick1.wav") Larger = _SndOpen("larger.wav") Loose = _SndOpen("loose.wav") raqueT = _SndOpen("raquet.wav") starT = _SndOpen("start.wav") tirS = _SndOpen("tir.wav") 'brickF = _SndOpen(_Embedded$("brickS"), "memory") 'brickS = _SndOpen(_Embedded$("brickF"), "memory") 'Larger = _SndOpen(_Embedded$("Larger"), "memory") 'Loose = _SndOpen(_Embedded$("Loose"), "memory") 'raqueT = _SndOpen(_Embedded$("raqueT"), "memory") 'starT = _SndOpen(_Embedded$("startT"), "memory") 'tirS = _SndOpen(_Embedded$("tirS"), "memory")
_SndPlay starT Do startYu = startY cub = 25 + (Rnd - Rnd) * 4 Cls , _RGB(cub, cub, cub) For i = 50 To 0 Step -1 mi = (1 - i / 50) * cub Line (0, _Height - i)-(_Width, _Height - i), _RGB(cub - mi, cub - mi, cub - mi) Next i Line (0, 0)-(_Width, 20), _RGB(75, 75, 75), BF _MapTriangle (0, 0)-(0, H&)-(W&, H&), plateau& To(0, 20)-(0, _Height)-(_Width, _Height) _MapTriangle (0, 0)-(W&, 0)-(W&, H&), plateau& To(0, 20)-(_Width, 20)-(_Width, _Height) If rnt1 < Timer Then RndU1 = Rnd * .25 + .75: rnt1 = Timer + Rnd RndU1 = RndU1 + 1 / fps Color _RGB(255 * RndU1, 255 * RndU1, 255 * RndU1), _RGB(75, 75, 75)
tscore = Int(((SCORE / MAXpoints) * 15000)) If tscore > 1000 Then fs = Int(tscore / 1000): ds = Int(tscore - fs * 1000) If ds < 10 Then fr$ = "00" Else If ds < 100 Then fr$ = "0" Else If ds >= 100 Then fr$ = "" truscore$ = (Str$(fs)) + " " + LTrim$(fr$) + LTrim$(Str$(ds)) Else truscore$ = Str$(tscore) End If _PrintString (35, 5), "SCORE:" + truscore$
If rnt2 < Timer Then RndU2 = Rnd * .25 + .75: rnt2 = Timer + Rnd RndU2 = RndU2 + 1 / fps Color _RGB(255 * RndU2, 255 * RndU2, 255 * RndU2), _RGB(75, 75, 75)
_PrintString (_Width / 2 - 6 * 8, 5), "Life : " For i = 0 To (Life - 1) _PrintString (_Width / 2 - 5 - (-i - 1) * 10 + (1 + i) * 5, 5), "@ " Next i
If win = 0 And begin = 1 Then gluck = ((Timer - starttime) / pLL) / (100 * Life) minute = Int((Timer - starttime) / 60) second = Int(Timer - starttime) - (minute * 60) End If If second < 10 Then k$ = "0" Else k$ = "" If rnt3 < Timer Then RndU3 = Rnd * .25 + .75: rnt3 = Timer + Rnd RndU3 = RndU3 + 1 / fps Color _RGB(255 * RndU3, 255 * RndU3, 255 * RndU3), _RGB(75, 75, 75)
_PrintString (_Width - 80, 5), Str$(minute) + ":" + k$ + LTrim$(Str$(second)) 'Int(Timer - starttime)) frames = frames + 1 If oldtime < Timer(.00001) Then fps = frames frames = 1 oldtime = Timer(.00001) + 1 End If win = 1 For i = 1 To NBbrickL For j = 1 To NBbrickH For q = 1 To TOTALBall xmin = startX + (i - 1) * LargeurBrick: xmax = xmin + LargeurBrick + DiametreBall ymin = startYu + (j - 1) * HauteurBrick: ymax = ymin + HauteurBrick + DiametreBall px = b(q).PX + DiametreBall * .5: py = b(q).PY + DiametreBall * .5 If px >= xmin And px <= xmax And py >= ymin And py <= ymax And br(i, j).active >= 1 Then Left = -px + (xmin): Right = -(xmax) + px: Top = -py + (ymin): Bot = -(ymax) + py If Left >= Right And Left >= Top And Left >= Bot Then b(q).PX = xmin - DiametreBall b(q).VX = -Abs(b(q).VX) If b(q).VX * b(q).VX > 1 Then b(q).VX = Sgn(b(q).VX) b(q).VY = Sqr(1 - b(q).VX * b(q).VX) * Sgn(b(q).VY) End If If Right >= Left And Right >= Top And Right >= Bot Then b(q).PX = xmax b(q).VX = Abs(b(q).VX) If b(q).VX * b(q).VX > 1 Then b(q).VX = Sgn(b(q).VX) b(q).VY = Sqr(1 - b(q).VX * b(q).VX) * Sgn(b(q).VY) End If If Top >= Bot And Top >= Left And Top >= Right Then b(q).PY = ymin - DiametreBall b(q).VY = -Abs(b(q).VY) If b(q).VY * b(q).VY > 1 Then b(q).VY = Sgn(b(q).VY) b(q).VX = Sqr(1 - b(q).VY * b(q).VY) * Sgn(b(q).VX) End If If Bot >= Top And Bot >= Left And Bot >= Right Then b(q).PY = ymax b(q).VY = Abs(b(q).VY) If b(q).VY * b(q).VY > 1 Then b(q).VY = Sgn(b(q).VY) b(q).VX = Sqr(1 - b(q).VY * b(q).VY) * Sgn(b(q).VX) End If
If br(i, j).active = 1 Then _SndPlay brickF If br(i, j).active = 2 Then _SndPlay brickS br(i, j).active = br(i, j).active - 1 SCORE = SCORE + Life * points pLL = pLL + 1 End If Select Case br(i, j).active Case 2: _PutImage (startX + (i - 1) * LargeurBrick, startYu + (j - 1) * HauteurBrick), Brick1&, 0, (1, 1)-(LargeurBrick - 1, HauteurBrick - 1): win = 0 Case 1: _PutImage (startX + (i - 1) * LargeurBrick, startYu + (j - 1) * HauteurBrick), Brick2&, 0, (1, 1)-(LargeurBrick - 1, HauteurBrick - 1): win = 0 End Select If br(i, j).active <= 0 And br(i, j).active >= -1 Then dd = Abs(br(i, j).active) * HauteurBrick * .5 _PutImage (startX + (i - 1) * LargeurBrick + dd, startYu + (j - 1) * HauteurBrick + dd)-(startX + (i) * LargeurBrick - dd, startYu + (j) * HauteurBrick - dd), Brick2&, 0, (1, 1)-(LargeurBrick - 1, HauteurBrick - 1) br(i, j).active = br(i, j).active - 3 / fps
End If If br(i, j).active < -1 And br(i, j).active <> -2 Then If bb(i * j).active = 1 Then bb(i * j).active = 2 bb(i * j).x = startX + (i - 1) * LargeurBrick bb(i * j).y = startYu + (j - 1) * HauteurBrick + HauteurBrick br(i, j).active = -2 End If End If Next q Next j, i Do: Loop While _MouseInput For o = 1 To NBbrickL * NBbrickH If bb(o).active = 2 Then bb(o).y = bb(o).y + (1 / (1 + fps)) * 125 If bb(o).y > _Height - 5 Then bb(o).active = 0 Select Case bb(o).genre Case 1 _PutImage (bb(o).x + _Width(Bonus1&) * .5, bb(o).y), Bonus1& If bb(o).y > _Height - 25 - DiametreBall * .5 Then If Abs(rX - bb(o).x) < (55 + add) And win = 0 Then bb(o).active = 0 TOTALBall = TOTALBall + 2 ReDim _Preserve b(TOTALBall) As ball ReDim _Preserve Speed(TOTALBall) b(TOTALBall).PX = Rnd * _Width b(TOTALBall).PY = _Height - 30 b(TOTALBall).VX = Rnd - Rnd b(TOTALBall).VY = Sqr(1 - b(TOTALBall).VX * b(TOTALBall).VX) * -1 b(TOTALBall).active = 1 Speed(TOTALBall) = 0 b(TOTALBall - 1).PX = Rnd * _Width b(TOTALBall - 1).PY = _Height - 30 b(TOTALBall - 1).VX = Rnd - Rnd b(TOTALBall - 1).VY = Sqr(1 - b(TOTALBall - 1).VX * b(TOTALBall - 1).VX) * -1 b(TOTALBall - 1).active = 1 Speed(TOTALBall - 1) = 0 End If End If Case 2 _PutImage (bb(o).x, bb(o).y), Bonus2& If bb(o).y > _Height - 25 - DiametreBall * .5 Then If Abs(rX - bb(o).x) < (55 + add) And win = 0 Then groout = Timer + 5 bb(o).active = 0 _SndPlay Larger End If End If Case 3 _PutImage (bb(o).x, bb(o).y), Bonus3& If bb(o).y > _Height - 25 - DiametreBall * .5 Then If Abs(rX - bb(o).x) < (55 + add) And win = 0 Then grooTut = Timer + 5 bb(o).active = 0 End If End If End Select End If Next o If grooTut > Timer Then gtir = 1 Else If gtir = 1 Then For u = 1 To totir If u <= UBound(ttir) And win = 0 Then If ttir(u).a = 1 Then ttir(u).y = ttir(u).y - (1 / fps) * 354 _PutImage (ttir(u).x - _Width(tir&) * .5, ttir(u).y), tir& If ttir(u).y < 1 Then ttir(u).a = 0 For i = 1 To NBbrickL For j = 1 To NBbrickH xmin = startX + (i - 1) * LargeurBrick - DiametreBall * .5: xmax = xmin + LargeurBrick + DiametreBall ymin = startYu + (j - 1) * HauteurBrick - DiametreBall * .5: ymax = ymin + HauteurBrick + DiametreBall px = ttir(u).x + DiametreBall * .5: py = ttir(u).y + DiametreBall * .5 If px >= xmin And px <= xmax And py >= ymin And py <= ymax And br(i, j).active >= 1 Then br(i, j).active = br(i, j).active - 1 SCORE = SCORE + Life * points pLL = pLL + 1 ttir(u).a = 0 End If Next j, i End If End If Next u jk = 0 For u = 1 To totir If ttir(u).a = 1 Then jk = 1 Next u If jk = 0 Then gtir = 0 totir = 0 ReDim ttir(0) As tir End If End If End If If gtir = 1 Then If cadence < Timer Then If _MouseButton(1) And begin = 1 And grooTut > Timer Then _SndPlay tirS totir = totir + 2 ReDim _Preserve ttir(totir) As tir ttir(totir).x = rX - 28 ttir(totir - 1).x = rX + 28 ttir(totir).y = _Height - 30 ttir(totir - 1).y = _Height - 30 ttir(totir).a = 1 ttir(totir - 1).a = 1 cadence = Timer + .25 End If End If For u = 1 To totir If u <= UBound(ttir) Then If ttir(u).a = 1 Then ttir(u).y = ttir(u).y - (1 / fps) * 354 _PutImage (ttir(u).x - _Width(tir&) * .5, ttir(u).y), tir& For i = 1 To NBbrickL For j = 1 To NBbrickH xmin = startX + (i - 1) * LargeurBrick - DiametreBall * .5: xmax = xmin + LargeurBrick + DiametreBall ymin = startYu + (j - 1) * HauteurBrick - DiametreBall * .5: ymax = ymin + HauteurBrick + DiametreBall px = ttir(u).x + DiametreBall * .5: py = ttir(u).y + DiametreBall * .5 If px >= xmin And px <= xmax And py >= ymin And py <= ymax And br(i, j).active >= 1 Then br(i, j).active = br(i, j).active - 1 SCORE = SCORE + Life * points pLL = pLL + 1 ttir(u).a = 0 End If Next j, i End If End If Next u End If If groout > Timer Then add = add + (1 / fps) * 25 Else add = add - (1 / fps) * 25 End If If add < 0 Then add = 0 If add > 25 Then add = 25 For y = 1 To 10 c = 200 - y * 20 Line (rX - (50 + add) + y, _Height - 25 + y)-(rX + (50 + add) - y, _Height - 25 + y), _RGB(c, c, c)
Next y co = co - (5 / fps) If co < 0 Then co = 0 Else For y = 0 To co c = 200 - y * 20 Line (rX - 30, _Height - 25 - y)-(rX - 25, _Height - 25 - y), _RGB(c, c, c) Line (rX + 30, _Height - 25 - y)-(rX + 25, _Height - 25 - y), _RGB(c, c, c) Next y
End If ti = ti + (1 / fps) * 640 If ti > _Pi * 2 Then ti = 0 cv = 175 * Abs(Cos(ti)) For th = -50 To 50 cvv = (1 - Abs(th) / 50) * cv PSet (rX + th, _Height - 22), _RGB(cvv, cvv, cvv) Next th
If grooTut > Timer Then co = co + (10 / fps) If co > 10 Then co = 10 If rnt4 < Timer Then RndU4 = Rnd * .25 + .75: rnt4 = Timer + Rnd RndU4 = RndU4 + 1 / fps Color _RGB(255 * RndU4, 255 * RndU4, 255 * RndU4), _RGB(cub, cub, cub) If win = 1 Then
_PrintString (_Width / 2 - 7 * 8, _Height / 2), "Congratulation" _PrintString (_Width / 2 - 8 * 8, _Height / 2 + 16), "click to restart" a = Int(((SCORE / MAXpoints) * 15000) / gluck) u = Len(LTrim$((Str$(a)))) If u <= 3 Then truscore$ = Str$(a) If u > 3 And u < 7 Then tscore = Int(a) fs = Int(tscore / 1000): ds = Int(tscore - fs * 1000) If ds < 10 Then fr$ = "00" Else If ds < 100 Then fr$ = "0" Else If ds >= 100 Then fr$ = "" truscore$ = (Str$(fs)) + " " + LTrim$(fr$) + LTrim$(Str$(ds))
End If If u >= 7 Then tscore = Int(a) fs = Int(tscore / 1000000): ds = Int(tscore - fs * 1000000)
gs = Int(ds / 1000): hs = Int(ds - gs * 1000)
If gs < 10 Then fg$ = "00" Else If gs < 100 Then fg$ = "0" Else If gs >= 100 Then fg$ = ""
If hs < 10 Then fr$ = "00" Else If hs < 100 Then fr$ = "0" Else If hs >= 100 Then fr$ = "" truscore$ = (Str$(fs)) + " " + LTrim$(fg$) + LTrim$(Str$(gs)) + " " + LTrim$(fr$) + LTrim$(Str$(hs))
End If bodo = Len("SCORE : " + truscore$) * .5 _PrintString (_Width / 2 - bodo * 8, _Height / 2 + 32), "SCORE : " + truscore$ If _MouseButton(1) And tim < Timer Then tim = Timer + 1: GoTo start End If If Life = 0 Then
_PrintString (_Width / 2 - 4 * 8, _Height / 2), "Game Over" _PrintString (_Width / 2 - 8 * 8, _Height / 2 + 16), "click to restart" a = Int(((SCORE / MAXpoints) * 15000) / gluck) u = Len(LTrim$((Str$(a)))) If u <= 3 Then truscore$ = Str$(a) If u > 3 And u < 7 Then tscore = Int(a) fs = Int(tscore / 1000): ds = Int(tscore - fs * 1000) If ds < 10 Then fr$ = "00" Else If ds < 100 Then fr$ = "0" Else If ds >= 100 Then fr$ = "" truscore$ = (Str$(fs)) + " " + LTrim$(fr$) + LTrim$(Str$(ds))
End If If u >= 7 Then tscore = Int(a) fs = Int(tscore / 1000000): ds = Int(tscore - fs * 1000000)
gs = Int(ds / 1000): hs = Int(ds - gs * 1000)
If gs < 10 Then fg$ = "00" Else If gs < 100 Then fg$ = "0" Else If gs >= 100 Then fg$ = ""
If hs < 10 Then fr$ = "00" Else If hs < 100 Then fr$ = "0" Else If hs >= 100 Then fr$ = "" truscore$ = (Str$(fs)) + " " + LTrim$(fg$) + LTrim$(Str$(gs)) + " " + LTrim$(fr$) + LTrim$(Str$(hs))
End If bodo = Len("SCORE : " + truscore$) * .5 _PrintString (_Width / 2 - bodo * 8, _Height / 2 + 32), "SCORE : " + truscore$ If _MouseButton(1) And tim < Timer Then tim = Timer + 1: GoTo start End If
If begin = 0 And Life = 3 Then _PrintString (_Width / 2 - 7 * 8, _Height / 2 + 16), "click to start": starttime = Timer
frx = _MouseX: fry = _MouseY If fry < 5 Then fry = 5 If fry > _Height - 5 Then fry = _Height - 5 If frx < 5 Then frx = 5 If frx > _Width - 5 Then frx = _Width - 5 If tim < Timer And _FullScreen = 0 Then _MouseMove frx, fry If Life > 0 And begin = 1 Then If oldrx > frx Then rX = rX - (1 / fps) * 1800 Else rX = rX + (1 / fps) * 1800 oldrx = rX If _MouseButton(1) And tim < Timer And begin = 0 Then begin = 1: tim = Timer + .1: ' _MouseMove _Width / 2, _Height / 2 If Life < 3 Then starttime = starttime + (Timer - endtime) End If If begin = 1 Then For q = 1 To TOTALBall If b(q).active = 1 And win = 0 Then moveBalls q _PutImage (b(q).PX - DiametreBall * .5, b(q).PY - DiametreBall * .5), Ball& End If Next q Else rX = _Width / 2 b(1).PX = _Width / 2 + ((_MouseX - _Width / 2) / (_Width / 2)) * 50: b(1).PY = _Height - 25 - DiametreBall * .5 b(1).VX = -((rX - b(1).PX) / INCIDE) If b(1).VX * b(1).VX > 1 Then b(1).VX = Sgn(b(1).VX) b(1).VY = -Sqr(1 - b(1).VX * b(1).VX) _PutImage (b(1).PX - DiametreBall * .5, b(1).PY - DiametreBall * .5), Ball& End If bb = 0 For q = 1 To TOTALBall If b(q).active = 1 Then bb = 1 Next q If bb = 0 Then TOTALBall = 1 ReDim b(TOTALBall) As ball b(TOTALBall).active = 1 If win = 0 Then Life = Life - 1 begin = 0 endtime = Timer End If For o = 1 To NBbrickL * NBbrickH If bb(o).active = 2 Then bb(o).active = 0 Next o grooTut = Timer - 1 tim = Timer + 1 If win = 0 Then _SndPlay Loose End If If botime < Timer Then For hu = 0 To 3 cot1x(hu) = Rnd * _Width: cot1y(hu) = Rnd * _Height cot2x(hu) = Rnd * _Width: cot2y(hu) = Rnd * _Height opi(hu) = Int(Rnd * 100) Next hu botime = Timer + Rnd * .05
End If If Rnd > .9 Then Line (cot1x(1), 30)-(cot1x(1), _Height), _RGB(opi(1) * .2, opi(1) * .2, opi(1) * .2) For ju = 0 To 3 _PutImage (cot1x(ju), cot1y(ju)), scratch1(opi(ju)) _PutImage (cot2x(ju), cot2y(ju)), scratch2(opi(ju)) Next ju _Display Loop Until _KeyDown(27) System 0 Sub moveBalls (i) Shared fps, Life, begin, speed, DiametreBall, HauteurBrick, add Shared b() As ball, Speed() If b(i).PX < 15 - DiametreBall * .5 Then _SndPlay brickF b(i).PX = 15 - DiametreBall * .5 b(i).VX = -b(i).VX b(i).VY = Sqr(1 - b(i).VX * b(i).VX) * Sgn(b(i).VY) End If If b(i).PX > _Width - 15 Then _SndPlay brickF b(i).PX = _Width - 15 b(i).VX = -b(i).VX b(i).VY = Sqr(1 - b(i).VX * b(i).VX) * Sgn(b(i).VY) End If If b(i).PY < 30 + DiametreBall Then _SndPlay brickF b(i).PY = 30 + DiametreBall b(i).VY = -b(i).VY b(i).VX = Sqr(1 - b(i).VY * b(i).VY) * Sgn(b(i).VX) End If If b(i).PY > _Height - 25 - DiametreBall * .5 Then If Abs(rX - b(i).PX) < (add + 55) Then _SndPlay raqueT b(i).VX = -((rX - b(i).PX) / INCIDE) If b(i).VX * b(i).VX > 1 Then b(i).VX = Sgn(b(i).VX) * .95 b(i).VY = Sqr(1 - b(i).VX * b(i).VX) * Sgn(-b(i).VY) b(i).PY = _Height - 25 - DiametreBall * .5 End If End If If b(i).PY > _Height - 15 Then If b(i).PY > _Height Then b(i).active = 0 Speed(i) = 0 Exit Sub End If End If Speed(i) = Speed(i) + (1 / fps) * 5 gro = (1 / (1 + fps)) * (344 + Speed(i)) If gro > HauteurBrick * .5 Then gro = HauteurBrick * .5 b(i).PX = b(i).PX + b(i).VX * gro b(i).PY = b(i).PY + b(i).VY * gro End Sub
|
|
|
Post by bplus on Feb 25, 2024 17:59:01 GMT
Ah to keep mouse inside screen, yes that is good reason!
|
|
ubi44
New Member
Posts: 32
|
Post by ubi44 on Feb 26, 2024 11:40:29 GMT
The completed game ! with hall of fame ! If you have any suggestions for improving QB64 & QB64PE Breakou_QB64_QB64PEv5.zip (459.11 KB) Add _freeimage before leaving ! & System 0 __ (v4 if not_fileexists create highscores.txt)_(v5 Ball bounced off a brick corrected!) Have question about $embed : Can I open and edit a file $Embed Ex: $Embed:'./highscoresr.txt','highS' Open _Embedded$("highS") For Output As #1 doesn't work!
|
|