Posts Tagged ‘XNA Game Studio’
Since I didn’t want to rewrite a whole bunch of code next weekend, I decided to tidy up and release this bunch of code.
It’s some helpful code that allows for easy sprite handling in XNA 4.0.
-Easy sprite creation (just CreateSprite(name, position) and it’ll automatically render it from that point on)
-Changing position, scaling, rotation is also easy
-Depth system where deeper sprites are always rendered behind less deep sprites
-Automatically loads the Content/Graphics folder for you so you can just refer to the images by name
-Basic layered sprite support (multiple sprites combining to make one sprite, for example a base body with armor and a weapon overlaid on it)
-Basic animation support
-Licensed under Creative Commons Attribution 3.0 Unported, so you’re free to modify it or use it commercially
Code includes a simple example project.
How it works
-Create a folder ‘Graphics’ with at least 1 image in it in your Content folder. The folder or any of its subfolders must not contain any non-graphic files.
-Put a SpriteFont in your Content folder with the name ‘Default’. It will be used as font for GTexts and the log.
-Call SpriteEngine.Initialize in the constructor of your XNA game class (note that it MUST be in the constructor, NOT in Game.Initialize()), after setting Content.RootDirectory.
-Call SpriteEngine.LoadContent in the LoadContent method of your XNA game class.
-That’s all the initialization it needs. Call SpriteEngine.Draw in your Draw method to actually have it do something. Note that it does not clear the screen for you; keep GraphicsDevice.Clear in there.
-If you want to use animations or ‘camera scrolling’, call SpriteEngine.Update in your Update method.
-From now on you can use SpriteEngine.CreateSprite to create sprites in your game. It returns a sprite object, which you can use to change its position, rotation, image, etc. Use SpriteEngine.EraseGObject to erase a sprite, or SpriteEngine.Nuke to erase everything.
SpriteEngine – Main class. Most of the functions you need will be in here.
GObject – Base class for displayable objects (Sprites and GTexts). Contains basic information like position, scale and depth.
GText – A displayed string that can be moved around and has a depth, much like a sprite.
Sprite – Class representing a sprite, containing basic information such as its position, images, rotation, scale, etc.
LayeredSprite – A sprite composed of multiple sprites. Uses a simple layer system where when the sprite is drawn, all of its sub-sprites are drawn at its location instead.
Details on what each property and method does can be found in comments in the code, I’m too lazy to type them all out.
This work is licensed under a Creative Commons Attribution 3.0 Unported License.
You are free:
* to Share — to copy, distribute and transmit the work
* to Remix — to adapt the work
* to make commercial use of the work
Under the following conditions:
* Attribution — You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).
Have fun, and good luck with your games.
Hello! I am static_boy123 and I just wanted to share my experience in my first LD, and first game, with others:
I found out about this competition last year when Notch(The maker of Minecraft) entered Prelude of the Chambered, I immediately said to myself, ”I will do this next year.” So now I did it, I entered in my first, but not last, Ludum Dare.
I was watching tv one night when something popped into my mind, the Ludum Dare. I checked the website to see when it was, two hours. I ran to my computer and started memorizing my basic -5 file- library inside and out, after an hour I was able to repeat most of it from memory and the rest, thankfully, wasn’t needed. So I waited the longest hour of my life hoping the theme would be kittens.
Once the competition finally started I cursed everyone who voted anti-kitten, opened up handy dandy Visual Studio, and got to work. I typed out what I remembered of my library only two classes, but I was able to make a bunch of edits to one to make a new class. I had lots of trouble starting and coming up with ideas for what to do, but I did the basic things, like changing the screen size and creating the controls for moving.
After an hour of sitting and thinking I had an idea, a game that is more based on story than game play, but still has game play. I sat down and started, I added in textures, added a way to shoot, and realized just how inexperienced I am when it comes to game making.
Coding was crazy, I had tons of road blocks; bugs, bugs, and more bugs. I had to go into untraveled land to create the game, and I also spent plenty of time in well worn territory. Overall my game was very fun and frustrating to make, but it was well worth it.
Now a list of what was good and what wasn’t:
- It was fun
- I learned a lot
- I coded in XNA which I am very comfortable in
- Everybody was very supportive of my first game
- I am happy with my work
- My coding works
- Others enjoyed my game
- The ultra great graphics game “Real Life” didn’t distract me that much
- My entry has two huge bugs
- I didn’t get to finish
- My original texture looked more like a guy masturbating than holding a gun(tip: if this happens move the arm higher on the body and refine the angle :P)
- It was very frustrating
- The story wasn’t clear because it wasn’t finished
- I spent a lot of time doing nothing during the challenge(SLEEEEEEEEP)