player image disapearing when not moving / "load_map" not lading fast enough

37 Views Asked by At

the code works, but the screen is getting cleared when i'm not moving, causing the player to disappear when you don't move.

ive tried doing wait .5, .5. and just not using CLS I also think that the CLS in the DO LOOP is preventing the map from loading

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 attached and sprites. https://drive.google.com/drive/folders/13LjenIPDfP34BActYdM19l9ljeo6F9xW?usp=sharing

1

There are 1 best solutions below

0
On

ok so i figured it out

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
    o = o + 1
    _PUTIMAGE (o, u), zombie

END SUB

i had to gt rid of the cls in enemyai