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.

Author
Message
Max123
8
Years of Service
User Offline
Joined: 22nd Mar 2016
Location:
Posted: 17th Jul 2016 12:29
Hello,
I've got a question on how to implement tile maps in AppGameKit.
Is there a way to do something like this:

map = {
{0,0,0,0,0},
{0,0,0,0,0},
}
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 18th Jul 2016 04:48 Edited at: 18th Jul 2016 04:49
here you can find an example.
https://www.appgamekit.com/documentation/guides/12_array_changes.htm

myself using files, also later you will need save/load more complex data for your level.
you can start with a simple ascii file (and fixed width font) to generate a map of it, like this
W=Wall,K=Key,M=Monster,D=Door,S=Start,E=Exit
WWWWWWWWWWWWWWW
W -----------------E
W---K--------------------M
W ------------- D
W ----------------------S
WWWWWWWWWWWWWWW
AGK (Steam) V2.0.20 : Windows 10 Pro 64 Bit : AMD (16.3.2) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
SoftMotion3D
AGK Developer
18
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 19th Jul 2016 23:25
Quote: "I've got a question on how to implement tile maps in AppGameKit."


simple.... dim map[32,32]
or a 3d map... dim map[32,32,32]
or if you need more then one value per cell... dim map[32,32,32,10] effectivly giving you 11 write values to each 3d tile
writting to it is as easy as this: map[1,0,1,0]=5 [maybe 5 can be what tile to use...etc etc]
Nieb
9
Years of Service
User Offline
Joined: 13th May 2014
Location: Lurking
Posted: 20th Jul 2016 19:16 Edited at: 20th Jul 2016 19:22
You could do something like so:


Then run through it with something like so:


Then load tile images like so:


Then assign tile images like so:
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 22nd Jul 2016 20:01
Quote: " dim map[32,32,32,10] "


I would strongly encourage he learn to use UDTs at that point. Greater flexibility and variable names would make it way easier to remember what's going on.

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
Max123
8
Years of Service
User Offline
Joined: 22nd Mar 2016
Location:
Posted: 23rd Jul 2016 11:42
Thank you for all the answers
SoftMotion3D
AGK Developer
18
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 25th Jul 2016 19:05 Edited at: 25th Jul 2016 19:06
Quote: "I would strongly encourage he learn to use UDTs at that point"


im a veteran agk user.... and i dont use udts at all. but your correct that you do need to remember whats what. Thats why i got my trusty notepad infront of me
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 25th Jul 2016 22:48
Quote: "im a veteran agk user.... and i dont use udts at all"

I'm shocked! Literally, shocked!

UDTs are hugely important if only for simplifying the way data is displayed to the developer!
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 26th Jul 2016 16:44
If you insist on using a standard array of numbers, at least use constants to represent the numbers.

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
SoftMotion3D
AGK Developer
18
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 27th Jul 2016 23:43
Quote: "If you insist on using a standard array of numbers, at least use constants to represent the numbers. "


nah... lol!

instead i have a standardized system in place. for every entity they use the same array sequence numbers for the same data types. inside my main functions i pull the array data into words to use them easier... then i save the words values back to my arrays once finished with them. I dont think i will ever use udt's unless someone has a gun to my head I've been coding this way for too long and you cant teach an old dog new tricks.
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 28th Jul 2016 05:06


You're making so much more work for yourself and anyone that ever reads through your code.

If you want to store mixed or complex data, udt is the way to go.


A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.

Login to post a reply

Server time is: 2024-04-19 11:57:58
Your offset time is: 2024-04-19 11:57:58