ID:157641
 
Heya everyone! I've been gone for a long while and I'm glad to see BYOND is still striving(?). I decided to sit down and play with some of the new functions since I left, skins, isometric maps, that kind of stuff. Anyway I got sucked into byond and for the last week have been developing what I hope will become a kick [butt] original Byond RPG!

The problem I've hit is where I'm trying to deal with 2 different maps. Theoretically ( haven't programed it yet), each player has a "piece". During regular gameplay this piece moves around a board. What I wanted to do, is have the player click a button, and have a window pop up (Got this part down) This window would contain a map control (Got this too) which would display the board and their piece (No idea how to do this part...)

I think I've hit a complete coder's block (kind of like writer's block) cause I can't even figure out how to make the piece! Is it it's own mob, or a variable of the player? Anyway, any help would be greatly appreciated.

A few notes about the board: It's pretty much for display purposes only, the player will not interact with it. However I will be pulling things like the piece's location off of it, but I'm not sure if that has to do with the board or the piece.
The board is kind of like Mario Party, there are weird paths and directions and each spot has it's own information.
Pieces will move in a semi-linear fashion, with the player choosing which direction to go at crossroads.

Edit: I forget, whats are the rules on swearing here?
So I have a theory on how this would work but I'm not sure if it's any good.

I've been going over LummoxJr's Second Hud demo. It seems to imply that a second map control cannot display a map, only icons drawn directly onto the screen. With this information, I was thinking I could get a big 2 dimensional list with each element containing a turf. I could then display a portion of the list in the secondary map, centered around the player's piece's location, which would be variables of the player. Lastly I would place the player's piece in the middle of the map.

so something like (this is freehand)
turf//These are the turfs that will fill the map
redspot
bluespot
greenspot
mob/var
pieceX=1//where the player's piece is
pieceY=1
piece='piece.dmi'//the piece's icon... does this work?
var/list/secondMap[10][10]//I'm not sure when I would fill the map...
mob/proc/displaysecondMap()//when the map is to be displayed
for(var/row=1, row<=10,row++)
for(var/column=1, column<=10,column++)
src.client.screen+=new secondMap[row],[column]("map2:[row],[column]")//draw all spots on the map
src.client.screen+=new piece("map2:[src.pieceX],[src.pieceY]")//draw the piece on the map


This would be called when they pull up the secondary map window. The real map will probably be somewhere around 50x50 or larger, and there is some more stuff needed to be done to center the screen around the piece, but in general I was wondering if this was a good method. Is there anyway to improve this? I'm worried about all the new procs, when they pull up the window a second time will it draw over the stuff and it will be deleted, or will it just stack on top of each other? should i just be using = instead of +=? does that work? I haven't tested this, I'll try to later today and post my results.
In response to Redslash
OK, so I did a bit and this is the code I have. It's not displaying the player's piece, but it will display a /obj/gameboard/piece... gotta go back to doing Trig now but if someone could take a look I'd really appreciate it!

var/list/secondMap[3][3]//Holds the map for the game board

world
New()//when the world starts
for(var/i=1,i<=3,i++)//initialize the game board
secondMap[i][1]=/obj/gameboard/redspot
secondMap[i][2]=/obj/gameboard/bluespot
secondMap[i][3]=/obj/gameboard/greenspot
..()

mob
var
gamePiece
pieceX=1
pieceY=1

Login()
gamePiece=new/obj/gameboard/piece()
displaySecondMap()
..()

proc
displaySecondMap() //when the map is to be displayed
for(var/row=1, row<=3,row++) //for each spot on the map
for(var/column=1, column<=3,column++)
var/thingy=secondMap[row][column] //for some reason it doesnt like new secondMap[row][column]("map2:[row],[column]")
client.screen += new thingy("map2:[row],[column]") //draw that spot on map
client.screen += new src.gamePiece("map2:[pieceX],[pieceY]") //draw the piece on the map

obj
gameboard
New(newloc)
screen_loc = newloc
icon='temporary.dmi'
redspot
icon_state="red"
bluespot
icon_state="blue"
greenspot
icon_state="green"
piece
icon_state="piece"


In response to Redslash
Half way done! I got ti displaying properly. I think my coder's block is gone too. Anyway, I'll post what I have up so if anyone else is having this problem they can see a possible solution.

var/list/secondMap[3][3]//Holds the map for the game board

world
New()//when the world starts
for(var/i=1,i<=3,i++)//initialize the game board
secondMap[i][1]=new/obj/gameboard/redspot()
var/obj/thingy=secondMap[i][1]
thingy.screen_loc="map2:[i],[1]"
secondMap[i][2]=new/obj/gameboard/bluespot()
thingy=secondMap[i][2]
thingy.screen_loc="map2:[i],[2]"
secondMap[i][3]=new/obj/gameboard/greenspot()
thingy=secondMap[i][3]
thingy.screen_loc="map2:[i],[3]"
..()

mob
var
obj/gameboard/gamePiece
pieceX=1
pieceY=1

Login()//after a player logs in, give them a piece and set up their board
..()
gamePiece=new/obj/gameboard/piece()
displaySecondMap(src)

verb
displaySecondMap() //when the map is to be displayed
for(var/row=1, row<=3,row++) //for each spot on the map
for(var/column=1, column<=3,column++)
client.screen += secondMap[row][column]
src.gamePiece.screen_loc="map2:2,2"
client.screen += src.gamePiece

obj
gameboard
New(newloc)
screen_loc = newloc
icon='temporary.dmi'
redspot
icon_state="red"
bluespot
icon_state="blue"
greenspot
icon_state="green"
piece
icon_state="piece"


I'm still looking for feedback, so if you spot something wrong or can think of a better way of doing it, please post! I'll try to upload a little demo and I'll edit this with a link when I do. It will also have comments :)

On another note... why hasn't any one posted? Am I just that uninteresting?