• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Josip Mati?

Battle City clone - need little help

3 posts in this topic

Hello again everyone

I've been silent for last few months and stopped my project due to various things (one of them becoming lazy after getting stuck at one point).
Few days ago I resumed working on it... and oh boy, working(!) features are starting to snowball one after another. Now, while progress is going on, I started to think about future improvements and several (higher level) questions appeared. Done with C# + XNA.

Please ask if you need any code, I currently don't know what to offer except for whole project. Also ask if there is anything unclear or that is not easily understandable, it's a bit hard to put in words what I exactly want.

This is how it looks currently:
[sharedmedia=gallery:images:2885]

Summary: metal tiles (and currently bricks) are indestructible, water is unpassable by tank but bullets fly over it, grass obstructs vision, blue tanks are AI controlled opponents, orange and green tanks are Player 1 and Player 2 respectively, 2 collided bullets disappear, non-allied tanks are destroyed when hit by allied bullet and instantly respawned.
Moving is restricted to 4 directions only; tiles and hitbox' are simple rectangles (a*a for tile and tank, a*b for bullet). Tiles and tanks with their bullets have their own separate class; each type of tile and tanks are stored into separate arrays.

So, the questions are:

1) Well, this one was quite hard for me to put into words. I already rewrote most of the code once (moved tanks and tiles to separate classes etc) and apparently I'll need to do it again - better right now white it isn't cluttered. Are there some tips on improving interactions between elements, adding new classes, detecting useless/redundant code etc. - in short, tips for writing a good code? I want to make that this project performs efficiently while having as much readable and adaptable code as possible.

For example, how can this:
[CODE]
// Definitions
public void MoveTank(bool HorAxis, int direction, bool cancel);
bool Collision(Rectangle Object, bool Projectile, string Direction, bool playerOwned);

if (Keyboard.GetState().IsKeyDown(Keys.Left))
{
Tanks[0].MoveTank(true, -1, false);
if (Collision(Tanks[0].TankHitbox, false, "Left", true)) Tanks[0].MoveTank(true, 1, true);
}
else if (Keyboard.GetState().IsKeyDown(Keys.Right))
{
Tanks[0].MoveTank(true, 1, false);
if (Collision(Tanks[0].TankHitbox, false, "Right", true)) Tanks[0].MoveTank(true, -1, true);
}
else if (Keyboard.GetState().IsKeyDown(Keys.Up))
{
Tanks[0].MoveTank(false, -1, false);
if (Collision(Tanks[0].TankHitbox, false, "Up", true)) Tanks[0].MoveTank(false, 1, true);
}
else if (Keyboard.GetState().IsKeyDown(Keys.Down))
{
Tanks[0].MoveTank(false, 1, false);
if (Collision(Tanks[0].TankHitbox, false, "Down", true)) Tanks[0].MoveTank(false, -1, true);
}

if ((Keyboard.GetState().IsKeyDown(Keys.Enter)) && (Tanks[0].BulletLaunched == false))
{
Tanks[0].LaunchBullet();
}
[/CODE]
be rewritten into something better and more clear? (Answer on my mind: using switch instead of multiple if..else)

2) Can you recommend me some AI algorithms which could be useful for this? Current one is somewhat recreated by observing original NES game of the same name (some people may better know it under name of Tanks) which still needs to be fine tuned. It uses chance system of changing directions (almost 100% chance to keep current one, if collided with something selects between other 3 directions equally) which gives somewhat chaotic movement.

3) I need to implement destructible brick wall. My idea is to split a tile hitbox into 16 equal pieces and process collision with 2 or 3 closest adjactent pieces. Is that good solution, will it tax processing power and memory and do you have other suggestions?

Thank you very much for reading [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] Edited by Aurioch
0

Share this post


Link to post
Share on other sites
OK, shameless bump.

This time I have more concrect questions. I hope that someone can answer, either with idea, pseudocode or C# code.

For questions 2 and 3, I provided source code. I hope it is readable enough :/ Comments about code appreciated.

1) I plan to add proper main menu screen, game over screen etc. I've downloaded Microsoft's Game State Manager project and currently I'm examining it, but can still someone tell me general idea about it? It WILL take some time until I get a hang how to execute it from Microsoft's code :/

2) In my own class, can I somehow access declared variable of another class without passing it by reference? To be more precise (check source code), I'd like to update status of one of the Tanks declared in main class from my Player class, calling Collision method from Game1 class. Should I declare new variable of class Game1 inside Player class to handle that?

3) How (if possible) can I save some settings (like keyboard keys for controlling tanks) without using .txt file?

Also, I offered current version of the game for playing [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] Feedback is appreciated. Is the game fun/good in its current state?
Also, you'll notice level1.txt in folder. Try editing a level a little with Notepad.

There are 2 problems with it:[list=1]
[*]On Victory and Game Over, it's unable to restart (don't know how to perform it. Call Game1.Initialize again?). To restart, simply run whole program again.
[*]... after short thinking, I decided to not tell about this one. Just know that I know about it and I've fixed it already. See what happens when one player runs out of lives.
[/list]
Also, for test purposes, F1 and F2 has their own functions as well. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] Just use them before one of players loses all his lives.
0

Share this post


Link to post
Share on other sites
This is without having checked out your source code yet, so bear with me. :)

1. Game states handled like MS's Game State Manager are based on the object-oriented programming concept polymorphism. It allows you to create a base class (GameScreen) and then build a manager that knows how to use GameScreens. Each of your screens (MainMenuScreen, GameOverScreen, etc) inherit from GameScreen. What this allows is for your manager to be capable of managing these screens even though it knows very little about the inner details of them. The manager doesn't care what each of these screens does, as long as it has the pieces (methods) that the manager expects.

This idea allows the manager to have a list (or any grouping or collection) of GameScreens and know that it can call certain methods (because the fact that they either ARE a GameScreen or INHERIT from a GameScreen (which means they are a GameScreen)) means that they provide an implementation of the methods in GameScreen (they may have a default implementation provided by GameScreen itself or they may provide their own implementation). So even without knowing anything about, for example, your GameOverScreen, the manager knows that it can call .Update() or .IsActive() on it because to be in this listing it either is a GameScreen or inherits from one.

Getting a good grasp of polymorphism is a big leg up in understanding the concept(s) involved there.

2. There are ways for you to get access to the variables of another class. Exactly HOW it should be done is more a question of design. You should not create a Game1 variable in the Player class. A Player shouldn't need to have a Game1 to function. Your example mentions handling collision. That is function that would be better handled in your Game1 class (the class that knows about the players and the enemies; the things that can collide) than in your Player class. Inside both the Tank class and Player class, you could have a method named something like .GetCollisionRectangle() that returns a rectangle that tells what area of the world or game board that that Player or Tank is currently occupying. Then the game could check those collision rectangles to determine if there is a collision.

3. In order to save settings between game play sessions, you will have to persist or serialize that information somehow. Be that in a .txt file or a database or .xml file or .json or whatever other format you'd like to use or make up. But as for the base idea, yes, you have to save that information out to somewhere when/before the user quits the game and then load it back in when the game starts back up.

As I mentioned before, I haven't downloaded yet so I can't provide any feedback on the game's current state.

Good luck.
1

Share this post


Link to post
Share on other sites
Thanks for answers :)

For 2 and 3, yeah, I already implemented that (or plan to implement in case of saving settings), I was just wondering if there's better way to do it.

About Game state management, I was examining Microsoft's example with having Your explanation in mind, so, if I understand correctly, I need to do this:[list]
[*]Create base ScreenManager class based on DrawableGameComponent which will have a list of GameScreens and take care of proper updating
[*]Create abstract GameScreen class with appopriate properties and overridable methods which will be used as a basis for all screens
[*]Create a new class for each part of the game, inherit GameScreen class and override its methods as fits
[*]In main Game, initialize ScreenManager and pre-load everything needed
[/list]
So much work XD I'll need about a week to make it work... after that, adding new game screens should be easy :/ I even wonder if I should start new project and just copy what I can into that new project.
Oh well, time to study more on my own since I won't learn about this on college :/
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0