I am trying to complete an RPG game for a project, but don’t know how to make a game map. This does not have to be graphic, but the code for the entire map and each tile must be correct.
So far, I have been thinking of creating a non-matrix map (as a professor request) using an ArrayList that contains all the associated fragments.
public abstract class Casella { /** * @uml.property name="tabellone" * @uml.associationEnd multiplicity="(1 1)" inverse="casella:Tabellone" * @uml.association name="contains" */ private int id; private boolean free = true; private List adjacent; private List items; private Tabellone tabellone = null; public void in(){ free = false; } public void out(){ free = true; } }
This was the code for one tile (which has 3 classes that extend it). I still don’t know how to assemble and create a map.
Thank you for your time.
, . ArrayList, . , ArrayList .
http://en.wikipedia.org/wiki/Adjacency_list
, , . , . :
, ? ? " X"?
[EDIT] RPG. / - (.. - ).
. (, , ). , (.. ?)
: , . , , , ( ).
, " ". : , , , . . - , .
, ASCII ( "C", "P", "H" ill), , .
, , , . , - , . , , , :
private Tabellone up = null; private Tabellone down = null; private Tabellone left = null; private Tabellone right = null;
, . , , , , Tablellone , , .
Tabellone adj = new Tabellone(); up = adj; adj.setDown(this);
, . . . , , , , , .
int count = 0; ArrayList<Tabellone> queue = new ArrayList<Tabellone>() queue.add(/*center tile*/); while (count < 100) { //if we want 100 tiles //take out the center tile from the beginning of the array list, create a tile for each direction and add those tiles to the array list, then increment count by 1. }
.. , , .
, , , .
, - , , .
private String level = " ######\n" + " ## #\n" + " ##$ #\n" + " #### $##\n" + " ## $ $ #\n" + "#### # ## # ######\n" + "## # ## ##### ..#\n" + "## $ $ ..#\n" + "###### ### #@## ..#\n" + " ## #########\n" + " ########\n";
. , . (#) . ($) . (.) , . at (@) - sokoban. , , (\n) .
? , 2d-?
-
Casella map [][] = new Casella[xSize][ySize];
, Excel, .
, , , . . , , -, , .
, .
for(int i = 0; i < XSIZE ; ++i) for(int j = 0; j < YSIZE ; ++j) if(j==0) //found left edge (i.e. no adjacent ones to the left) if(j==(YSIZE)) //found right edge (you get the picture)
, , , , 2, 3 4.
, , , , /.
, , X- , - , , , , , , edge, , , a multimap, .
, , AlbertoPL .
, X- Y-, , 4 2 , . , [Y] [X] [Y + 1] [X] [Y] [X + 1] . max 6 min 3, [Y + 1] [X + 1] [Y] [X]. , , 2 , . , , , . , , , , () , .
, . ( , ), .
, , , (n, s, e, w). , 1-6 (, ). .
Aaron, , .
X-Y-Z. , . , .
, RPG, . ? ? ?
Source: https://habr.com/ru/post/1710988/More articles:ASP classic читает .NET cookie в Firefox, но не IE - cookiesВ servlet destroy() называется first или finalize()? - javaHow can I create an XmlDocument with many xml namespaces in one node? - xmlASP.net Page object null when calling it from a control template - c #Countdown Timer - c #Использование Erlang для управления несколькими экземплярами внешнего процесса - erlangjavascript asks for a password (i.e. *******) - javascriptSecurity Considerations for Creating Email on the Internet - securityCDialog and CPropertySheet authentication recommendations? - validationIs there a separate Java library that provides LDAP style analysis? - javaAll Articles