Super Doctor Who!

take a look at this :smiley:

If your looking for suggestions, all Enums have a valueOf(String) static method that returns the Enum with that name. Which is what you’re doing. They also have an ordinal() method which returns the position of the Enum (as in from the order in which they were defined). Better that making a String and comparing Strings the whole time.

Please don’t post code that makes me cry. :’(
Here’s a much better way to do what you were doing:


	enum Doctor {
		A {
			@Override
			Doctor regenerate() {
				return B;
			}
		},
		B {
			@Override
			Doctor regenerate() {
				return C; // and so on...
			}
		};
		
		abstract Doctor regenerate(); // you'd call e.g Doctor.A.regenerate();
	}

Nice work though, you’ve done a lot.

In my opinion it’s beautiful:

  • Type safe
  • More performant
  • More object orientated

You should probably explain why. Do you not like the look of it, or how it works?

@Troubleshoots That’s a decent start, but I think it could be improved:


 enum Doctor {
      A, B; 

      private Doctor(){
           //initialization

      }

      public Doctor regenerate(){
           return Doctor.values()[Arrays.asList(Doctor.values()).indexOf(this)+1];

       }
      
   }

Then you don’t have to copy and paste 11 times. Also Doctor.values() should be cached but I wanted to keep it simple. And then if Arrays.asList(Doctor.values()).indexOf(this) returns the last element of the Doctor.values() array then just implement your behavior for whatever happens after 11 regenerations.

I don’t believe you need that for loop.

@SwordsMiner
I don’t see how each doctor becomes the next? Or am I missing something?

You only gave me one file, no amount of looking will find where you’re calling setDoctor.

No. I also wouldn’t recommend talking down to Jimmt, or anyone for that matter. How can you expect us to know your code when we cannot see it?

Swordsminer, this is going great, but I have one complaint about your engine.

XML level format. You really have to get a new level editing idea, because that is just crazy inefficient. You are essentially using 20-30x as much space as you could be if you used standard level saving ideas, like saving a text file full of ID’s. This will result in longer editing time, and longer parsing time.

Hope this helps,
-wes

Adding on to what @wessles said, maybe you should parse levels from an image. It doesn’t take up that much space, and makes it really easy to design levels because you can see what it will look like as you edit it.

0 -> Assign an ID to all tile-types
1 -> Use PrintWriter to write all the corresponding ID’s
2 -> Read it later, and assign a Tile[][] to all of the IDS’s
3 -> Render

Of course, this is a pain to get working if you have no experience with ID based-tiles.

I usually use Doppler Tile Map Editor to edit the maps. I actually wrote a writer and parser for it in my game engine MERCury. You can find it here, if you want. I used it a bit, and it seems fairly clear from any bugs. It is independent, of the engine itself, so you can just take it only, and not the rest of the engine, since you seem fairly opposed to that.

Have a blast,
-wes

I like notches approach in Minecraft. Here is how I use it now:


// Tile.java
public static Tile stone = new TileStone().setId(0).setSolid(true);
public static Tile dirt = new TileDirt().setId(1).setSolid(false);

...

// Game.java
Tile.stone.render(x, y);

It’s basically a hacked up enum that you can do just a bit more with.

But I can’t do everything for you, but I am confident that you can find your way from this point.

Have fun,
-wes

[quote]thats not a tilemap
[/quote]
What do you mean? Are you not using tiles? Do you mean the level you have made so far?

Nice!
One thing you may find… frustrating later on is making a level editor. I mean, it won’t hurt for a bit, but when it does… Ger. That is why I write parsers instead, but go with whatever you want.

Good luck!
-wes

Multiplayer without servers? I don’t know if that’s possible but I would like to not have to forward my ports everytime i want to start a server. I really like the game and idea though. As a huge Doctor Who fan, I commend you on your venture in this game.

Thats still a server and it still has ports… Not to mention you’re severely limiting the player in what they can do. I could care less about playing on LAN, I rarely ever do. LAN parties are fun, but you need both.

And no, not RIP the host. LAN still has a host.

Woah! You got LAN working that quickly?! Demo, please?

re: the map editor.

When I made Metal Blob Solid, my map data would simply be a series of numbers:

0 0 0 0 0
0 0 0 0 0
4 4 4 4 4

0 = empty square
1 = water
2 = slime
3 = lava
4 - 150 = a ground tile
151 - 200 = foreground tile

The map data lived in a multidimensional array:

private final int data[][] = new int[WIDTH][HEIGHT];

The game would then load the tile set, looking for files called 1.png, 2.png, 3.png, etc. It wouldn’t error on a missing tile image, so you wouldn’t need to provide all 200. Creating a map editor for this was very, very easy, as it was just updating a number in a multidimensional array.

Consider doing that, if you’ve not done so already.

I’ve seen this project in the latest posts but never really looked at it. Strange, because I used to watch the show a ton.
I’ll say one thing:
I love the Dalek.

Pretty cool man :point: