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 (653)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [Update] fixed: Tile Map Design Problem  (Read 1579 times)
0 Members and 1 Guest are viewing this topic.
Offline SonicPixelation

Senior Newbie

« Posted 2012-10-22 02:28:20 »

I have been working on a Puzzle game,(basically its Like Portal in 2d). the main Ideas is going to be to get a Box on a button so that you can get out the door. But I ran into a design problem with the Tile engine. How its works is it calls entities from an array in the Tile file so as to get there id's and then compairs them to a .txt file to see were they go.

I designed the Door and Button to be Tiles and then I would use another Tile called wireTile. basically it calls every tile of one sort through the same class, so I cant have a perminiate x, or y to any Tile. Do you know anyway to give each tile a more permintate position?

here is my Tile and level code.
Offline actual

JGO Coder

Medals: 24

« Reply #1 - Posted 2012-10-22 03:01:02 »

I'm not sure that I entirely understand your question but what I *think* you are asking is how can you give things positions if they are moving around? (Notice how me not understanding you doesn't stop me from answering Smiley ). Can you explain your problem in a little more detail.

1. You have x,y coordinates but those look to be for rendering. Why not add the x,y coordinates of the level to each tile. So your set tile looks like:
public void setTile(int x, int y, Tile tile){
     int id = map[y][x];
     Tile.tiles[map[y][x]] = tile;

2. What are your entities and is there any reason you keep a separate array of the level rather than adding them directly to the tile/

Offline SonicPixelation

Senior Newbie

« Reply #2 - Posted 2012-10-22 03:12:56 »

Ok ley me try and explain this a little better. The problem I was having is the wiretile in the map is used like 20 time so far but it calls all 20 of them through one class. I want it make copy's of every wiretile so that I can have perminate x and y cords for each tile instead of them swarming through one class per tile. So basically my code to the wire was plans to be something like if(level.getTile(x-1,y).powered) powered = true;  the x and the y would be the tiles position so this would look at the tile to your right to see if it's powered and if it is it would turn on too.

I hope this helps.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline actual

JGO Coder

Medals: 24

« Reply #3 - Posted 2012-10-22 03:46:41 »

It helps but can you show your code for WireTile?. And can you post the snippet of code where it is calling it "20 times through one class"?  I am confused about some things in your code. It may not be relevant but it might be. Why do you have these static members in Tile?
public static Tile[] tiles = new Tile[25];

public static Tile SolidTile = new SolidTile();
public static Tile EmptyTile = new EmptyTile();
public static Tile CheackPointTile = new CheckPointTile();
public static Tile ButtonTile = new ButtonTile();
public static Tile DoorTile = new DoorTile();
public static Tile WireTiled = new WireTile();

Also, why in your level update method are you updating the tile array within your Entity loop? Sorry for all of the questions but sometimes it can be hard to follow another person's code.
Offline SonicPixelation

Senior Newbie

« Reply #4 - Posted 2012-10-22 05:32:09 »

Just some quic clarifacations the static tile list was there from my old tile referance system. But I am not compleatly sure the new one is good so I left the code laying around. As for the calling it 20 times that occors in the render method when it's getting the tile. The get tile method calls from a 2d array that was loaded from a txt file, basically what I ment was that I have 20 wiretile recorded to the array. And the tile updating inside the entity loop was amistake :p. sorry for all the extra guff in my code I am not the neatest programer.

So from what I gather I need to set the tile Pos. in the set tile method. I am not sure if this is what you mean or maybe you have something better in mind. Thank you for all the help.

This is basically it when it comes to the wire tile. But I removed the power checking didn't work in the first place.
Offline SonicPixelation

Senior Newbie

« Reply #5 - Posted 2012-10-22 20:24:02 »

basically to sum it up I want to make a instance of every tile that appears on the screen, because as of now it is making one instance per tile type so the x and y cores for any given tile are the last occurrence of that tile in the map. so what I want to do is every time a tile is set at the start it makes a new version of it.

you responses would be greatly appreciated.
Offline SonicPixelation

Senior Newbie

« Reply #6 - Posted 2012-10-22 23:00:06 »

ok I fixed it, what i needed to so it turn the change the getTile method into getTile(int x ,int y) and the Tile class init's the x and y.

thank you for all the help.

Hopefully the game will be done soon.
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

SHC (27 views)
2015-08-01 03:58:20

Jesse (19 views)
2015-07-29 04:35:27

Riven (40 views)
2015-07-27 16:38:00

Riven (21 views)
2015-07-27 15:35:20

Riven (24 views)
2015-07-27 12:26:13

Riven (14 views)
2015-07-27 12:23:39

BurntPizza (36 views)
2015-07-25 00:14:37

BurntPizza (46 views)
2015-07-24 22:06:39

BurntPizza (30 views)
2015-07-24 06:06:53

NoxInc (37 views)
2015-07-22 22:16:53
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21 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‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!