Saturday, February 14, 2009

Old XNA Source

As requested by Luca, here's the source code for the old XNA version before I decided to port it over to C++. The zipped folder includes both the source for the game and the level editor, both of which are somewhat buggy.

Don't expect much from it in terms of coding as I was still learning the ins and outs of C# and the XNA framework at the time.

Nevertheless, here it is:
Generic XNA Source & Level Editor

As for the game's current progress, everything has pretty much come to a halt for the time being due to college. I'll probably be able to squeeze in some work here and there, but I won't be able to get much done until the semester is over.

14 comments:

  1. Phil, thank you very much for your contribution to the XNA community!
    Despite your concerns, I will surely learn much from your code, as your game is absolutely amazing!
    I really hope you find the time complete this project (not hurting your studies, of course :-).
    Best regards,
    Luca

    ReplyDelete
  2. Thanks so much for sharing this it has been very useful to me. :)

    Quick question about the level editor: Where do you place the doors to get them working correctly ingame?

    I've managed to get the editor to save and load using the games level format (since it was slightly different) and get everything work except the doors correctly. I can make a door in room 1 go to room 2 but not vice versa. Any hints would be extremely welcome. Thanks :)

    ReplyDelete
  3. The way the doors work is a little complicated, and I probably could have done it much MUCH better than it is right now.

    First thing, the room filename has to be 'roomAreaX' where X is a number (ie: roomArea0). This can be changed in the code, however.

    When placing a door, there are some variables you need to fill:
    Room Destination - what the next room is. The value for it should be the 'X' value of the room destination's filename. If the next room's filename is roomArea1, then the value should be 1.
    Width/Height - self explanatory. I don't remember if the doors that link to each other need to be the same dimensions. If you're using the Generic XNA code, then I think they need to be the same.
    Match String - the string value that actually links the doors together. This should be the same for both doors.

    Quick Tutorial:
    Create two rooms, roomArea0 and roomArea1. In roomArea0, create a door with destination set to 1 and match string as 'A'. In roomArea1, create another door with destination set to 0 and match string as 'A'.

    NOTE: This only works for Generic since this was the way I had set it up (yea, I know. It sucks :P).

    ReplyDelete
  4. Cheers for that it worked. :)

    ReplyDelete
  5. No updates for a while for obvious reasons, any chance of play of your new c++ version?

    ReplyDelete
  6. Sorry for the lack of updates, I've been busy with an independent study project for college.

    As for a preview, I'm hoping to release one some time soon as there are some kinks to work out. It'll probably be very short though (10~20 mins?) since the game itself isn't going to be some 3+ hour adventure.

    ReplyDelete
  7. I've managed to get this working in Visual C# Express 2008 and XNA 3.0, but the audio is giving me problems. The WAV files are there, but the XNA format soundbanks and such aren't. Any chance that you could fix this?

    Also, what's the license on this? Is it free to use on personal projects? Commercial?

    ReplyDelete
  8. I don't know if I can do anything relating to the audio problem since the last time I used XNA was with version 1.0. Sorry.

    As for license, feel free to use any part of the game for your personal projects. I'm hoping the source code is actually useful to some people.

    ReplyDelete
  9. I've done the same as Dante. I made my own editor from scratch, made the room files all xml based and redid the collision code so it nolonger needed the Solid class. I also redid the switch code, coverted the destructable blocks to tiles you could destroy and changed the key based blocks to enemies (of a sort).
    But I've had massive issues with my new slope tile collision so I've started my own game from scratch heh. :)

    ReplyDelete
  10. BTW Dante you should use the new SoundEffect class for your sound effects, and the MediaPlayer + Song class for any music you want. Those were both new to XNA 3.0 and alot easier to use than the old XACT Audion Engine stuff.

    ReplyDelete
  11. I've managed to get the audio to work, just had to substitute something for the missing run.wav and build the files. Now I'm trying to get gamepad support to work, but my buttons are either repeating or not working at all. I defined public statics for the gamepad just like the keyboard, and now I only get walk (no run) and no button responses.

    for ( int i=0; i < 2; i++)
    {
    Game1.state = GamePad.GetState((PlayerIndex)i);
    Game1.oldstate = GamePad.GetState((PlayerIndex)i);
    if (Game1.state.DPad.Up == ButtonState.Pressed)
    KeyUp = true;
    if (Game1.state.DPad.Left == ButtonState.Pressed)
    KeyLeft = true;
    if (Game1.state.DPad.Right == ButtonState.Pressed)
    KeyRight = true;
    if (Game1.state.DPad.Down == ButtonState.Pressed)
    KeyDown = true;
    if (Game1.state.Buttons.Start == ButtonState.Pressed)
    KeyStart = true;
    if (Game1.state.Buttons.A == ButtonState.Pressed)
    KeyJump = true;
    if (Game1.state.Buttons.X == ButtonState.Pressed)
    KeyAttack = true;
    if (Game1.oldstate.DPad.Up == ButtonState.Pressed)
    KeyUpOld = true;
    if (Game1.oldstate.DPad.Left == ButtonState.Pressed)
    KeyLeftOld = true;
    if (Game1.oldstate.DPad.Right == ButtonState.Pressed)
    KeyRightOld = true;
    if (Game1.oldstate.DPad.Down == ButtonState.Pressed)
    KeyDownOld = true;
    if (Game1.oldstate.Buttons.Start == ButtonState.Pressed)
    KeyStartOld = true;
    if (Game1.oldstate.Buttons.A == ButtonState.Pressed)
    KeyJumpOld = true;
    if (Game1.oldstate.Buttons.X == ButtonState.Pressed)
    KeyAttackOld = true;
    }

    ReplyDelete
  12. thanks for sharing the sources. I doubt i'll ever code any XNA game, but i'm always eager to see how one address the odds of game engine programming ...

    ReplyDelete
  13. Thanks, I love your game, the art is awesome. It really has that cute, colorful and old school feel I like.

    Will your new C++ sources be released too ?

    ReplyDelete
  14. Hey, I know this is a bit old, but do you still have your XNA source lying around somewhere? I'm really interested in seeing how you handled player input.

    Your DL link was on MegaUpload so it's not working anymore sadly.

    ReplyDelete