DUGA icon indicating copy to clipboard operation
DUGA copied to clipboard

pygame-web port

Open pmp-p opened this issue 1 year ago • 6 comments

Hi, i love it and thanks to pygame-ce and pygbag I tried to port the whole https://pmp-p.github.io/DUGA-wasm/

But i still have a problem with MAP.move_inaccessible_entities() where possible_npc_positions around line 67 is empty when running on Web

Same for available_pos in NPC.py around 446 random.choice on empty list

I'd really like to have your insight on that as it could be a bug in cpython wasm port or stdlib part.

pmp-p avatar Jan 17 '24 19:01 pmp-p

Oh, interesting! A web-based version would be interesting. I am unsure how much I can help, as I have no experience with doing this.

The game runs in my browser billede - When does the game crash for you? Also, is there a way, that I can see the console output?

Maybe try and see if the variables, in MAP.py, npc_positions (line 48) and temp_possible_npc_positions (line 51) are not empty. If they are, perhaps there is an error with the levels in SETTINGS.py

Also, did you change the levels in some way? There are some weird things going on when playing the endless mode billede This plant shouldn't be there and I cannot walk past it, which should be possible normally.

MaxwellSalmon avatar Jan 17 '24 20:01 MaxwellSalmon

npc_positions ends up empty indeed

SETTINGS.current_level=0 [((16, 4), 180, 1), ((14, 1), 180, 12), ((10, 10), 90, 15)] npc_positions=[]
68 /data/data/duga-wasm/assets/MAP.py bug possible_npc_positions is empty
>=> Seed:  0.7348403041952006
SETTINGS.current_level=0 [((34, 4), 90, 9), ((31, 11), 180, 1), ((18, 17), 360, 0), ((19, 19), 90, 2), ((25, 25), 270, 0), ((35, 18), 90, 15), ((30, 19), 270, 4), ((32, 28), 270, 1), ((22, 30), 180, 1), ((25, 28), 180, 4)] npc_positions=[]
68 /data/data/duga-wasm/assets/MAP.py bug possible_npc_positions is empty

you can inspect the game from repl by using https://pmp-p.github.io/DUGA-wasm?-i for url

to run locally get the changes from https://github.com/pmp-p/DUGA-wasm then python3 -m pip install --user pygbag and python3 -m pygbag --git --PYBUILD 3.13 --ume_block 0 --no_opt main.py then you can go to http://localhost:8000?-i

pmp-p avatar Jan 17 '24 20:01 pmp-p

It seems that the generated level is corrupt. The first level is always the same (the seed is the same) and for some reason it is completely wrong. I tried opening it in the level editor and it looks like this:

billede

The player start position is outside of the map and all doors are replaced by ferns, for some reason. Also a lot of NPC's and items are placed outside the playable area. I have no clue why this would happen, I have never experienced it before. Try to set the seed to something else - I tried to re-generate some maps in your version and it seemed a little bit better, yet still weird.

Maybe try to run some custom maps and see if they work without errors. If they work fine, the level generation must be bugged.

I tried running the map in my original version of the game as a custom level. The player spawns out of bounds and cannot get inside the level. Try to run this level as a custom level to see if the behavior is the same (Change file extension to .dat - unable to upload with the right extension)

customLevels.txt

MaxwellSalmon avatar Jan 17 '24 22:01 MaxwellSalmon

The seed is indeed fixed on wasm, like it would be in dev mode / bug repro mode !

with the above customLevels.dat npc_positions gets populated

pmp-p avatar Jan 18 '24 04:01 pmp-p

Using random.seed(time.time()) at top of main.py does not fix it. I guess there's something wrong with RNG feeding that only happens on wasm.

pmp-p avatar Jan 18 '24 04:01 pmp-p

That seems to be the case. The doors are sometimes replaced by ferns and have a weird behavior, which seems to be a mix of the two. If you find out anything, please let me know - I may also take a look at the level generation if I have the time.

MaxwellSalmon avatar Jan 18 '24 17:01 MaxwellSalmon