Hello, I want to make a game, but before even attempting that I want to get some of the basics of it down and generally have a rather ok\clean code to work from.
What I am basically trying to have is a picture that shows like a world-map, and when you click on some part of the world-map your taken to a new picture showing a bit more detailed information of the area(and so on depending on amount of areas).
The way I'm doing this is to get the x\y coordination from the mouse, and then change the picture to another picture if it is within the coordination, however this would mean I'd need unthinkable amount of if\else statements, especially considering different conditions and states(which is fine, but it seems way too unorganized).
I did try to create a class for each location, however when I did that I didn't manage to neither go back or change to another location(which was another class itself).
So I'm just wondering, is there any cleaner ways to do this then having either a million of functions for each location within 1 class? Or having it all spammed down with lots of if\else's and\or functions in the main class?
one way might be to consider your main map like a grid, and each smaller map fits one of the grid squares.
e.g. main map is (500,500) so make each smaller map (50,50), so you have a 10 x 10 grid
with these smaller maps in a 2D array
lets say user clicks at (246,180), you'd then show the map from array[246/50][180/50]
svein kristian nykaas
Joined: Apr 15, 2012
Good suggestion, but I can't really picture it done that way.
as you can see bellow, that's basically how you travel the "world" and to different locations etc. So need some way to make each location unique, but also generally easily accessable by going back and forth.
"after clicking the mountain"
"after clicking the forest"
"after clicking the cottage in the forest"
Joined: Jun 09, 2003
after looking at the pics, I'd still be inclined to create multiple rectangles around the specific areas,
keeping those rectangles in an array, looping the array to see if rectangle.contains(pointClicked),
if true, show the zoomed image of that location/rectangle.
repeat for the zoomed locations/rectangles.
e.g. you mention a world map, rectangles around each continent, as a starter?
all the way down to the pic of the cottage in the forest, where I'd imagine the only
thing to zoom in on is the cottage, so that would be the only rectangle in that image,
clicking anywhere else would do nothing.
subject: Clean way to change between mutlible pictures