fridayjones85 has asked for the wisdom of the Perl Monks concerning the following question:
I've created an ascii-art game that uses a two-dimensional array to keep track of the map, which refreshes each time the character moves. The game is also multiplayer, using io::socket::inet sockets to recieve the opponent's location and refresh the map when a change is made. To achieve this, I used threads so that both the keyboard and the sockets would wait for input simultaneously.
My problem is this: when the thread is created, the 2D array storing the map on the main level:
#@level is an array of strings; each string is a row of the map. # This breaks the entire thing into a 2D array where each element is a + character on the map. my @tempArray; my @twoDee; for(my $m = 0; $m <= $#level; $m++) { @tempArray = split(//, $level[$m]); push @twoDee, [@tempArray]; }
I have read the man pages from threads::shared many times, but can't find / understand a means of sharing a 2D array, which would make my life much simpler. I've poked and prodded, but usually get an error message about inappropriate scalar values.
I'd appreciate any help anyone could offer -- also, let me know if you need to see more code blocks and I'll paste them here.
Janitored by Corion: Added formatting, code tags, as per Writeup Formatting Tips
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using threads::shared with multidimensional arrays
by BrowserUk (Patriarch) on Jun 10, 2006 at 23:18 UTC | |
|
Re: Using threads::shared with multidimensional arrays
by renodino (Curate) on Jun 10, 2006 at 22:37 UTC | |
|
Re: Using threads::shared with multidimensional arrays
by chromatic (Archbishop) on Jun 11, 2006 at 04:43 UTC | |
by Anonymous Monk on Jun 12, 2006 at 12:23 UTC |