PDA

View Full Version : PGDmC: Knight Fever



Winwardo
08-07-2011, 10:36 PM
Hey, this is my first post to this website but I thought I'd register my interest in this contest here just so you guys know I exist :P

I'm Chris Winward, a 17 year old student (doing Pascal at school, an older version of one of my games was actually featured here in this article (http://www.pascalgamedevelopment.com/content.php?209-Space-Shooter-by-UK-Student)) and I've been working on a mini arcade game called Knight Fever for this competition.

Moderately not-so-long story short, you're a knight, and your world has been overrun by monsters and whatnot. Naturally, you answer the valiant call of the brave, and take it upon yourself to find the biggest freakin sword you can, and lop the heads off of your otherworldly adversaries. As well as head-lopping abilities, it also grants you the power to stomp on your enemies' heads from above, and shoot walls of fire from your fingertips.

http://dl.dropbox.com/u/1471205/Pascal/Knight%20Fever/pictures/pic1.png

The graphics are still in their early form (ie I scrawled away in photoshop for as little time as possible for each sprite), I have a team-member working on graphics and another has written some music for the game, so the presentation quality should be at a good standard a little further down the line.

It's written in my own engine, utilising SDL as a springboard to access OpenGL functions to draw it all, as well as SDL for all the music and key input. I'll release the source code along with the game if anybody wants to poke through it, but I'm sure the rest of you more experienced programmers won't find much new in there.

I haven't had anywhere near as much time as I'd have liked to have had to make this game so far (there's a lot of projects and work currently at school weighing me down) but I'm happy with what I have so far.

Thanks for the opportunity for the contest, and I'll be sure to update you as I go along :)

WILL
08-07-2011, 10:59 PM
Hello Chris, welcome to the PGD forums!

What a great first post. Your game looks like it'll be pretty fun to play. I look forward to trying it out when judging begins. Feel free to post away. I've set you as a non-moderated member so your posts should show up instantly now.

Starting out can seem a little daunting at first, but there are plenty of resources on the site and out there on the net. Just stick with it and you'll eventually be able to count yourself among the ranks of the veteran Pascal game developers. :)

Love the programmer's art btw! :D

chronozphere
09-07-2011, 11:08 AM
Lovin the game title and the screenshot. Good luck in the competition! :)

paul_nicholls
09-07-2011, 12:38 PM
Hi Chris! Welcome to PGD, hope you enjoy your stay :)

The game is looking mighty fine, and I am looking forward to playing it...good luck!

Just stick at it and you will get better and better before you know it :)

cheers,
Paul

Winwardo
09-07-2011, 12:49 PM
Thanks for the kind comments so far, guys :)
Once I've got the collision system properly working I'll throw up a copy of it so far to Dropbox for you guys to try out if you want, although other than art and adding menus I wouldn't expect it to change dramatically over the next week.

Looking forwards to everyone else's entries too :D

code_glitch
09-07-2011, 01:58 PM
There is an ftp for this... But I must myself admit to using the dropbox method all too often :D

Anyway, looking great so far, I'm doing an architectural re-write so I look forward to trying this one out, or at least seeing more of it ovver the last 8 days of the compo :)

Ingemar
09-07-2011, 07:29 PM
A knight chopping up green no-good-whatevers? Yes, why not? I like 2D games, they are so easy to grasp, you can focus on gameplay instead of messy 3D geometry.

How do you represent the ground? Are you testing background pixels, do you use a mask image or something else?

Winwardo
09-07-2011, 08:24 PM
There's two images, the drawn background image, and another which is transparent with black pixels over it which is the collision mask. The game loads up the mask, extracts every fourth pixel for the alpha value, and then the player and other game objects use that array of values to check whether it's solid or not.

Since OpenGL can't hold textures larger than 1024x1024 (or so I've heard), I've had to split each level into multiple collision masks. Having a little trouble getting collision to flow seamlessly from one mask to the adjacent ones, but It's coming together.

Edit: I only decided to use (what I assume is) a needlessly complex way of doing it because a) I wanted my artist and myself to have freedom making the levels however we wanted, which when using a tile system can be limiting, and b) I may as well learn how to do something new if I get the chance ;)

WILL
09-07-2011, 09:16 PM
Since OpenGL can't hold textures larger than 1024x1024 (or so I've heard), I've had to split each level into multiple collision masks. Having a little trouble getting collision to flow seamlessly from one mask to the adjacent ones, but It's coming together.

On this... the 1024x1024 texture size limit depends on your computer's hardware. Newer more powerful cards can go higher than this, just be sure to choose a texture size that will match those generation of systems which you want your game to run on. 1024x1024 is a good size for most systems there days, however many would be able to do higher such as 2048 and even 4096 for the higher end video cards.

Winwardo
09-07-2011, 09:28 PM
Considering that the computers at my school where I want this to be able to play can barely run OpenGL and require all textures to be a power of 2 in size, I thought I'd put it down to 512x512 just incase. It would be using practically the same amount of memory either way, but this way I can be definite that it will run on older machines.
(We're talking horrible beige clacky keyboards and towers here in some cases, not a pretty sight)

Thanks for the info though, was not aware of 4096^2 textures being supported at all

Ingemar
10-07-2011, 08:22 AM
Considering that the computers at my school where I want this to be able to play can barely run OpenGL and require all textures to be a power of 2 in size, I thought I'd put it down to 512x512 just incase. It would be using practically the same amount of memory either way, but this way I can be definite that it will run on older machines.
(We're talking horrible beige clacky keyboards and towers here in some cases, not a pretty sight)

You mean really old computers? Sounds like 10+ years old. Not that an old computer is useless but it is getting a bit hard to accept computers without at least half-decent GPUs.

WILL
10-07-2011, 10:00 AM
Also most newer cards, even the fairly older ones mind you, don't nessiccarily need to be 1:1 scale (square). They can be rectangular in size as long as both dimensions are each power of 2. So for example a 'modern day' card should support 512x1024 sized textures, but it never hurts to test this.

There is a tool that used to be hosted on Delphi3D.com before when the site was still online. It was a great resource from way back that has since turned into a ghost site and eventually inactive. It was called glinfo and when ran, it would tell you exactly what maximum size your textures could be on that system. Great for testing systems and your development system to set yourself a target minimum/maximum for OpenGL version and specs.

There is this other one now that should work for most platforms that you can develop for using Object Pascal. It's called GLview 3.0 and it'll work on win32/64 and Mac OS X as well as iOS and Android devices too. Maybe see if they'll let you run this program on your school? It was approved for the iPhone/iPad by Apple so that kinda says something. Worked alright when I ran in on my devices.

Jimmy Valavanis
10-07-2011, 02:22 PM
Considering that the computers at my school where I want this to be able to play can barely run OpenGL and require all textures to be a power of 2 in size, I thought I'd put it down to 512x512 just incase. It would be using practically the same amount of memory either way, but this way I can be definite that it will run on older machines.
(We're talking horrible beige clacky keyboards and towers here in some cases, not a pretty sight)

Thanks for the info though, was not aware of 4096^2 textures being supported at all


TIP:
you can determine at runtime the maximum texture size that is allowed using the following code:



var
max_texturesize: integer;

....

....
glGetIntegerv(GL_MAX_TEXTURE_SIZE, @max_texturesize);

if max_texturesize >= 1024 then
(code to load 1024X1024 texture)
else
(code to handle lower texture sizes)

code_glitch
10-07-2011, 02:50 PM
Wait, theres a limit on tex size? I have a practice of loading everything to textures etc and Ive done 12 megapixels on my Radeon 4330 and GMA 4500MHD no problems at all (the gma was a little sluggish) but other than that no hitches... I would say 2048x2048 is pretty clean nowadays - most screens exceed at least one dimension of that 1024x1024 limit after all :D

Now, that is an elegant solution there jimmy - noted for prometheus :D

paul_nicholls
10-07-2011, 08:39 PM
Wait, theres a limit on tex size? I have a practice of loading everything to textures etc and Ive done 12 megapixels on my Radeon 4330 and GMA 4500MHD no problems at all (the gma was a little sluggish) but other than that no hitches... I would say 2048x2048 is pretty clean nowadays - most screens exceed at least one dimension of that 1024x1024 limit after all :D

Now, that is an elegant solution there jimmy - noted for prometheus :D

Yes there is definitely a limit to texture sizes, even on latest video cards :) If you try and load too many textures, or too large ones, then the card will swap in/out textures and other data to fit and your program will drop FPS like nothing else if you are not careful...

cheers,
Paul

WILL
10-07-2011, 09:23 PM
glGetIntegerv is a very handy function for getting whatever piece of information from your system supports from OpenGL and other non-OpenGL values.

My system coincidentally can support 2D and 3D textures at 8196x8196 and 8196x8196x8196 respectively. And after trying it on my Mac, I'd highly recommend try out GLview. Tells you a lot of useful information should you get deep into OpenGL and 3D programming.

GLview webpage (http://www.realtech-vr.com/glview/)

Ñuño Martínez
11-07-2011, 08:06 AM
Another medieval game for the contest! We have 3, right?

The current graphics looks cool. It reminds me the good old ZX and MSX games. :)

Ingemar
11-07-2011, 08:27 AM
Another medieval game for the contest! We have 3, right?


It is just 1/3 of the games, hardly a strong trend. And medieval themes are among the most popular ones. Medieval and SF. Are there two SF games or more?

Winwardo
16-07-2011, 02:54 PM
The game is practically ready for upload, I just need to get all the art finished and into the game. Here's the main menu and a pic of you ingame.

http://dl.dropbox.com/u/1471205/Pascal/Knight%20Fever/pictures/mainmenu.png

http://dl.dropbox.com/u/1471205/Pascal/Knight%20Fever/pictures/ingame.png

The gameplay is very simple, two buttons for attacking, three buttons for movement, goblins spawn progressively faster as time goes on, and anytime a goblin dies without you killing it (such as in a lava pit) you lose points. Will have the game up ASAP :)

EDIT: Also, it suffers from a crippling bug that closes the game due to accessing a bad part of memory. I can't replicate this bug, and even with a try except statement and other stuff, it still SIGSEGVs.


function grabCollisionArrayPixel(xz,yz:integer;xx,yy:intege r) : byte;
begin
if ((yz mod 512) = 0) then inc(yz);
if ((xz mod 512) = 0) then inc(xz);
if(yy < 1) then yy := 1;
if(xx < 1) then xx := 1;
try
result := arrayCollisionPixels[yy,xx]^[ (512 * (yz mod 512)) + (xz mod 512) ];
except
raise exception.create('Bad memory access');
writeln('SIGSEGV noted');
result := 255;
end;
end;

If anybody could help me with stopping this from crashing I would majorly appreciate it. It's certainly not xx and yy being out of bound, and the second value can range from 0 to 262144. By my calculations, (512 * (yz mod 512)) + (xz mod 512) should never be larget than 262143, even if yz and xz are both 511. So any ideas?

Jimmy Valavanis
16-07-2011, 05:13 PM
function grabCollisionArrayPixel(xz,yz:integer;xx,yy:intege r) : byte;
begin
if ((yz mod 512) = 0) then inc(yz);
if ((xz mod 512) = 0) then inc(xz);
if(yy < 1) then yy := 1;
if(xx < 1) then xx := 1;
try
result := arrayCollisionPixels[yy,xx]^[ (512 * (yz mod 512)) + (xz mod 512) ];
except
raise exception.create('Bad memory access');
writeln('SIGSEGV noted');
result := 255;
end;
end;

If anybody could help me with stopping this from crashing I would majorly appreciate it. It's certainly not xx and yy being out of bound, and the second value can range from 0 to 262144. By my calculations, (512 * (yz mod 512)) + (xz mod 512) should never be larget than 262143, even if yz and xz are both 511. So any ideas?

What about if yz or xz are negative?
eg
xz = -10;

xz mod 512 gives a result -10 (!!)

Winwardo
16-07-2011, 05:34 PM
I had never thought of that Jimmy!
I changed it to
if ((yz mod 512) <= 0) then begin inc(yz); writeln('Error #001 caught'); end;
and suddenly partway through I found that being written to my console, went up the the top left corner of the map and there were goblins outside the map! I just need to make it so they'll auto-delete if they try going outside the map, and that should fix the crash!

Thank you so much Jimmy, you've saved the entry from random crashing :)

EDIT: Nope, seems there are other issues too. But that was one of them. :///

Double Edit: I seem to have trapped all the crashes now and stopped them from happening, so if it does crash when it's entered, I'll be pretty annoyed, heh

Winwardo
17-07-2011, 09:14 AM
http://dl.dropbox.com/u/1471205/Pascal/Knight%20Fever/pictures/outsidelevel.png

http://dl.dropbox.com/u/1471205/Pascal/Knight%20Fever/pictures/towergame.png

Finished, just in time!
Uploaded to the FTP, and I've got a Dropbox redirect setup just incase something happens to the FTP and/or people want to try out the game without going to the FTP.
Download it here! (http://dl.dropbox.com/u/1471205/Pascal/Knight%20Fever/Knight%20Fever%20-%20Chris%20Winward.zip)

This has been a fun experience getting this game created and finished by the deadline, hope everyone else enjoyed doing this as well ( ignoring the stress of not being finished until fairly late into the contest ;) ) :)
Quick note: One of my playtesters had a bug where the goblins would pile up in a deathzone instead of taking damage. He had Windows 7 32-bit. If anyone else has this problem, please tell me and your specs to see if I can pinpoint the issue!

Traveler
17-07-2011, 11:36 AM
I just tried you game on Windows (64b) but didn't experience that problem. I did notice a situation in you 'castle' level where all enemies appearing from the right side are stacked on top of each other.