• Welcome to Randomland - The Forum. Please login or sign up.
 
May 02, 2024, 09:15 PM

News:

Get Out, See Green!


General Programming Discussion / Help Me!

Started by Brad, Feb 23, 2012, 03:54 PM

Previous topic - Next topic

Brad

The Player class doesn't hold a heck of a lot at the moment. In fact I could probably do without it...

OK... what about this:

A player IS a character. You load all characters at the character selection screen (which is a class by the way CharacterSelection screen, which is managed by the screen manager). When a player selects a character you pass that character to the constructor of the Player class. The constructor is a copy constructor, it copies all of the variables over which could be considered state, but leaving references for non-state stuff that should be shared (art assets like sprites). This copy constructor would have to do the same thing for each of the CharacterStates of that Character (shouldn't be more than 5 for most Characters).

This leaves you with a Player who cannot change their character until they get a Game Over and a new Player is created (which erases all the Player state like score anyway). Also doesn't work with tag-team like setups... but I'm not planning on every doing that with this anyway.

The sucky part is I have to write a big copy constructor and keep it updated throughout the development of my program so that it stays in sync as I add and remove variables from the Character and CharacterState classes.

It solves my multiple inheritance problems too... as the Character class can inherit from the CollisionObject class. That makes a Player object a CollisionObject as well.

I think that should work...

It kinda sucks working on a project yourself, nobody at work anymore to bounce non-work-related ideas off of. Writing them out on Randomland sort of helps, but it's not really the same ya know.

zourtney

Tell me about it. I have almost no one to bounce ideas off of at work :-/

Anyway, I'm actually a bit more confused now. It seems like you made a case against "Player is a Character". But I am now thinking we have different definitions of Player...

I was considering Player as the program-wide embodiment of the user at the keyboard...ya know, boring stuff like name, join date, leetscore, and favorite pea. If you're talking about an object that in-game object act upon, that's totally different.

Brad

Yes... the Player (when I capitalize it means that is the name of a class, I  guess?) represents a single user playing the game. Not necessarily with a keyboard, and there isn't necessarily only one of them but you get the idea.

The on screen representation of a Player is his/her Character. This is what object's interact with in the game, it's what you see on the screen, etc... In this game the player can have only one of them, they choose them before starting the game and they are stuck with them until game over. So for all intents and purposes the a Character IS a Player... as far as the game is concerned. It's just whether or not I want to see it that way.

Players get created at the same time Characters are chosen. So you have to pass in a Character class to the Player constructor anyway. Whether or not it then passes it down to the base constructor in the Character class or it uses new and instantiates a Character field... I guess it really doesn't make a huge difference.

I don't really need a lot of the benefits I mentioned when making the Player have a Character... I'm not using multiple Characters per player, and you can't change Characters without starting over so you may as well create a new Player object.

Regardless... I've got to have special "copy" constructors in the Character and CharacterState classes. These need to copy all the variables over, including creating a bunch of new objects (because these are "state" related objects) but only referencing shared assets like sprite sheets and sound effects.

So at that point I guess my original question doesn't really matter as much as I originally thought it did.

Brad

I just wasted like 45 minutes in total confusion because I didn't know you had to specify which base constructor you want to use in an initializer list in C#.

So I was calling the completely empty default constructor... Which is really dumb.

zourtney

What are you making? I want to mess with some of the newer C#, Windows8, and WindowsPhone stuff. Unfortunately, as soon as I have a free moment to do it, sleep sounds a lot more enticing than staring confusedly at a computer for another several hours...  :-\

Brad

I am working on an XNA project were I get to program a whole bunch of different game mechanics without writing a bunch of different games. All 2d stuff though not really getting into 3d at the moment because I suck at making models. I suck at drawing sprites too but that isn't as big of a problem in this project.

Basically I am trying to generalize a bunch of different game actions so that I can produce different actions/effects by tweeking some variables.

Allowing user generated content is kinda different in XNA because that kind of thing isn't allowed on Xbox. It works ok on PC though, just a bit different than normal XNA.

I'll post screenshots and go in to more detail when I have a working alpha.

zourtney

Cool, cool. Need a map editor? (just kidding, for old times' sake)

Brad

Heh. I will accept any help offered of course. :)

zourtney


Brad

Anybody seen browserquest yet? An interesting MMO style game in HTML 5 from the Mozilla team. Flash is becoming less needed all the time. Yay for open standards!

zourtney

Since this topic is so vaguely named, I'll post here.

I just downloaded Windows 8 and installed the Developer Tools on my home computer. I've been batting around the idea of trying to make a WP or W8 app. Anyone have any good ideas?

Nick

Oct 31, 2012, 09:20 AM #26 Last Edit: Oct 31, 2012, 09:23 AM by Nick
Really good podcasting apps are few and far between. Even in the rich land of android.  Or perhaps a WP front end of our eventual hiker/trekker review/recommendation system. WP is probably lacking for apps, so take a look at the super popular, yet stupidly easy games from other platforms (ant smasher, anyone? Make it... Arthropod Destroyer! Though I kinda like spiders. But that class includes LOTS of critters; everything from centipedes to crabs.)

zourtney

I just created a Windows Phone dev account. If I make something, I can submit it. If not, I'm out 8 bucks (kinda...).

Brad

I've been researching different development platforms not that XNA is officially dead (I can always continue with Mono of course.) 

What I want is something which can be used for mobile development, which is only going to get bigger in the future. The only downside to mobile developments is that I'm either going to be writing in Java or Javascript. Neither of which are my prefered "I'd do this without even getting paid" programming languages.

HTML 5 would be ideal if it can work cross platform, but I don't know how much of that has been implemented in the various mobile browsers yet. HTML 5 also gives me PC compatibility too and you could even port it to a Windows 8 app.

The main thing holding me back is that it would mean giving up the wonderful OOP world that I have in C# for the spaghetti western world of Javascript.

Thoughts?

zourtney

Mar 07, 2013, 10:41 AM #29 Last Edit: Mar 09, 2013, 08:41 PM by zourtney
Thoughts: no you wouldn't! :) there has been a landslide of great browser-side Javascript frameworks put out in the last year. A few a geared specifically at gaming applications. For general web app stuff, Backbone.js is awesome. I use it every day. I can dig up some more stuff, but JS has become much more grown up lately. The OOP concepts are different, but very much there.