XNA – How to check if mouse or keyboard button has been clicked, pressed or released


I was reviewing some of the search terms that brought people to my website. It seems like a lot of them are related to using the mouse in XNA, so I figured I’d write a quick post about determining the mouse or keyboard state in XNA, though this applies to most anything that polls input and has a main loop.

Read the rest of this entry »

Fondusi’s Dev Blog – Week 6 – Part 1 – C# Sockets and Servers


This week we spent some time doing little things – fixing bugs, changing how things look, etc. We also started work on the networking code which is what I talk about in this post. I discuss the beginnings of the TCP multi-client server application with actual code examples and descriptions.

Read the rest of this entry »

Fondusi’s Dev Blog – Week 5 – Lighting and Spatial Partitioning


This week we managed to get a lot of things done. Andrew did a lot of work on the region editor and I added some cool new features and fixed bugs in the lighting system.

This post covers changes to the lighting system and spatial partitioning/hashing. I go in-depth on how to use spatial hashing to not only cut down on the amount of things drawn, but to draw only the things that can be visible on screen.

Read the rest of this entry »

Fondusi’s Dev Blog – Week 4 – Lighting and Shaders


This week we focused on getting the lighting system working in the tile engine. In order to do this, I had to change the way the tile engine was being rendered. Read on to see how we did it and how it looks.

Read the rest of this entry »

Creating Render Targets in XNA 4.0


While working on the game engine for Fondusi’s, I had to change how my tile engine was rendered in order to add the lighting. At first, all tiles were just rendered directly to the screen (back buffer, actually) but with the lighting, I was tweaking pixel alpha values and it ended up causing issues with stacked tiles. So, what I needed to do was to draw my tiles on one surface, draw the lighting on a second surface, and then draw the lighting surface onto the tiled surface with it’s own pixel shader effect. (Really, I just sample the lighting surface in the pixel shader while drawing the tile surface to the back-buffer.)

In order to draw it like that, I had to add new render targets. Now, I was following a blog post on Shawn Hargreaves’ Blog which was (quite!) out of date. So needless to say, I had a few issues implementing it the same way. Fortunately, they’ve made it a lot easier to use render targets in XNA 4.0 and that what I’m going to show you below.

Read the rest of this entry »

Fondusi’s Dev Blog – Week 3 – Tile Behaviours


This week we got some of the extra mapping tools working like the paint bucket and the eye dropper, which allows you to select a tile from the map (so you don’t have to find it on the tilesets). We also set up “tile behaviours” (read the full post for more info), added the ability to switch between player mode and camera control, added some validation functions for mouse clicks on the game from (see here for more details), added an outline for the player name font, and did an overhaul of the particle engine system to make it more generic and useful.

Read the rest of this entry »

Fondusi’s Dev Blog – Week 2 – Pixel Shaders and Moving Players


The second week of development was spent reorganizing the map editor and fleshing out more-or-less how we wanted it to look and function. We added a basic pixel shader effect file and changed how players move across tiles, which I discuss in more detail in the full post.

Read the rest of this entry »

Fondusi’s Dev Blog – Week 1 – Tile Engine and Map Structure


Assuming you’ve read up on the first post, it’s time for the first (back-logged) Fondusi’s Development Blog weekly post.

Week 1 – August 1st – 7th

Note: We decided to start out making the map editor so we could get the tile engine up and running quickly before we needed the server, client or networking code. So, until further notice, all posts relate to developing the map editor.

This week I set up the solution’s main projects and began work on the tile engine. I based the map layout on the old game’s map objects and added new capabilities as I saw fit. The major new addition was using map layers. Basically, this is like having two maps stacked on each other. There are special tiles that allow the character to switch between layers. This means we can do things like allow players to walk over other players on bridges or have a house with two floors on the same map.

Read the rest of this entry »

Fondusi’s Dev Blog – The Beginning


So, I figured that since no one (from Fondusi’s) reads this, it’s probably safe to start writing about our development progress on the new version of Fondusi’s. My plan is to write a blog post once per week (hopefully on Sunday) that sums up the development progress that we’ve done during that week. We’re in our fifth week so I’ll have to do some retroactive work.

Before I get to that, however, a little back story:

About 7 years ago, maybe more… sometime around 2004 anyways, I was a teenage (wanna-be) programmer who thoroughly enjoyed 2D, SNES-like RPGs. Especially the online one’s like Graal, Deloria (RIP <3) and all those Mirage, Elysium, etc. projects. And so it was that I decided to make my OWN 2D, online, SNES-like RPG. So I started messing around with those Mirage/Elysium type VB6 game engines. After Deloria died, there were a few clones, the main one (as I recall) was run by GodSentDeath (GSD) and DarkAngel (or whatever the heck Frank’s alias was). Somehow I got the source to this game after GSD stopped working on it and did a bit (very bit) of work on it. Eventually, I took that source and built it into what Fondusi’s was 1.5 months ago. After weeks, months, years of work. VB6 just wasn’t cutting it. I figured, “Hey, I’m a good programmer. I’ll just recreate the engine.” If only I had known about source control back then…
Read the rest of this entry »

XNA – Converting from angle to Vector2 and back


I was recently working on an XNA project and needed to convert from an angle to a Vector2. There are a lot of resources showing how to go one way (angle->Vector2) or the other (Vector2->angle) but not many showing both. So, I figured it might be helpful to put it up here, even if I only use it for reference.

Angle -> Vector2

Now, the reason I make the Y value negative is because that’s how the screen coordinate system works. If you didn’t do this, the angle in radians would go clock-wise instead of counter-clockwise.

Vector2 -> Angle
Read the rest of this entry »

Latest Posts



Post Calendar

November 2014
M T W T F S S
« Sep    
 12
3456789
10111213141516
17181920212223
24252627282930