i did not undestand how works sprite 2D movement
- skinkairewalker
- Enthusiast
- Posts: 627
- Joined: Fri Dec 04, 2015 9:26 pm
i did not undestand how works sprite 2D movement
hi , i am a newbie in PureBasic xD , and i would like of understands how works the movement 2D !!
- BasicallyPure
- Enthusiast
- Posts: 536
- Joined: Thu Mar 24, 2011 12:40 am
- Location: Iowa, USA
Re: i did not undestand how works sprite 2D movement
Here is a small example.
Esc = quit
Esc = quit
Code: Select all
EnableExplicit
ExamineDesktops()
Define.i w = DesktopWidth(0)
Define.i h = DesktopHeight(0)
Define.i x, y, inc = 5
If InitKeyboard() And InitSprite() And OpenScreen(w, h, 32, "")
CreateSprite(1, 100, 100, #PB_Sprite_AlphaBlending )
StartDrawing(SpriteOutput(1))
Circle(49, 49, 49, $FF8080)
StopDrawing()
y = h/2 - 50
Repeat
FlipBuffers()
ClearScreen(0)
DisplayTransparentSprite(1, x, y)
x + inc
If x < 0 Or x > w-100
inc = -inc
x + inc
EndIf
ExamineKeyboard()
Until KeyboardReleased(#PB_Key_Escape)
EndIf
BasicallyPure
Until you know everything you know nothing, all you have is what you believe.
Until you know everything you know nothing, all you have is what you believe.
- BasicallyPure
- Enthusiast
- Posts: 536
- Joined: Thu Mar 24, 2011 12:40 am
- Location: Iowa, USA
Re: i did not undestand how works sprite 2D movement
Something a little more interesting
dancing eggs
dancing eggs
Code: Select all
EnableExplicit
ExamineDesktops()
Define.i w = DesktopWidth(0)
Define.i h = DesktopHeight(0)
Define.i x1, x2, x3, x4, y1, y2, y3, y4
Define.i Yinc, Xinc, Xmax = w - 100, Ymax = h - 100
If InitKeyboard() And InitSprite() And OpenScreen(w, h, 32, "")
CreateSprite(1, 100, 100)
CreateSprite(2, 100, 100)
StartDrawing(SpriteOutput(1))
Circle(49,49,49, $DFE7F6)
Circle(49, 49, 24, $1548F3)
StopDrawing()
StartDrawing(SpriteOutput(2))
Circle(49,49,49, $1548F3)
Circle(49, 49, 24, $DFE7F6)
StopDrawing()
x1 = w/2 - 50 : x2 = x1 : x3 = x1 : x4 = x1
y1 = h/2 - 50 : y2 = y1 : y3 = y1 : y4 = y1
Macro ShowSprites(x, y)
DisplayTransparentSprite(2, x, y)
DisplayTransparentSprite(1, x>>1, y>>1)
DisplayTransparentSprite(1, x>>1, Ymax - y>>1)
DisplayTransparentSprite(1, Xmax - x>>1, y>>1)
DisplayTransparentSprite(1, Xmax - x>>1, Ymax-y>>1)
EndMacro
Repeat
FlipBuffers()
ClearScreen($753F0C)
ShowSprites(x1,y1) : ShowSprites(x2,y2) : ShowSprites(x3,y3) : ShowSprites(x4,y4)
x1 + Xinc : y1 + Yinc
x2 - Xinc : y2 - Yinc
x3 + Xinc : Y3 - Yinc
x4 - Xinc : y4 + yinc
If x1 < 0 Or x1 > Xmax
Xinc = -Xinc
x1 + Xinc : x2 - Xinc : x3 + Xinc : x4 - Xinc
EndIf
If y1 < 0 Or y1 > Ymax
Yinc = - Yinc
y1 + Yinc : y2 - Yinc : y3 - Yinc : y4 + Yinc
EndIf
Xinc + Random(2) - 1
If Abs(Xinc) > 10 : Xinc >> 1 : EndIf
Yinc + Random(2) - 1
If Abs(Yinc) > 10 : Yinc >> 1 : EndIf
ExamineKeyboard()
Until KeyboardReleased(#PB_Key_Escape)
EndIf
BasicallyPure
Until you know everything you know nothing, all you have is what you believe.
Until you know everything you know nothing, all you have is what you believe.
- skinkairewalker
- Enthusiast
- Posts: 627
- Joined: Fri Dec 04, 2015 9:26 pm
Re: i did not undestand how works sprite 2D movement
but to movement sprite 2D , how is th command ?
example > movesprite(spriteID,spriteX,spriteY) <<< have some like this ? i dont understand how i movement sprite with screenposition xD
thanks by repply
example > movesprite(spriteID,spriteX,spriteY) <<< have some like this ? i dont understand how i movement sprite with screenposition xD
thanks by repply
Re: i did not undestand how works sprite 2D movement
You'd have to update the x, y coordinates and then draw the sprite with either the DisplaySprite() or the DisplayTransparentSprite() functions:skinkairewalker wrote:example > movesprite(spriteID,spriteX,spriteY) <<< have some like this ?
Code: Select all
instruction$ = "USE ARROW KEYS TO MOVE SPRITE" +
#CR$ + #CR$ + "PRESS ESCAPE TO QUIT"
If OpenWindow(0, 0, 0, 800, 600, "Sprite Movement", #PB_Window_ScreenCentered)
TextGadget(0, 0, 20, 800, 60, instruction$, #PB_Text_Center)
If InitKeyboard() And InitSprite() And
OpenWindowedScreen(WindowID(0), 30, 80, 740, 490, 0, 0, 0)
spriteX = 100 : spriteY = 100 : spriteMovement = 20
spriteID = LoadSprite(#PB_Any, #PB_Compiler_Home +
"examples/sources/data/Geebee2.bmp")
Repeat
;----------------------------------------------------
event = WindowEvent() ;missing WindowEvent() call
;----------------------------------------------------
FlipBuffers()
ExamineKeyboard()
ClearScreen(RGB(255, 255, 255))
If KeyboardReleased(#PB_Key_Right)
spriteX + spriteMovement
ElseIf KeyboardReleased(#PB_Key_Left)
spriteX - spriteMovement
ElseIf KeyboardReleased(#PB_Key_Up)
spriteY - spriteMovement
ElseIf KeyboardReleased(#PB_Key_Down)
spriteY + spriteMovement
EndIf
TransparentSpriteColor(spriteID, RGB(255, 0, 255))
DisplayTransparentSprite(spriteID, spriteX, spriteY)
Until KeyboardReleased(#PB_Key_Escape)
EndIf
EndIf
EDIT: code amended to include the WindowEvent() function
Last edited by TI-994A on Mon Feb 15, 2016 4:12 am, edited 1 time in total.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel
Re: i did not undestand how works sprite 2D movement
@skinkairewalker: Sprites don't have a position assigned to them. You simply specify where you want them drawn each time you display them.skinkairewalker wrote:but to movement sprite 2D , how is th command ?
example > movesprite(spriteID,spriteX,spriteY) <<< have some like this ? i dont understand how i movement sprite with screenposition xD
You can draw the same sprite in multiple places on a single screen rendering by simply using multiple DisplaySprite() or DisplayTransparentSprite() commands, each specifying different coordinates for the same sprite image.
You track the sprite's position using your own variables. You can implement a command like 'movesprite(spriteID, spriteX, spriteY)' by updating the variables that you have stored the sprite's position in and have your display routine reference them when rendering the sprites.
- skinkairewalker
- Enthusiast
- Posts: 627
- Joined: Fri Dec 04, 2015 9:26 pm
Re: i did not undestand how works sprite 2D movement
thanks BasicallyPure,TI-994A and Demivec by repplyes xD
now i understand how move sprite
now i understand how move sprite
- skinkairewalker
- Enthusiast
- Posts: 627
- Joined: Fri Dec 04, 2015 9:26 pm
Re: i did not undestand how works sprite 2D movement
when i debug my application by dome reason , App stop working
follow the screenshot> http://prntscr.com/a38rs8
follow the screenshot> http://prntscr.com/a38rs8
Re: i did not undestand how works sprite 2D movement
The sprite is not storing its coordinates. But you can use your own code to handle sprites (anyway it is required if you writing game or something more complex than just code example):skinkairewalker wrote:but to movement sprite 2D , how is th command ?
example > movesprite(spriteID,spriteX,spriteY) <<< have some like this ? i dont understand how i movement sprite with screenposition xD
thanks by repply
Code: Select all
Structure SINGLE_SPRITE
ID.i ; Purebasic sprite ID
X.l
Y.l
EndStructure
Procedure MoveSprite (*SPRITE.SINGLE_SPRITE, X, Y)
*SPRITE\X = X
*SPRITE\X = Y
EndProcedure
; after you wrapped your sprite ID to SINGLE_SPRITE structure this should be used instead of calling DisplaySprite directly
Procedure RenderSprite (*SPRITE.SINGLE_SPRITE)
With *SPRITE
DisplaySprite(\ID, \X, \Y)
EndWith
EndProcedure
;;;;;;;;;;;;;;;;;;;;;;;;
Define TEST.SINGLE_SPRITE ; that's some sprite
TEST\ID = ; assign to it your #sprite ID, obtained when creating sprite
MoveSprite(TEST, 50, 100) ; now you can move sprite that stylish way ^^
RenderSprite(TEST)
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
Re: i did not undestand how works sprite 2D movement
When using OpenWindowedScreen(), you need to add event handling using WindowEvent() in your main loop.skinkairewalker wrote:when i debug my application by dome reason , App stop working
follow the screenshot> http://prntscr.com/a38rs8
Code: Select all
While WindowEvent():Wend
Re: i did not undestand how works sprite 2D movement
A complete Breakout, tricky and very little
Code: Select all
EnableExplicit
Define copyright$="www.nachtoptik.de",version$="1.1j" ; Break out - (c) Werner Albus - www.nachtoptik.de
Define beep_0,beep_1,beep_2,stepp_0,max_levels,ball_x,ball_y,ball_y_1,max_balls,max_balls_1
Define clinker,clinker_1,racket_width,racket_height,racket_pos,racket_moving,win_x,win_y,animation_speed
Define mouse_x,wait_for_speed_up,swapping,moving_a,moving_b,count,i,ii,iii,speed_up,stepp_old
Global timer_event_1,stepp,stepp_1,go_x,go_y
#sound=0 ; If you want sound - load your own 3 "Beep" Sound Files and set #sound=1
CompilerIf #sound
#sound_0="beep_0.wav" ; Set here then the Path´s to the Soundfiles
#sound_1="beep_1.wav"
#sound_2="beep_2.wav"
DataSection
beep_0: :IncludeBinary #sound_0
beep_1: :IncludeBinary #sound_1
beep_2: :IncludeBinary #sound_2
EndDataSection
InitSound() : CatchSound(0,?beep_0) : CatchSound(1,?beep_1) : CatchSound(2,?beep_2)
If IsSound(0)=0 Or IsSound(1)=0 Or IsSound(2)=0
MessageRequester("Error","Can not init Sound",0)
End
EndIf
Macro play_sound(sound)
PlaySound(sound)
EndMacro
CompilerElse
Macro play_sound(sound)
EndMacro
CompilerEndIf
; ------------------------------- User editable Parameter´s -------------------------------
stepp_0=6 ; Speed - Start Value, from 3 up to max Levels (12) - Speed automatically add at times stepp_0 /3
max_levels=12 ; Maximal Level´s - Ball Speed add automaticaly from Level to Level
max_balls=5 ; Amount Ball´s in each Level
racket_width=70 ; Racket width
win_y=730 ; Window Y - resizable
; -----------------------------------------------------------------------------------------
animation_speed=10 ; I think, good so for the moostly Computer´s - Handbrake for very quickly Computer´s
win_x=1200 ; Window width - fix
ball_x=0 ; Startpoint Ball X
ball_y_1=220 ; Startpoint Ball Y
stepp_1=stepp_0
ball_y=ball_y_1
clinker=179
max_balls_1=max_balls*15
Dim clinker (clinker,1)
Enumeration 500
#rotor_1 : #rotor_2 : #rotor_3
#millstone_left : #millstone_right
#speedpoint_left : #speedpoint_right
#racket_0 : #racket_1 : #black_racket
#ball
EndEnumeration
If InitMouse()=0
MessageRequester("Error","Can´t init Mouse",0)
End
EndIf
If Not LoadFont(0, "Arial", 24,#PB_Font_Bold)
MessageRequester("Error","Can´t load Font Arial",0)
End
EndIf
Procedure coloring_clinker(clinker,clinker_color)
StartDrawing(SpriteOutput(clinker))
FrontColor(clinker_color)
DrawingMode(#PB_2DDrawing_Gradient)
LinearGradient (0,0,0,16)
Box(0,0,32,8)
FrontColor(0)
BackColor(clinker_color)
Box(0,8,32,8)
StopDrawing()
EndProcedure
Procedure display_and_rotate_sprite(sprite,x,y,angle)
RotateSprite(sprite,angle,#PB_Relative)
DisplaySprite(sprite,x,y)
EndProcedure
Procedure timer_events()
Select EventTimer()
Case 1
timer_event_1=1
Case 2
If stepp<stepp_1
stepp+1
go_x=stepp : go_y=stepp
EndIf
EndSelect
EndProcedure
Macro collision_rotor(rotor,divisor,add_count)
If SpriteCollision(rotor,win_x divisor -16,20,#ball,ball_x,ball_y)
If ball_x>win_x divisor
go_x=stepp
Else
go_x=-stepp
EndIf
count+add_count
play_sound(2)
EndIf
EndMacro
OpenWindow(0,0,0,win_x,win_y,"Breakout - created & © Werner Albus - "+copyright$+" - Free distribution is allowed - Fee-based distribution prohibited - Quiet With ESC - v"+version$,#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If InitSprite()=0 Or InitKeyboard()=0 Or OpenWindowedScreen(WindowID(0),0,0,win_x,win_y,0,0,0,#PB_Screen_WaitSynchronization)=0
MessageRequester("Error","Can´t init Spritesystem",0)
End
EndIf
AddWindowTimer(0,1,animation_speed) ; Handbrake for very quickly Computer´s:-)
AddWindowTimer(0,2,40) ; Accelerate Speed on Start - is this value bigger, stepp_0 must reduce
BindEvent(#PB_Event_Timer, @timer_events())
OpenWindowedScreen(WindowID(0),0,0,win_x,win_y)
ExamineKeyboard()
Gosub init_sprites
Repeat ; Main Loop
If WaitWindowEvent(1)=#PB_Event_CloseWindow : End : EndIf
If timer_event_1 ; Wait for Timer
timer_event_1=0
FlipBuffers() : ClearScreen(0)
StartDrawing(ScreenOutput())
DrawText(4,16,Str(count))
StopDrawing()
For i=5 To max_balls_1-15 Step 15 : DisplaySprite(#ball,i,7) : Next i ; Show available Ball´s
clinker_1=0
For ii=0 To clinker Step 30
For i=4 To win_x Step 40
ExamineMouse()
mouse_x=MouseX()-racket_width>>1 ; - a half Racket width
DisplaySprite(#ball,ball_x,ball_y) ; Show Ball
DisplaySprite(#black_racket,mouse_x+5,win_y-23) ; Show black Background Racket
If racket_moving
DisplaySprite(#racket_1,mouse_x,win_y-30) ; Show Racket 1 - Racket is moving
Else
DisplaySprite(#racket_0,mouse_x,win_y-30) ; Show Racket 0 - Racket standing still
EndIf
If SpriteCollision(#racket_0,Mouse_x,win_y-30,#ball,ball_x,ball_y) ; Racket to Ball Collision
play_sound(0) ; "Beep" Sound 0
go_y=-stepp
If racket_moving ; Racket is moving
Select racket_moving
Case 1 ; Racket moves to right
If ball_x-mouse_x>racket_width>>1
go_x=stepp
Else
go_x=stepp>>1
EndIf
Case -1 ; Racket moves to left
If ball_x-mouse_x>racket_width>>1
go_x=-stepp>>1
Else
go_x=-stepp
EndIf
EndSelect
Else ; Racket is not moving
If ball_x-mouse_x>-6 And ball_x-mouse_x<6 ; Racket Edge left Collision
go_x=-stepp
ElseIf ball_x-mouse_x>racket_width-6 And ball_x-mouse_x<racket_width ; Racket Edge right Collision
go_x=stepp
EndIf
EndIf
EndIf
If SpriteCollision(iii,i,50+ii,#ball,ball_x,ball_y) ; --- Collision Clinker´s -----
If clinker(iii,0)
go_y=-go_y
play_sound(2) ; "Beep" Sound 2
StartDrawing(SpriteOutput(iii))
Select Point(0,8)
Case $7F00 : count+1
Case $7F7F : count+2
Case $7F5F00 : count+3
Case $7F : count+4
EndSelect
StopDrawing()
EndIf
If ball_x-i<17 ; 16 = a half Clinker width
RotateSprite(iii,-10,#PB_Relative) : clinker(iii,1)-10
Else
RotateSprite(iii,10,#PB_Relative) : clinker(iii,1)+10
EndIf
If Abs(clinker(iii,1))>30 ; Tilting Angle max
clinker(iii,0)=0
Else
Select Abs(clinker(iii,1)) ; Re coloring Clinker´s
Case 10 : coloring_clinker(iii,$FFFF)
Case 20 : coloring_clinker(iii,$FFBF00)
Case 30 : coloring_clinker(iii,$FF)
Default : coloring_clinker(iii,$FF00)
EndSelect
EndIf
EndIf ; ------------------------- Collision Clinker´s ----------------------------
If clinker(iii,0) : clinker_1+1 : DisplaySprite(iii,i,50+ii) : EndIf ; Show active Clinker´s
iii+1
Next i
Next ii
display_and_rotate_sprite(#rotor_1,win_x>>2-16,20,9) ; Show Rotor 1
display_and_rotate_sprite(#rotor_2,win_x>>1-16,20,15) ; Show Rotor 2
display_and_rotate_sprite(#rotor_2,win_x>>1-16,20,90) ; Show Rotor 2
display_and_rotate_sprite(#rotor_3,win_x/1.3-16,20,-9) ; Show Rotor 3
display_and_rotate_sprite(#millstone_left,win_x>>1-32,280,-5) ; Show Millstone left
display_and_rotate_sprite(#millstone_right,win_x>>1,280,5) ; Show Millstone right
display_and_rotate_sprite(#speedpoint_left,win_x-1000,280,-45) ; Show Speed point left
display_and_rotate_sprite(#speedpoint_left,win_x-1000,280,-90) ; Show Speed point left
display_and_rotate_sprite(#speedpoint_right,win_x-232,280,45) ; Show Speed point right
display_and_rotate_sprite(#speedpoint_right,win_x-232,280,90) ; Show Speed point right
collision_rotor(#rotor_1,>>2,3) ; Collision Rotor 1
collision_rotor(#rotor_2,>>1,4) ; Collision Rotor 2
collision_rotor(#rotor_3,/1.3,3) ; Collision Rotor 3
If SpriteCollision(#millstone_left,win_x>>1-32,280,#ball,ball_x,ball_y) ; Collision Millstone left
count+2 : go_x=-stepp : play_sound(2)
ElseIf SpriteCollision(#millstone_right,win_x>>1,280,#ball,ball_x,ball_y) ; Collision Millstone right
count+2 : go_x=stepp : play_sound(2)
EndIf
If (SpriteCollision(#speedpoint_left,win_x-1000,280,#ball,ball_x,ball_y) Or SpriteCollision(#speedpoint_right,win_x-232,280,#ball,ball_x,ball_y)) ; Collision Speed Point´s
If wait_for_speed_up>50 ; Wait for Speed up
wait_for_speed_up=0
If speed_up
stepp=stepp_old ; Speed down to default
Else
stepp_old=stepp : stepp+stepp/3 ; Speed up
EndIf
If speed_up
count+4
coloring_clinker(#speedpoint_left,$FFBF00) ; Coloring Speed Point 1
coloring_clinker(#speedpoint_right,$FFBF00) ; Coloring Speed Point 2
Else
count+3
coloring_clinker(#speedpoint_left,$FF) ; Coloring Speed Point 1
coloring_clinker(#speedpoint_right,$FF) ; Coloring Speed Point 2
EndIf
speed_up=~speed_up
play_sound(2)
EndIf
EndIf
wait_for_speed_up+1 ; Slowly speed up the Ball
;If ball_y>win_y : go_y=-go_y : EndIf ; Demo mode for Test´s
If Not clinker_1 Or ball_y>win_y+25; Next Level or exit
If ball_y>win_y+25 ; Ball is exit
max_balls_1-15
If max_balls_1<15 ; Ball´s done
play_sound(1) ; "Beep" Sound 1
StartDrawing(ScreenOutput())
Box(0,240,win_x,win_y-240,0) ; Delete Artefakt´s
DrawingFont(FontID(0))
DrawText(win_x/2-TextWidth(copyright$)/2,10,copyright$) ; Copyright Text - removing prohibited
DrawingFont(#PB_Default)
StopDrawing()
FlipBuffers()
ReleaseMouse(1)
If MessageRequester("Again ?","Score : "+Str(count),#PB_MessageRequester_YesNo) = #PB_MessageRequester_Yes
RunProgram(ProgramFilename())
EndIf
End
EndIf
EndIf
iii=0 : ball_x=0 : ball_y=ball_y_1 : stepp=0 : speed_up=0
coloring_clinker(#speedpoint_left,$FFBF00) ; Re coloring Speed Point 1
coloring_clinker(#speedpoint_right,$FFBF00) ; Re coloring Speed Point 2
If Not clinker_1 ; Next Level, add Speed
stepp_1+1
If stepp_1>max_levels
stepp_1=max_levels
EndIf
If speed_up
stepp=stepp_old
EndIf
Gosub init_sprites
EndIf
EndIf
If Random(10)>9 ; Breaking the symmetric Ball moving - angry:-)
ball_x+Random(1) : ball_y+Random(1)
EndIf
ball_x+go_x : ball_y+go_y
If ball_x>win_x-6 : go_x=-stepp : EndIf
If ball_x<0 : go_x=stepp : EndIf
If ball_y<0 : go_y=stepp : EndIf
swapping=~swapping ; --------- Analyse moving Racket -----------
If swapping : moving_a=mouse_x : Else :moving_b=mouse_x :EndIf
If moving_a=moving_b
racket_pos=mouse_x
racket_moving=0 ; Racket moves not
Else
If mouse_x>racket_pos
racket_moving=1 ; Racket moves to right
ElseIf mouse_x<racket_pos
racket_moving=-1 ; Racket moves to left
EndIf
EndIf ; -------------------------------------------------------
If iii>29 : iii=0 : EndIf
ExamineKeyboard() ; Bye with Escape
If KeyboardPushed(#PB_Key_Escape)
End
EndIf
EndIf ; Wait for Timer
ForEver ; Repeat the Main Loop
;-------------------- Subroutine init Sprites ----------------------
init_sprites:
play_sound(1) ; "Beep" Sound 1
For i=0 To clinker
CreateSprite(i,32,16) ; Create Clinker´s
coloring_clinker(i,$FF00)
RotateSprite(i,180,#PB_Absolute)
clinker(i,0)=1 ; Clinker´s on
Next i
CopySprite(0,#rotor_1) ; Create Rotor 1
CopySprite(0,#rotor_2) ; Create Rotor 2
coloring_clinker(#rotor_1,$FFBF00) ; Coloring Rotor 1
coloring_clinker(#rotor_2,$FF) ; Coloring Rotor 2
CopySprite(#rotor_1,#rotor_3) ; Create Rotor 3
CreateSprite(#millstone_left,32,16) ; Create Millstone left
coloring_clinker(#millstone_left,$FFFF) ; Coloring Millstone left
CopySprite(#millstone_left,#millstone_right) ; Create Millstone right
CopySprite(#rotor_1,#speedpoint_left) ; Create Speed Point left
CopySprite(#rotor_1,#speedpoint_right) ; Create Speed Point right
CreateSprite(#racket_0,racket_width,10) ; Create Racket 0 - standing still
CreateSprite(#ball,7,7) ; Create Ball
CreateSprite(#black_racket,racket_width-10,10) ; Create black Racket - Background for Highspeed
SpriteQuality (#PB_Sprite_BilinearFiltering) ; Show High Quality Sprites
StartDrawing(SpriteOutput(#ball)) ; Coloring Ball
Circle(3,3,3,-1)
StopDrawing()
StartDrawing(SpriteOutput(#racket_0)) ; Coloring Racket 0
Box(0,0,5,10,$00D7FF)
Box(racket_width-5,0,5,10,$00D7FF)
Box(5,0,racket_width-10,7,-1)
DrawingMode(#PB_2DDrawing_Gradient)
LinearGradient (0,0,0,3)
Box(5,4,racket_width-10,4)
FrontColor($00D7FF)
Box(5,4,racket_width-10,4)
StopDrawing()
CopySprite(#racket_0,#racket_1) ; Create Racket 1 - moving
StartDrawing(SpriteOutput(#racket_1)) ; Re-coloring Racket 1 Edges for moving Racket
Box(0,0,5,10,$45FF)
Box(racket_width-5,0,5,10,$45FF)
StopDrawing()
ExamineMouse()
MouseLocate(win_x/2,win_y/2) ; Set Racket to Start Point
Return
Re: i did not undestand how works sprite 2D movement
Oversight on my part; totally missed the WindowEvent() function in the event loop.skinkairewalker wrote:when i debug my application by dome reason , App stop working...
Thanks for pointing that out, Danilo.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel