不移动时播放器图像消失/“加载地图”加载速度不够快

Posted

技术标签:

【中文标题】不移动时播放器图像消失/“加载地图”加载速度不够快【英文标题】:player image disapearing when not moving / "load_map" not lading fast enough 【发布时间】:2019-08-26 00:56:04 【问题描述】:

代码有效,但是当我不移动时屏幕被清除,导致玩家在你不移动时消失。

我尝试过wait .5, .5。只是不使用CLS 我还认为DO LOOP 中的CLS 阻止了地图加载

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

【问题讨论】:

【参考方案1】:

好吧,我想通了

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

我不得不删除enemyai 中的cls

【讨论】:

以上是关于不移动时播放器图像消失/“加载地图”加载速度不够快的主要内容,如果未能解决你的问题,请参考以下文章

提高网站页面加载速度的方法

线程加载图像更快,直到它们在 Studio 中消失

在使用 vue.js 和 vue-router 显示路由之前,Rest API 加载数据的速度不够快

在使用 vue.js 和 vue-router 显示路由之前,Rest API 加载数据的速度不够快

使用后台队列从 url 加载图像仍然不够快

检测在移动设备上离开全屏 iframe