Код пули

Реализация стрельбы по направлению взгляда игрока
  1. 10 side% = 1 : scrWidth% = SCREENWIDTH(0) : scrHeight% = SCREENHEIGHT(0)
  2. 11 GELLOAD "bull", "bullet.png"
  3. 12 GELLOAD "man", "man.png"
  4. 13 gelWidth% = GELWIDTH("man") : gelHeight% = GELHEIGHT("man")
  5. 14 SPRITEGEL "bull", "bull"
  6. 15 SPRITEGEL "man", "man"
  7. 16 SPRITEMOVE "man", playerX%, playerY%
  8. 17 SPRITEMOVE "bull", bulletX%, bulletY%
  9. 18 IF LEFT(0) THEN playerX% = playerX% - 1 : side% = 1
  10. 19 IF RIGHT(0) THEN playerX% = playerX% + 1 : side% = 2
  11. 20 IF UP(0) THEN playerY% = playerY% - 1 : side% = 3
  12. 21 IF DOWN(0) THEN playerY% = playerY% + 1 : side% = 4
  13. 22 IF FIRE(0) THEN ok% = ok% + 1
  14. 23 IF ok% = 1 THEN bulletX% = playerX% + gelWidth% / 2 : bulletY% = playerY% + gelHeight% / 2 : ok% = 2
  15. 24 IF ok% > 1 and side% = 1 THEN bulletX% = bulletX% - 1
  16. 25 IF ok% > 1 and side% = 2 THEN bulletX% = bulletX% + 1
  17. 26 IF ok% > 1 and side% = 3 THEN bulletY% = bulletY% - 1
  18. 27 IF ok% > 1 and side% = 4 THEN bulletY% = bulletY% + 1
  19. 28 IF bulletX% = 0 THEN ok% = 0
  20. 29 IF bulletY% = 0 THEN ok% = 0
  21. 30 IF bulletX% = scrWidth% THEN ok% = 0
  22. 31 IF bulletY% = scrHeight% THEN ok% = 0
  23. 32 IF ok% = 0 THEN bulletX% = -50 : bulletY% = -50

Реклама

Мы в соцсетях

tw tg yt gt