代码有效,但是当我不移动时屏幕会被清除,导致玩家在你不移动时消失。
我试过做wait .5, .5
。只是不使用CLS
我也认为CLS
在DO LOOP
阻止地图加载
RANDOMIZE TIMER
SCREEN _NEWIMAGE(800, 600, 32), 2
x = 0
y = 0
DIM SHARED x AS INTEGER
DIM SHARED y AS INTEGER
DIM SHARED u AS INTEGER
DIM SHARED o AS INTEGER
DIM SHARED Keypress AS STRING
DIM SHARED player AS LONG
DIM SHARED zombie AS LONG
DIM SHARED map_data(800, 600) AS INTEGER
SCREEN _NEWIMAGE(800, 600, 32)
u = INT(RND * 450) + 50
o = 100
player = _LOADIMAGE("Sprites\3.png")
house = _LOADIMAGE("Sprites\2.png")
zombie = _LOADIMAGE("Sprites\4.png")
TIMER ON
ON TIMER(.2) enemyai
DO
_PUTIMAGE (x, y), player
DO
Keypress = UCASE$(INKEY$)
IF LEN(Keypress) > 1 THEN Keypress = RIGHT$(Keypress, 1)
LOOP UNTIL Keypress > ""
CLS
SELECT CASE Keypress
CASE "W", "H": y = y - 10 'Up
CASE "A", "K"
x = x - 10 'Left
CASE "S", "P": y = y + 10 'Down
CASE "D", "M": x = x + 10 'Right
CASE "Q", CHR$(27): END 'Q or Esc Ends prog.
END SELECT
_PUTIMAGE (x, y), player
load_map
LOOP
SUB enemyai
CLS
o = o + 1
_PUTIMAGE (o, u), zombie
END SUB
SUB load_map
OPEN "map.dat" FOR INPUT AS #1
FOR a = 0 TO (780 \ 16)
FOR b = 0 TO (580 \ 10)
INPUT #1, map_data(a, b)
NEXT
NEXT
CLOSE #1
END SUB
map.dat 附加和精灵。 https://drive.google.com/drive/folders/13LjenIPDfP34BActYdM19l9ljeo6F9xW?usp=sharing