Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / [SOLVED] Please help me with my Map Editor Save and Load

Author
Message
Bob Sherman
2
Years of Service
User Offline
Joined: 15th Jul 2016
Location:
Posted: 1st Dec 2018 00:45
Just a few things to get out of the way:
I know other map editor exist
I know you can use Tiled
My coding isn't beautiful (but it's commented)

I posted this a while back, but I decided to revisit it and try to get it to work. For some reason I can't get the saving and loading correct. Please can someone help me with my code. Thank you.

Attachments

Login to view attachments

The author of this post has marked a post as an answer.

Go to answer

Cybermind
16
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 3rd Dec 2018 09:40 Edited at: 3rd Dec 2018 10:33
This post has been marked by the post author as the answer.
Hi

First, I changed the way sprite ID's are stored when the map is created, I have the function return an ID instead of assigning an ID manually.



Then, in your bottommost SaveMap() function, I've added the .image to identify which image is stored there.


When you load your map (and here the CreatedSpriteID stored earlier when creating the map comes in handy, now you can just check map[x,y].SpriteID to see which sprite is at what tile, this might, however, affect other stuff as I can see you do some manually assigning of IDs, I always have the function return an ID and then store that ID, this goes for images and sprites and what not. This makes your code more dynamic as you don't have to worry about which ID's are free as your code grows) I have added a line that changes the sprite image when not zero, I have added .image to map[i,j].



I hope this helps you

EDIT: Oh, and by default, AppGameKit does not save in the same directory as the app is run from. So your map.dat is located in users folder when on Windows, don't know which folders the other platforms use.

EDIT again: I made DrawImage global (Global DrawImage as integer)
13/0
Bob Sherman
2
Years of Service
User Offline
Joined: 15th Jul 2016
Location:
Posted: 9th Dec 2018 22:55
Thank you so much Cybermind!!
Cybermind
16
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 12th Dec 2018 09:24
Glad I could help I noticed that clicking the UI at the top would also cause clicking on the tile map, you could simply disable the top part of the screen for the tilemap so only the UI reacts to clicks at the top of the screen
13/0
Vladimuffin
2
Years of Service
User Offline
Joined: 27th Nov 2016
Location:
Posted: 13th Dec 2018 03:13
It looks like your thismidX and thismidY aren't finding the middle because you have // before *0.5. I know that doesn't relate to saving but noticed it while reading
One smart fellow, he felt smart. Two smart fellows, both felt smart. Three smart fellows all felt smart...
GubbyBlips
User Offline
Joined: 20th Dec 2018
Location:
Posted: 22nd Dec 2018 04:47
Thanks for the help.

Login to post a reply

Server time is: 2019-06-18 00:44:04
Your offset time is: 2019-06-18 00:44:04