Josh-CO Dev

Solving the worlds problems one line of code at a time.

Leave a comment

Why not to use the “delete before publishing feature” in Visual Studio

So, I learned an important lesson yesterday, I narrowly avoided wiping the entire site so far. Not that I have a whole lot of content yet, but it would have been a bit heartbreaking to say the least. I am working on a personal project that involves setting up a subdomain on this site that will host a silverlight application. My web project is set to delete all files and replace them when I perform a publish. Well, I am troubleshooting some issues with a WCF service and posted some files in my root directory. A couple of mistakes later and I accidently tried to publish my project to the root drive rather than the folder that houses my subdomain. Many of my folders and all of my files were wiped from the root directory. Thankfully, I happened to have a backup of most of the files and most all wordpress content is housed in the database. Talk about a rough lesson to learn!


Leave a comment

XNA RPG Tutorial

I found an interesting tutorial over at XNAGPA that has been keeping me occupied for the last week or so. The think that I am enjoying the most about this tutorial is that it really focuses on what happens behind the scenes and everything seems to be really well thought out. I have followed many tutorials and find that many of them only teach one thing. Then you have to figure out how to incorporate them into your projects. This seems to be particularly difficult with things like a good Game State Management System . You have to start your project with this in mind or it is a complete bugger. These tutorials walk you through game states, incredibly good object oriented layouts, gui components, etc. I feel I have learned more from these tutorials in the past week than I ever have in my XNA studies. I plan to post some more projects up later after I have completed more of these tutorials. I have a neat Silverlight side-project in mind.

Leave a comment

XNA – Animated Sprite Engine

So, the next thing that I wanted to learn was animating sprites and creating some base classes for them. I ran across a great tutorial at XNA Resources that did the job wonderfully. I have spent the past couple days going through the tutorial and making sure that I understand all of it. It seems like it may be a bit excessive, but I would rather have too much functionality than too little. I have zipped up the project I created off of it for anyone that may be interested in it. Next, I will be following a couple of tile engine tutorials and will either turn them into a platformer or adventure type game.


Leave a comment

Delphi Source Control and Versioning

One of the things that never fails to cause me a headache is versioning and source control in Delphi. The company I work for uses Delphi 7, so we have to manually use Visual Source Safe for our source control. Unlike a newer tool, like Visual Studio or even RAD Studio, there is no integration with any source control environments. What this means is that we have to handle source control by hand. We perform monthly releases on our main system in Delphi and generally do not do any rollouts outside of this monthly releases. What is a huge pain is when an issue arises and you have to perform a rollout outside of this monthly release. For Sarbanes Oxley and other government regulations, we cannot let unapproved code move to production. This means that we have to manually backup all of the changes that we have made for the next release and pull old code out of visual source safe and recompile. If you are working on a large release, you will inevitably forget to back something out and it will slip to production. What would be great is if there was a versioning tool that allowed you to revert back to a previous state without having to manually perform all of these processes. Here’s to looking to the future!

Leave a comment

XNA – Adding a Jumping Sprite

The next logical step in my project was to figure out how to make a sprite jump. I followed George Clingerman’s tutorial HERE and modified it a bit. I didn’t like that it kept making you jump along the path that you started, it just felt a bit fake, so I removed the jumping state and modified the code a bit. See the code below for the bulk of the logic.
Continue reading

Leave a comment

XNA – Code Example. Moving a Sprite with Scrolling Backgrounds

So I decided to upgrade my project last night and add sprite movement. The ability has been added to control a sprite, left and right only, on the screen along with the scrolling background. If the character sprite reaches 150 pixels from either side of the screen, the sprite movement will halt and only the background will scroll. The next step is to implement some basic jumping. Then I think a tile engine needs to be built to handle ground objects, and then some gravity to hold the character on those objects. The background logic still needs to be seperated off into a different class as well.

The biggest changes here are that we upgraded the sprite class to handle some additional methods. We also added an inherited class hero to handle the main character. The biggest chunk of logic is as follows:

Continue reading

Leave a comment

XNA – Code example. Scrolling Background on Keyboard Movement

One of the things that I am trying to work up to is writing a scrolling platform game. I decided to write a demo that would scroll the background on keypress and found that it was fairly easy to do. Here is an example of the update code that I used and I am also putting the solution in a zip. It could stand to be more object oriented, but it can be tidied up later. Next step will be to make the sprite move and the background only scroll when the sprite is near the edge of the screen. This is an extension and some customization on top of the tutorial found here: Scrolling 2d Background

// Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)

KeyboardState keyState = Keyboard.GetState();
string leftOrRight = null;
Vector2 aDirection = Vector2.Zero;

if (keyState.IsKeyDown(Keys.Left))
leftOrRight = “left”;
else if(keyState.IsKeyDown(Keys.Right))
leftOrRight = “right”;

// TODO: Add your update logic here
switch(leftOrRight) //if moving right the bg needs to move left
case “right”:
if (bg1.position.X < -bg1.size.Width)
bg1.position.X = bg3.position.X + bg3.size.Width;

if (bg2.position.X < -bg2.size.Width)
bg2.position.X = bg1.position.X + bg1.size.Width;

if (bg3.position.X bg1.size.Width)
bg1.position.X = bg3.position.X – bg3.size.Width;

if (bg2.position.X > bg2.size.Width)
bg2.position.X = bg1.position.X – bg1.size.Width;

if (bg3.position.X > bg3.size.Width)
bg3.position.X = bg2.position.X – bg2.size.Width;

aDirection = new Vector2(1, 0);

Vector2 aSpeed = new Vector2(130, 0);

bg1.position += aDirection * aSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
bg2.position += aDirection * aSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
bg3.position += aDirection * aSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;


Get the full code here: Scrolling 2d Background with Keypress Example