LoadBrush(1, "labirynt_01.png", {Transparency=#BLACK}) LoadBrush(2, "podloga.png") DisplayBrush(2, 1, 1) DisplayBrush(1, 1, 1) LoadSprite(1, "magazynier.png") startpos_x=225 startpos_y=235 pos_x=startpos_x pos_y=startpos_y DisplaySprite(1, pos_x, pos_y) StartTimer(1) While quit = False If IsKeyDown("LEFT") Then pos_x=pos_x-1 DisplaySprite(1, pos_x, pos_y) If IsKeyDown("RIGHT") Then pos_x=pos_x+1 DisplaySprite(1, pos_x, pos_y) If IsKeyDown("UP") Then pos_y=pos_y-1 DisplaySprite(1, pos_x, pos_y) If IsKeyDown("DOWN") Then pos_y=pos_y+1 DisplaySprite(1, pos_x, pos_y) WaitTimer(1, 10) Wend
If IsKeyDown("LEFT") Then pos_x=pos_x-1 DisplaySprite(1, pos_x, pos_y) If Collision (#SPRITE_VS_BRUSH, 1, 1, 1, 1) Then pos_x=pos_x+1 DisplaySprite(1, pos_x, pos_y)
@recedent, post #1
@recedent, post #1
Pytanie brzmi - gdzie popełniłem błąd? I czy błąd leży po mojej stronie, czy po stronie funkcji detekcji kolizji?
If IsKeyDown("LEFT") pos_x=pos_x-1 DisplaySprite(1, pos_x, pos_y) If Collision (#SPRITE_VS_BRUSH, 1, 1, 1, 1) pos_x=pos_x+1 DisplaySprite(1, pos_x, pos_y) EndIf Endif
If IsKeyDown("LEFT") pos_x=pos_x-1 DisplaySprite(1, pos_x, pos_y) If Collision (#SPRITE_VS_BRUSH, 1, 1, 1, 1) pos_x=pos_x+1 DisplaySprite(1, pos_x, pos_y) EndIf ElseIf IsKeyDown("RIGHT") pos_x=pos_x+1 DisplaySprite(1, pos_x, pos_y) If Collision (#SPRITE_VS_BRUSH, 1, 1, 1, 1) pos_x=pos_x-1 DisplaySprite(1, pos_x, pos_y) EndIf ElseIf IsKeyDown("UP") pos_y=pos_y-1 DisplaySprite(1, pos_x, pos_y) If Collision (#SPRITE_VS_BRUSH, 1, 1, 1, 1) pos_y=pos_y+1 DisplaySprite(1, pos_x, pos_y) EndIf ElseIf IsKeyDown("DOWN") pos_y=pos_y+1 DisplaySprite(1, pos_x, pos_y) If Collision (#SPRITE_VS_BRUSH, 1, 1, 1, 1) pos_y=pos_y-1 DisplaySprite(1, pos_x, pos_y) EndIf EndIf
@juen, post #5
Tylko że chyba nie da się sprawdzić kolizji nie ruszając sprita.
If IsKeyDown("LEFT") And Not Collision (#SPRITE_VS_BRUSH, 1, 1, 2, 1) pos_x=pos_x-1 DisplaySprite(1, pos_x, pos_y) Endif
@Hexmage960, post #3
While quit = False If IsKeyDown("LEFT") And Not Collision (#SPRITE_VS_BRUSH, 1, 1, 2, 1) pos_x=pos_x-1 DisplaySprite(1, pos_x, pos_y) EndIf If IsKeyDown("RIGHT") And Not Collision (#SPRITE_VS_BRUSH, 1, 1, 0, 1) pos_x=pos_x+1 DisplaySprite(1, pos_x, pos_y) EndIf If IsKeyDown("UP") And Not Collision (#SPRITE_VS_BRUSH, 1, 1, 1, 2) pos_y=pos_y-1 DisplaySprite(1, pos_x, pos_y) EndIf If IsKeyDown("DOWN") And Not Collision (#SPRITE_VS_BRUSH, 1, 1, 1, 0) pos_y=pos_y+1 DisplaySprite(1, pos_x, pos_y) EndIf WaitTimer(1, 10) Wend
@recedent, post #10