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