Taking on a Zelda Clone: Part 6

I got a couple hours of free time today, but alas, they did not prove to be as productful as the past few days.

Code
I finally learned how to separate my code across multiple files (thanks, Jeff!) so I did a bit of reorganizing. I’m gonna have to do some big rehauls at some point, I can already tell from how convoluted I have to do a bunch of parameter passing. If only there were a way to make it so C# had globals or something.

Player stuff
I made it so the tomato gets knocked back a little bit when hit. It’s based on the direction you’re facing – I can’t remember if that’s how Zelda 1 does it, I know different games treat this different ways and each way has its own quirks that can annoy players. I’ll look into this later.

I really need to improve the tile collision routines, as right now you won’t fly as close to a tile as you can if a tile is very nearby when you get hit. Also, if you get hit and knocked through a door, wackiness ensues.

Enemies
Most of my work today was spent on enemies. I made it so they don’t drop items 100% of the time, easy enough to do. I simplified the Enemy class a bit, too.

I also made it so that enemies don’t load instantly on a room load – they sort of stay there in poofy cloud form for a few frames. I know Zelda 1 works this way, so now this acts just like that.

Almost forgot that I made it so that each room now has specific enemies assigned to it – no more of this “infinite enemies show up, but only so many at a time” thing. I’m glad I got this part done, although the way I wound up implementing it seemed a little odd – the enemies need a reference to the current room object to do various things while the room object has the actual enemy list. So for a second there there was a chicken and the egg thing going on until I killed the chicken and egg made a chegg instead.

Right now there’s one main enemy action – which is to walk around somewhat randomly. I added some variables to this, and now although most enemies use this same pattern, they wind up acting slightly different. For instance, the mushrooms now move in erratic ways, as compared to the standard style. The blue ghosts tend to prefer longer, straighter movements, I guess slightly inspired by Pac-man 😛

Then I went and tried to add a new type of action – I wanted the eye enemy to stop once in a while, look around, and then do something. It took some ugly work, but I got the code for this working. With some polishing up this code will become the basis for giving enemies more complex movements.

Controllers
I realized it would be nice to be able to play this on a gamepad/joystick, so I tried it out. No luck. It turns out XNA only accepts input from Xbox controllers. I ordered a wired Xbox controller from Amazon, but I really need to find a better way to support generic gamepads. I looked online quickly and tried some stuff, but hit a wall when the C# compiler said it couldn’t find DirectX.DirectInput stuff. I downloaded the latest DirectX SDK hoping that would fix it, but nope.

So for now, it’s still just keyboard only 🙁

Projectiles

Before the day ended, I wanted to at least implement projectiles created by enemies. I decided to give the eyeballs an energy ball they can shoot at the player. It took a bit of working and some really ugly work to get the textures and sound effects to where they needed to go (man, I need to figure out a better system for that) but it worked!

At first the fireballs would sometimes stay still and not fly anywhere, I figured out this is due to lost precision in mixed int/float math. So I just fixed it by using floats for stuff. Now the fireballs fly properly and it’s really cool to see it coming together!

My very first attempt at getting the “make enemy create an object” thing to work resulted in a nice surprise – coins everywhere! This was before I created the fireball object, so I was using coins as a stand-in. I just didn’t expect so many!

Music
I thought I’d try adding some 3D Dot Game Heroes music to this build just for fun. Again, someday I’m gonna have to learn music, I can’t steal existing stuff forever 😛

Graphics


To try to get some inspiration for tile graphics, I looked at screenshots from BS Zelda, the SNES remake/port of Zelda 1. It was very informational, and I shamelessly copied some of them for the graphics used in the graveyard screen of this build.

It looks nice, but then you walk up into the desert room and it’s like, “Ugh, this is like a Windows 3.1 game made in MS Paint and by an eight year old.” I feel so many XNA games on Xbox Live are like that, I want to avoid that as much as possible. So I’ll need to study more pixel art in the future.

Thoughts
Probably won’t have much time tomorrow for this stuff, but we’ll see. I keep putting off the better movement stuff because I need to do so many major rehauls to various systems. I don’t want to lose my steam just yet though, I know once I start on a rehaul it’ll suck a lot of the fun out of the project.

I also thought I might’ve come up with a decent way to do the screen transitions, I’ll have to ponder it some more. For now, sleeps!

Download

Both comments and pings are currently closed.

2 Responses to “Taking on a Zelda Clone: Part 6”

  1. blahmoomoo says:

    You can have global variables in C#… in a sense. You can make a class that only consists of public static variables (static means there’s only one of them, and they belong to the class itself rather than an object of the class) and reference them with ClassName.StaticVar

    Many newer generic PC controllers support XInput (the Xbox 360 controller input standard), so you don’t need an official Xbox 360 controller to interface with XNA. For example, my Logitech F510 has a switch on the back to toggle between XInput and DirectInput. It would be nice to support DirectInput for legacy, though.

  2. tapi says:

    if you feel up to it there’s a somewhat cleaner way of storing globals called the singleton pattern as well: http://msdn.microsoft.com/en-us/library/ff650316.aspx

    feel free to hit me up on aim or skype if you have c# questions, both accounts are tapiocayeah.

Subscribe to RSS Feed Follow me on Twitter!