Java-Gaming.org Hi !
 Featured games (84) games approved by the League of Dukes Games in Showcase (604) Games in Android Showcase (171) games submitted by our members Games in WIP (654) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
Pages: [1]
 ignore  |  Print
 Maze Game Advice  (Read 893 times) 0 Members and 1 Guest are viewing this topic.
_Scyth_

Junior Devvie

 « Posted 2013-01-09 17:17:14 »

Hey again, I have another noobie question

It's not so much a coding one but I may need help with that in the end. Also, something that might be necessary is that I'm using the BlackBerry JDE 5.0.0 so I'm restricted to using the Graphics package that comes with it. I'm sure a lot of you probably do not have these libraries however like I said my question isn't really a coding one.

1. Is it practical to create a bunch of tiles, and define the walkable pathways using a certain number, so that i wouldn't have to worry about collision detection for a simple maze game.
2. How would I store the co-ordinates of the walkable tiles, so that I can iterate through like an array to see in what directions the player can walk.

PandaMoniumHUN

JGO Coder

Medals: 32
Exp: 3 years

White-bearded OGL wizard

 « Reply #1 - Posted 2013-01-09 17:58:37 »

Hi.
1. Yes, it's a good idea to make your mazes tile based. It will be useful when you would like to generate random mazes.
2. You can do it by dozens of different ways, however here is a pretty primitive solution:
Refer numbers to your tiles so it'll be like:
0 = Nothing
1 = Wall
2 = Player
And to store these values create a multidimensional array (int[][] level = new level[100][100] <- Here's the code to create 100*100 level).
After this all you have to do on movement is to check if the position where you want to move is a wall or not, with something like this:
 1  2  3  4  5  6  7 `int playerPosition_x = 10;int playerPosition_y = 10;if(Keys.Right.isPressed()){   if(level[playerPosition_x+1][playerPosition_y] == 0){      //You can move here because there's nothing   }}`

Please keep in my that I don't know how you have to handle inputs on BlackBerry JDE so Keys.Right.isPressed() is just an example.
Also don't forget to check if playerPosition_x+1 (or whatever tile you want to move to) is out of your array's bounds. (e.g. level[101][100], this will throw an OutOfBoundException since our level in my example is only 100 by 100 and not 101 by 100).
If you didn't understand anything just let me know and I'll try to explain it.

My Blog | Jumpbutton Studio - INOP Programmer
Can't stress enough: Don't start game development until you haven't got the basics of programming down!
_Scyth_

Junior Devvie

 « Reply #2 - Posted 2013-01-09 18:12:43 »

Thanks that helped a lot! The code example is excellent! Thanks a lot
Pages: [1]
 ignore  |  Print

You cannot reply to this message, because it is very, very old.

 SHC (37 views) 2015-08-01 03:58:20 Jesse (24 views) 2015-07-29 04:35:27 Riven (44 views) 2015-07-27 16:38:00 Riven (24 views) 2015-07-27 15:35:20 Riven (27 views) 2015-07-27 12:26:13 Riven (18 views) 2015-07-27 12:23:39 BurntPizza (39 views) 2015-07-25 00:14:37 BurntPizza (48 views) 2015-07-24 22:06:39 BurntPizza (33 views) 2015-07-24 06:06:53 NoxInc (40 views) 2015-07-22 22:16:53
 theagentd 50x wessles 49x basil_ 33x KaiHH 26x orangepascal 25x Riven 22x ags1 18x mooman219 17x bornander 15x KudoDEV 13x princec 11x pquiring 11x CelestialCreator 11x klaus 10x Jesse 9x Spasi 8x
 List of Learning Resourcesby gouessej2015-07-09 11:29:36How Do I Expand My Game?by bashfrog2015-06-14 11:34:43List of Learning Resources2015-05-31 05:37:30Intersection Methodsby Roquen2015-05-29 08:19:33List of Learning Resources2015-05-05 10:20:32How to: JGO Wikiby Mac702015-02-17 20:56:162D Dynamic Lighting2015-01-01 20:25:42How do I start Java Game Development?by gouessej2014-12-27 19:41:21
 java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org