Thursday, December 27, 2007

Updates

I suppose I shall institute this new thing where I update you on how much I have done in the day.

Today, I learned that JOGL is out of my immediate reach.
Today, I added NPC sensitivity to the collision detection.
Today, I fixed the NPC sprite transparency issue.
Today, I modified the size of the steps my player takes. This makes my game look a little smoother, a little nicer.
Today, I made it so that my player is drawn within the same heights as the NPCs (it was different for some reason).

The night is still young, so I'm sure there is more to do. I want to create the thread that controls the NPC movement. Basically, I can split that into two parts. One that controls which image is displayed, and one that controls it's actual movement. In my old code, that was actually two separate methods. Now, though, it is combined. So, I need to, basically, copy the Thread that is used for moving my player, and instead pass NPC characteristics to it. Also, I am keeping it in the main class, so I'll have to take everything in my player class and incorporate it into the Thread. It's gonna be a little work.

Add to that the fact that I need to program the sensitivity of detecting which NPCs are near. And then I need to take from those a random one to update.

Work Begins Anew

Put on a pot of coffee. I am transferring my code to a JOGL framework, to see if it makes it any better. I'll let you know how it goes.

EDIT- Sigh, alas, JOGL is just a little too difficult for me to understand in one day. I think I shall continue programming in pure Java. I'll get around to JOGL someday, but just not anytime soon, I think.

Ah, Success Is Mine

Yours truly, a mere mortal, has managed to successfully (I believe) install JOGL, the little thing that gives incredible performance in 3D applications, let alone 2D ones. I will vest the rest of the day into learning how to do simple stuff (by their comparisons, all 2D stuff is simple), up to animation. Then, if I feel I am comfortable enough with it, I will convert my entire application (everything I have) to the JOGL system, and finish it there. Won't that be a treat?

I'll just have to find out, eventually, how to make it so that when I get my program onto other computers, everything loads correctly.

EDIT- So, getting the damn stuff installed is one thing. Programming with it is another completely. I finally got one of the examples to work. One of the problems, though, is that when I hit the X up at the top, nothing happens. It won't close. I'll work on it.

EDIT TWO- Yeah, in a record three minutes, I fixed the problem. It actually took longer to open the IDE than it did to fix the program. I changed it from a Frame to a JFrame, which has the EXIT_ON_CLOSE thing. That did the trick. I'm off to learn how to draw images with JOGL.

Rested

Me and my computer both are. After sorting through somewhere near 700,000 files, it found two things it did not like and I got rid of them. Then I shut my computer down and restarted it. Now it zips along. It uses 375 megs of memory now, as opposed to the 1 gig it used at all times before shutting it down. I should probably do that more often. I also got a stupid firefox problem, so I just reinstalled that now.

Programming later, food now (I just woke up a little while ago). Still a little tired, but a lot better than I was last night at 4 in the morning, trying to understand JOGL. Which I refuse to learn now (look for that to be implemented somewhere around the fifth official version of the game, as kind of a treat).

Later.

JOGL

So, I read up a little on Java OpenGL, which is a little thing which makes graphics zoom like greased lightning. The demo used 3D graphics, and ran at 700-900 frames per second. Fucking... amazing. I figure that even though it is made to work with 3D applications, it can work wonders also on 2D applications. But, it looks a little complicated, and I'll probably need a little help to get going with it.

EDIT- Holy shit this shit is complicated. I don't understand it at all. But, haha, I once remember being in fourth grade, and having to deliver a message to an eight grade teacher. I took one look at the math on the board, and thought I would never understand that stuff. I've been a math genius ever since. So one day I might actually buy a book on it and fucking delve into the code. Until then, I shall settle for simplicity and mediocre performance.

After 4 and a half hours... virus scan still going! 588,000 files scanned. Fucking Microsoft Flight Simulator. That's 100,000 files right there at least. Where did all these files come from?

On The Road...

... to NPCs. I created a separate layer to render, apart from the background images. I forgot to reinsert the transparency stuff, so the NPCs show up on a black surface, but they show up. I am hoping to make it so that ... I lost my train of thought.

Hm, I was hoping to make it so that it could do something. I will endeavor to make it so that the NPCs walk around. For some reason, I can't remember anything of what was sure to be a long post. I must be really tired.

Tomorrow, guys.

Wednesday, December 26, 2007

It's NPC Time, Bitch

I realized I have no idea how to start to structure my NPC code. Well, I did have an idea, and I am having it critiqued on a forum, now. 112,000 files scanned.

Defrag

My computer has not been defragmented in a long time. So I cleared off a lot of stuff, and I am going to start a defrag right now. Later, people. A lot later, depending on how much stuff I need is on my hard drive.

EDIT: Okay, that took nowhere near as much time as I thought it would. It took longer to free up the space needed to defrag in the first place. And apparently my D drive needs no defrag. So, it being only nine at night, I am ready for the programming to continue. In four hours, you shall see me post, "So, it being only one in the morning, I am going to do some more programming." I am, I admit, somewhat obsessed. But, I have reason to be; I only have just over two weeks until college begins. A new semester, six classes, friends who live with me, not nearly as much free time.

Well, I only have one class on Monday and Friday, so there's time then.

EDIT TWO: Running a virus scan, and later a spyware scan. My Explorer.exe is, for some reason, randomly consuming 50-60 percent of my processing capabilities. I don't mind it so much, I suppose, except for the fact that I'm afraid it is degrading the performance of my Java compilations. More later.

EDIT THREE: ~60,000 files scanned, and nothing yet. Unfortunately, there are 300,000 to 400,000 files on my computer. Maybe a little less, since I just deleted a few programs, and games. Now I start on NPCs. Damn, this is tough.

First Look

Okay, so I got the idea to make a small video of how my program is doing so far. I guess all I'm gonna say is that this is just a test map. Two of the protrusions in the corners started life as NPCs in my old map, and that 3X3 block toward the lower left edge was once a small building. They will be again, but for now they are trees. Also, I want to say that all the images are sprites taken from various versions of Nintendo's Pokemon games. They own them, and I am not collecting any sort of fee for their use, so I am off the hook as far as legality goes. Enjoy... me walking around a map....



So, how was it? Was it cool? Did it make you all tingly with anticipation? Did you notice the background trees shifting unevenly?

Bah, never you mind that last part. It looks good enough in person, and better on video, I think.

I am suddenly exhausted, and my eyes hurt a little. Break time. I'll begin anew later.

Success, Success

I am very happy with myself. After looking online for a very long time, running through forums and websites and shit, I have determined that my game is pretty damned good. I also "fixed" it again. Remember all that crap I gave myself about making the character turn in place? Well, I ended up setting the direction, and then starting the move thread, and finally adding a slight pause to the thread. That pause gave the computer a chance to ascertain whether or not the key was still being held down. So very quick taps gave a turn in place reaction (just like the actual game). Well, I realized that this pause (30 milliseconds) was actually showing up in the game, giving my animation a very slightly noticeable hiccup every half second or so. You would have to be paying attention to spot it, but it was there, it was responsible for part of the perceived crappy animation, and it was getting on my nerves.

So what I did was change the location of the small pause. I made it only register if the direction was not set. So when the direction was set (like after you had finished turning in the direction, and either held the button, or went to tap it again), the pause no longer occurred. This led to some smoother animation, and a happier me.

I now have the player done (for the moment). I still need to shift more of the code to the player class, but that will come later. I'd say, as far as the entire game is done, I am now somewhere around 1/200 - 2/100 done. For those of you more idiotic than a fifth grader, that's 1/200 - 2/200. Not much. Some of it will be easier, though, so I am alright. Art and music will be death; I may have to find someone else to help me with them.

Later, peoples, I'ma gonna find something else to do (programming-wise).

Hey Justin.

New Ideas

So I stumbled across an interesting little tidbit, while roaming through Java forums. I now about an interesting little thing call a Rectangle. No, I'm not a moron. It's a programming thing that can help me know when stuff comes into view of my "camera" into the little world I have created. The Rectangle would be updated constantly to follow my character, and the rectangles of other things, like NPCs for instance, would set off an alarm when they intersect with it.

Unfortunately, while this is a good way to detect other characters, I do not see how it can be effectively used to make my tile map faster. Oh well. I heard Quadtrees are good for large maps, but I cannot find good documentation on them. I'll look around again, though.

Oh, That Was Easy

I did it. In record time, too, I might add. My character turns in place (mind you, you must tap the arrow key pretty damned quickly), and turns and walks without significant pause. Gonna work on some other stuff, now.

EDIT: Blah, did some more stuff. Tried experimenting with VolatileImages. I did not like it. It actually slowed everything down. I thought it was supposed to make images faster accessed? Whatever. Back to BufferedImages. There's a small amount of distortion in the images as they are drawn (something like tearing but not nearly as bad), but I think I'm cool with that.

So, I also checked out, once more, my emulator for the Gameboy Advance. I played some Pokemon Crystal (my absolute favorite version), and looked at how that looked. And I realized it was just as terrible as mine. That same sort-of-tearing is there too, even through the best filters. So that means my version of the game is just as good as the best emulated version out there. Awesome.

So, I have finished the basics with my character (just the walking, though), collision detection, the tiled map, all that sort of stuff. Next up is the NPCs. I am going to make two of them (like in the original test map), that walk around a predetermined path. I have no idea how I am going to do this, but I suppose it will be something like, look around the visible portion of the map (can be done while in the animation loop). If there is any portion of an NPC's path being animated, I shall set that NPC into motion. If their path is no longer animated, they go dormant.

But first, lunch, and Rush Hours.

Ah, Sleep

I obeyed myself, and went to sleep last night without programming anymore. I woke up fresh with no headache, and took a nice, warm shower. And then I got some breakfast and started programming. I have it now so that my character can turn in place, and I also have him moving smoothly across the board. The method I wrote down last night did work, although it took making a new thread in order to do so.

My only problem with it now is that the pause when turning in place is too long. In the actual game, if you quickly tap the directional pad, the character turns in place. However, if you press it down, the character turns and immediately starts walking. I replicated this in my original program (I looked at that code, tried to adapt it, and promptly trashed it, starting from scratch). But on my program, when you turn and walk, there is a pause (allowing you to otherwise turn in place), before the walking. The rest of my day shall probably be spent getting rid of that pause.

It is almost time for lunch, though, so I may give it a rest for a little while. I also wish to enjoy my copies of Rush Hour and Rush Hour 2 once more. I'll see what I can get done.

Later, peoples.

Why Do I Do This To Myself?

I started programming again. Why? Just because I did. I had a goal in mind. Did I reach that goal? Yes and no.

Well, I realize that there are some things I should have done, that I did not. Before, I had the code for making the character look like he's walking separate from the code to actually move him. This is trouble, because when the character is moving against a wall, his feet still move. In a perfect world, that is. This was accomplished in my old program. However, the code to do that is now dependent on the the arrow keys being effective, which, now, when I run into a barrier, they no longer are. This is a problem I must fix.

Also, I am experimenting with different ways to move the character continuously. I have tried several ways, but none seem to work to my liking. I am actually getting an idea right now, so bear with me while I write it down.

I use steps in the X and Y directions to mark movement. These are increased by 8's until the desired goal (+tileSize, -tileSize) is reached. This produces the smooth movement as the character walks. I am thinking of using the flag methods to flag the keys I am pressing down. I am thinking that I can program it to only acknowledge the held key when no other keys are pressed, and also the steps are only divisible by tileSize. That way, it will not continuously read the flagged key and zip my character across the board.

Tomorrow, though. Absolutely no more programming tonight.

Later, fucktards.

More Done

Phew, did a little more. I got my guy to walk. And I figured out how to use classes and junk. I have a class for my character now. Of course, there's some stuff I should do to optimize it, to ready it for possible changing resolutions, but I'll get around to that later.

Next up is something I completely forget how to do. I need to make it so that I can turn in place, rather than automatically walking in the new direction. Then, I need to make it so that I have smooth walking, without that little jerk at the beginning. Now, I know what some of you are saying. "Flag the keys being pressed, and you won't have that pause!" Well, fuck you all. That makes my game too fast. I had a way of doing it with just the keyPressed() code, and that's what I'm going with.

It's almost one in the morning, so I think I will finally call it in, and get ready for sleep. Tomorrow I will look at the old code I have for that, and find a way to implement it into the current programming.

Tuesday, December 25, 2007

Fixed Something I Didn't Even Know Was Broke

So, I started noticing this little thing where the character started out on a tree. It was fine to move, and of course I couldn't move back onto the tree. So I decided to change the starting position of the character. Unfortunately, I noticed that the playerPosX, and playerPosY numbers seemed to dictate where the character would come up on the screen, not in the field. Well, I fixed it. I had to add two variables, ones that measure the initial distance from the original starting point. This makes me realize I shall have to make a method that initializes all the character information when the game is resumed. I know I should have already thought of that, but hey, this is my first serious game, and I'm learning as I go.

So, now my character is centered on the screen no matter where on the board he starts. I was in the middle of getting the sprites for him up and working, so I shall continue that now.

Done

Collision detection is working. It was just a little switch statement using the direction, and whether the tile above, left, right, or below was a one or a zero. I only have two different tiles now. In the future, tiles that the character collides with will be within a predetermined range of numbers. That will be my collision checker.

Alright, Whatever

I ate some more food, and my headache is more or less at the same intensity it was earlier. So, I am going to go ahead and do a little programming. Gotta go up to my bed, and get comfortable first. I discovered that the power button on my tv remote, which I had believed not to be working, actually does. It's a little tricky, but it saves me a naked trip across the cold room, out of the cover of my warm blankets.

I'll have some results later, peoples. It's collision time!

Java, For You Peoples

So, I did a little search for Java in blogs, and didn't come up with anything useful. Then I was searching around Facebook for Java groups, and in one, I found a link to a blog made by someone who was writing a Java tutorial. In the interest of internet friendship, I am going to put a link here so that people can go check it out, if you want to learn Java. So far there are only two posts, two lessons, but if they stick with it, it looks like it could be good. So, enjoy this, and learn, people.

http://toastcode.blogspot.com/

If I see anything on the blog that looks wonky, I will point it out.

I Don't Heart New York

Scratch that, I fucking hate it. I love Philly much more. Why? Well, I respect assholes (this city being full of them, and I myself am one), I don't mind the filth, and frankly, the 400+ murder rate is something of a draw to me. I don't ever want to leave. I also hate traveling with my family. They hate taking me places, too, and have vowed never to do so again. On the plus side, I got to see my sister for the first time since I started college three or so months ago. That was alright.

I have a headache (which set in just before the Indian food, which was the reason I went in the first place. I had the mixed grill tandoori, which was still good, though a little burnt), although it is mostly gone. I am eating some food to help rid myself of it (I tend to not take medicine for stuff unless it's prescribed). But as for Java, no. No programming tonight. Just... no.

Tomorrow, peoples.