The Game Programming Wiki The Game Programming Wiki
The Official Game Programming Wiki Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sidescroller Design

 
Post new topic   Reply to topic    The Game Programming Wiki Forum Index -> .NET Game Programming
Author Message
Diirewolf
Guest





PostPosted: Mon Jun 05, 2006 12:17 pm    Post subject: Sidescroller Design Reply with quote

Im working on a sidescroller in c# with MDX (managed directx) and i want some info on how to organize my classes in a sidescroller to make it work well... i have tried analysing other codes but they are too long and dont make sense. I am quite fluent with c# and I have already set up a renderer class that deals with directx and drawing... so i need someone to explain how to structure my classes. eg. what classes should there be, what not and which classes should inherit from which and where should i do my collision detection (within which class). These things confuse me... there is also something called a Class Diagram which i dont know how to use so maybe that might help me in some way. Any help would b appreciated!
Thanks!
Back to top
Selt
A.I. Lifeform


Joined: 10 Apr 2006
Posts: 835
Location: Virginia

PostPosted: Mon Jun 05, 2006 7:14 pm    Post subject: Reply with quote

I don't know much about directX, but I think I can help you. The class architecture(thats what the class structure is called) is based on your own prefrence. I usually have a sprite class, where all my other sprites extend from. I usualy do my collision detection in my main game loop, right before all the sprites are updated or move(right after would work to, and is probable better for a platformer). I'm assuming you're not using a game engine, because most of the time the game engine makes you use ceratin classes.

If by class daigram, you mean UML, the click http://pigseye.kennesaw.edu/~dbraun/csis4650/A&D/UML_tutorial/
Back to top
View user's profile Send private message Visit poster's website
workmad3
Bibliotherapist


Joined: 21 Dec 2005
Posts: 6236
Location: Manchester, UK

PostPosted: Mon Jun 05, 2006 8:28 pm    Post subject: Reply with quote

Heh, class diagrams are easy.... draw boxes... these are your classes.... connect the boxes with lines, these are the relationships between the classes. Put writing inside the boxes, these are either the class name or the function/variable names.

If its just for your own peace of mind, just draw boxes for your classes, connect them to keep the relationships straight, and get an idea of each class interface(the methods it exposes publically) and just use it to keep things straight and as a planning tool. Theres no point doing any more on a single man project.

If you are working with more people, then use a UML tutorial to ensure the syntax of the diagram is correct, but don't put too much extra effort in, as it is just an aid to understanding.... if you want a complete and accurate description of the classes, then go and code the classes Wink wink
_________________
God must love stupid people, he made so many.
theraje: 'God doesn't love stupid people, they're just easier to make'
http://sharedillusions.blogspot.com
Back to top
View user's profile Send private message
Diirewolf
Guest





PostPosted: Tue Jun 06, 2006 6:11 am    Post subject: Reply with quote

ok, this kind of helped but im looking for something a bit different. Ok first of all i dont need any help with directx. I have programmed a renderer class which initialized DirectX in one call and has drawing functions. This class is called renderer. My question is what about my other classes. i have a windows form class wchih contains the main game loop and initializatino functinos. ok now this windows form contains an instance of the Renderer class. now my question is what other classes must be in my game. I can guess that i need a player class... and a Map class (to represent the map and background etc.). Ok now where will the drawing functinos be. will i call a Player.Draw(Renderer renderer) and pass the renderer or should i make the position data of the player public so i can access it in the main render loop in my form and draw directly from there. Also how will i make my player and map interact. I have the map data in a List of Rectangles. and i need to check each one of these rectangles if they are colliding with the player rectangle. Where will i do this, will i make all the data public and get it into the main gmae logic loop in the windows form or should i take the player and pass it as a parameter to a collision detectino function in my map class OR should i pass the map to the player and have some collision detectino code there (which is what im doing now but i dont think its the right way of doing it). Can someone tell me how to structure my classes, now u know exactly what i mean by 'structure'.
Thanks
Back to top
Machaira
King Code Monkey


Joined: 01 Sep 2004
Posts: 10702
Location: Abingdon, MD

PostPosted: Tue Jun 06, 2006 12:39 pm    Post subject: Reply with quote

I like to make my objects take care of themselves, thus I would pass a pointer to the objects to have them draw themselves. That's just my personal preference though. I'm sure others would say just expose the objects' position data.

As for the actual classes themselves - Level class, Entity class (the player's character and enemies), and Pickup class (this could be a powerup, Mario-like coin/Sonic-like ring, ammo for weapons, etc). That would probably be sufficient for the basic game. The Entity and Pickup could be derived from a base LevelItem class which contains the position data and graphic to be displayed (for the Entity it would be a frame strip) and functions that all objects use (Draw, Update, etc).

edit: If you're using C# 2005, it has a class diagram tool in it. If not, you're out of luck I guess. Happy
edit #2: I threw together a skeleton project. Check it out here.
edit #3: moved to .NET forum, as this is about code design, not really game design.
_________________
Bored? Head on over to my blog and see what I'm up to.

Microsoft XNA MVP
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Diirewolf
Guest





PostPosted: Tue Jun 06, 2006 7:51 pm    Post subject: Reply with quote

ok thanx for the info, helped a lot. One thing which (i think) u failed to mention was how to do collision checking (more like where to do it).
Lets say for eg. i have a Level class which contains a list of Rectangles that need to be checked if they are colliding with the player. There is the player class also and i also have the Windows main Form where the loop is taking place. How would i get both the player and level data together and do a collision check? Let me know on this please because this is what is confusing me the most.
Thanks again!
Back to top
Machaira
King Code Monkey


Joined: 01 Sep 2004
Posts: 10702
Location: Abingdon, MD

PostPosted: Tue Jun 06, 2006 8:20 pm    Post subject: Reply with quote

Usually you'll do collision as part of the key processing in the game loop. I'll try to update the code with an example tonight.
_________________
Bored? Head on over to my blog and see what I'm up to.

Microsoft XNA MVP
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
supaG
Funky Monkey


Joined: 15 Aug 2004
Posts: 1570
Location: Atlanta, GA

PostPosted: Wed Jun 07, 2006 2:42 am    Post subject: Reply with quote

www.skasoftware.com

The guy who made zombie smashers x has a tutorial with a full source for a side scrolling game with good animation and everything. On the main site on the left it says "Dev" rollover and its the game called DeadPako
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Machaira
King Code Monkey


Joined: 01 Sep 2004
Posts: 10702
Location: Abingdon, MD

PostPosted: Wed Jun 07, 2006 3:54 am    Post subject: Reply with quote

Nice find.
_________________
Bored? Head on over to my blog and see what I'm up to.

Microsoft XNA MVP
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Diirewolf
Guest





PostPosted: Wed Jun 07, 2006 5:31 am    Post subject: Reply with quote

Thx guys, i will check this site out...
Back to top
Diirewolf
Guest





PostPosted: Thu Jun 08, 2006 5:46 am    Post subject: Reply with quote

That game is in VB and i cant understand VB if my life depended on it (i dont know the sytax looks REALLY wierd and noting close to C++ or C#)
That skeleton program kinda helped, if u can get the updated skeleton for me it would be much appreciated.
Thx
Back to top
supaG
Funky Monkey


Joined: 15 Aug 2004
Posts: 1570
Location: Atlanta, GA

PostPosted: Thu Jun 08, 2006 10:00 am    Post subject: Reply with quote

http://www.2dgame-tutorial.com/

Here's one thats C++
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Machaira
King Code Monkey


Joined: 01 Sep 2004
Posts: 10702
Location: Abingdon, MD

PostPosted: Thu Jun 08, 2006 1:00 pm    Post subject: Reply with quote

Diirewolf wrote:
That game is in VB and i cant understand VB if my life depended on it (i dont know the sytax looks REALLY wierd and noting close to C++ or C#)

Google "vb to c# converter" Happy
_________________
Bored? Head on over to my blog and see what I'm up to.

Microsoft XNA MVP
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Ska Software
Postronaut


Joined: 08 Aug 2005
Posts: 47
Location: Home of Saranac Breweries, NY

PostPosted: Wed Jul 12, 2006 4:28 pm    Post subject: Reply with quote

I've been referenced!

Did a double-take. I think that's a first for me.

I think Zomberman might be commented a bit better than DeadPako, but I don't think it really would address the collision detection issue that's at hand... Bomberman movement is very constricted, as we should all remember.
_________________
www.skasoftware.com
blog.skasoftware.com
Back to top
View user's profile Send private message Visit poster's website AIM Address
Machaira
King Code Monkey


Joined: 01 Sep 2004
Posts: 10702
Location: Abingdon, MD

PostPosted: Wed Jul 12, 2006 4:58 pm    Post subject: Reply with quote

Probably less constricted in the upcoming version:

http://games.teamxbox.com/xbox/945/Bomberman-Online/
_________________
Bored? Head on over to my blog and see what I'm up to.

Microsoft XNA MVP
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    The Game Programming Wiki Forum Index -> .NET Game Programming All times are GMT
Page 1 of 1

 



Hosting donated by Grubby Games.

Powered by phpBB © 2001, 2002 phpBB Group