Re: A level format problem
There are a few ways to do this. You could just use a single List (or 2d array, whatever) of tiles instead of parallel data structures (which is a sign of bad design), and each tile contains a boolean value deciding whether or not it's solid as well as how to draw it (an image, drawing code, whatever). Then your walk-through wall would just be a normal wall with the collision boolean equal to false.
I'm not sure what you mean when you ask how to get an Object to spawn another or to get Objects interacting.
Re: A level format problem
Quote:
Originally Posted by
KevinWorkman
There are a few ways to do this. You could just use a single List (or 2d array, whatever) of tiles instead of parallel data structures (which is a sign of bad design), and each tile contains a boolean value deciding whether or not it's solid as well as how to draw it (an image, drawing code, whatever). Then your walk-through wall would just be a normal wall with the collision boolean equal to false.
I'm not sure what you mean when you ask how to get an Object to spawn another or to get Objects interacting.
Well, I guess I could try to get the collision to be part of the main level loading code, as for the object to spawn another, I mean to get my level class/object to place blocks, enemies and the player at certain spots. For the objects interacting, I mean like the player touching, say a coin, and having the coin disappear and add 1 to the coins variable.
Re: A level format problem
You fill a 2d array with game Objects. There is no spawning at that step, you just populate a data structure. During gameplay, you test which cell of the array the player is in, then take the appropriate action based on what kind of game Object is at that location.
Re: A level format problem
Quote:
Originally Posted by
KevinWorkman
You fill a 2d array with game Objects. There is no spawning at that step, you just populate a data structure. During gameplay, you test which cell of the array the player is in, then take the appropriate action based on what kind of game Object is at that location.
So how do you actually list which game object goes where in the array? That's what I'm having trouble with. Do you just type in the object name, like "coin" instead of typing "Rectangle So and so" or "ImageIcon So and so"?
Re: A level format problem
Quote:
Originally Posted by
Gravity Games
So how do you actually list which game object goes where in the array? That's what I'm having trouble with. Do you just type in the object name, like "coin" instead of typing "Rectangle So and so" or "ImageIcon So and so"?
That part is really up to you. You can use some type of text system and read levels from files, or you can procedurally generate levels, or you can hardcode them. That's completely up to you.
Re: A level format problem
Quote:
Originally Posted by
KevinWorkman
That part is really up to you. You can use some type of text system and read levels from files, or you can procedurally generate levels, or you can hardcode them. That's completely up to you.
I'm already using a text based system (I'm loading my levels from a .txt file). I just can't figure out how to call a specific instance of an object/class to be placed at a certain spot.
Re: A level format problem
You aren't going to like this answer, but if you're getting stuck on basic instantiation, then I'd really recommend taking a step back and going through the basic tutorials. I highly suggest taking on something a little simpler than a game engine. Start smaller and work your way up instead of diving right into the deep end. Try doing something like pong or breakout first.
Re: A level format problem
I've already gone through basic tutorials, I just don't get how to call an object from another object. But if you really think it would help, I'll see if there's a basic object tutorial...
Edit: *Realizes that calling other objects is literally as easy as just typing in its name* *facepalm* ...I haven't felt this stupid since I forgot to import the Rectangle package trying to draw a rectangle...