PDA

View Full Version : Finishing a game (or anything else) + problem



Septimus
25-04-2003, 04:09 AM
Hi, I'm a long time reader - first time poster. Just a couple of questions to start with:

1. When you're making a game or something, do you focus on the basics to get it playable ASAP and then work on building in the extra features or do you insert the features as you're working on the program (so the program looks good but doesn't quite work)?

2. I've got a problem with a game I'm working on. It's trying to be a clone of the Atari2600 game Beserk (top-down maze game similar to pac-man only more open and you can shoot), I don't know if you've heard of it. The problem is when I shoot down and right the bullet passes through walls and continues to the edge of the form. Every other direction works fine.
I don't know much about graphics and Delphi so I'm just using the canvas and checking pixel colour ahead of the bullet. If a pixel that the bullet will travel into next frame is not black (the floor colour) then it should stop travelling (that's all I'm up to so far).
The whole code would probably be too long to post here, but here is the section that performs the move:

{more code here}
Halfspeed := Person.ShotSpeed div 2;
case Person.BulletDir of
{more code here}
3: begin //down + right
Inc(Person.ShotX, Halfspeed);
Inc(Person.ShotY, Halfspeed);
if Form1.Canvas.Pixels[Person.ShotX + Halfspeed, Person.ShotY + Halfspeed] <> clBlack then Person.CanShoot := True; //stop the bullet;
end;
{more code here}

That is a case of shooting direction = 3. Moving the person using the keypad changes the direction that the bullet will travel. 3 = down and right. I made the shot speed half on diagonals otherwise it travels twice as quickly as NESW.
I've been over the rest of the program with a fine tooth comb (since it didn't always work like this) and everything is the way it should be. It's exactly the same as the other directions except for the Inc and Dec of the axes.
Any suggestions would be appreciated, including other ways to do what I'm trying to do. I've tried to research it, but 90% of what I found was for far more advanced 3D programs, the other 10% just wasn't helpful.

cairnswm
25-04-2003, 06:44 AM
1. I always try and add little by little to my programs. Before a user sees a program I've run it an estimated 1000 times. Same applies to my games. Everytime I add a little thing I test everything again.

2. Why not just check for map limits as well?

Alimonster
26-04-2003, 02:11 PM
1. When you're making a game or something, do you focus on the basics to get it playable ASAP and then work on building in the extra features or do you insert the features as you're working on the program (so the program looks good but doesn't quite work)?
Hmm. I find that I can get a lot more done if I focus on getting _something_ displayed (menu, game, whatever). I've found that making code overly-generic or fancy can be bad for productivity -- for example, if I was writing a class to display images, but tried to make it generic to handle different formats, then I get nothing done. However, sticking to an initial format and using it for a while gets results quickly, which feeds back into my motivation. The same goes for other parts of the game, IME. If you can make things generic and get your game doing interesting things then more power to you, but don't spend too long on it. It's much to easy to end up with 50 different unfinished projects if you do that.

Try writing only the parts you need when you need them -- sod planning for the future in your code until you have something _worth the time_. Otherwise, you end up with the most generic, beautifully designed thing that does nothing because you lost motivation ;).

IMHO of course.

Imminent threats work too -- "you must finish this part of the game in a week or I'll lock you inside a fridge for a day." Just ask anyone here and we'll be willing to provide appropriate threats.

About your second question: it's hard to say without seeing more code (e.g. the other cases). If you could provide more information about what you're doing (and especially download code) then we'll be able to help more.

Septimus
27-04-2003, 04:11 AM
Well I dunno how or why but:
I added much the same pixel detection to prevent the actual person walking through walls and fiddled with the location the bullet appears from the sprite (so not it looks like the bullet comes out of the gun instead of the forehead) and that seems to have fixed the problem.

Now I don't know what to do next. I think I've probably bitten off more than I can chew. The last game I made was with Turbo Pascal 7 about 7 or 8 years ago and had no graphics whatsoever. Things were so much simpler back then...

I think my problem will be that once I get a game playable (however basic it looks and plays) then that'll be the end of it. That'll be good enough and I'll move on to something else. That's what happened in the olden days anyway.

I guess there's good arguments for both ways of making a program. Unfortunately I had a great idea a few days ago that I figured I'd leave a little later and now I can't remember what it was. Maybe I should leave notes for myself...

Another question though:
Is figuring out Image Lists worth it for small games? So far I have series of 8 bitmaps for the person, the gun flash, ect that load from file depending on direction facing. There doesn't seem to be any problem doing it this way, but I was planning on adding some sort of movement animations, which would make it 1 or 2 dozen images for just the person alone (eventually there will be the same for up to 10 robots also).

Obviously repeatedly loading pictures from the HDD would be the least efficient way of doing it, but it's all so overwhelming I don't know if I should concentrate on understanding one component at a time or slowly build off what I already know, incorperating new components as I learn them.

Bobby
27-04-2003, 06:48 AM
Hi, if your going to get into lots of images needed and switching between them I would recommend using a directX component set. they are all very easy to use, and there are multiple ones available.

DelphiX
PowerDraw
Omega

I would recommend using one of them :) It makes things so much easier.

If you dont want to go that route, I Would just use an imagelist, they are easy to figure out with playing around with them a little :)

Im sure there are lots of ways to go about it.

Bobby

Septimus
27-04-2003, 07:38 PM
I don't think I'm quite ready to tackle 3D just yet. Besides, I have Delphi 7 and I haven't found a component suite that supports it yet. Not to mention I think it would be overkill for my little proggie. I may give image lists a go soon. It's either that or the AI, which I'm also not looking forward to.

Alimonster
27-04-2003, 08:13 PM
Imagelists are really a straightforward concept, so don't worry about them so much :). In short, they let you store many bitmaps/icons/whatever that are the same size in what amounts to an array. If my memory is correct then the imagelists will be stored within your exe file, so you don't have to supply those bitmaps with your project once they've been added (which can be handy to reduce clutter). Assuming I'm remembering correctly, that is.

The important part of an imagelist is its "GetBitmap" method. You create a TBitmap, set its size, use GetBitmap and then do whatever you want. Here's a quick example nabbed directly from one of my very old projects:

procedure TForm1.DrawImage;
var
Bmp: TBitmap;
begin
Bmp := TBitmap.Create;
try
Bmp.Width := 16; // whatever size your pics are
Bmp.Height := 16;
ImageList1.GetBitmap(SomeIndex, Bmp); // get the bitmap from ilist
Canvas.StretchDraw(ClientRect, Bmp); // draw bmp however you want
finally
Bmp.Free; // free everything you create
end;
end;

Where SomeIndex is a number from 0 to the amount of images in the imagelist - 1 (just a zero based array value, in other words).

Basically, imagelists are a way to make your program "cleaner" -- you'll end up having less files (maybe just an exe file) to hand to other people, which makes things less of a hassle for the end user.

Now the AI -- you can be worried about that . :roll:

EDIT: Actually, I don't think you even need to set the bitmap's width and height beforehand.

Bobby
27-04-2003, 10:11 PM
all 3 of the component packages support delphi 7, and are 2d only ;)

Bobby

Septimus
28-04-2003, 03:42 AM
I got DelphiX a few weeks ago and it wouldn't install the components. I tried to do all the crap you have to do to get it to work with Delphi 6 and that didn't work. I haven't looked at the other 2 yet, I might soon.

I figured I was probably better off learning the coding instead of shortcuts anyway, maybe I was wrong.

I guess image lists don't look that difficult when you put it like that. It's like they try to explain them in the most complicated possible way in the help file. A problem with having the bitmaps in the exe though is that I was planning on making the sprites cusomizable, though I figured that would open a whole new clipping headache, since at the moment I'm just repeatedly scanning 4 or 5 pixels on the current sprite. The same 4 or 5 pixels would be in the wrong place if someone made their own pictures. So I dunno.

I suppose I should just keep it simple to start with. I just hate having to go back later on and recode whole sections just to implement a new way of doing the same thing.

Thanks for your help guys. Programming is nowhere near as fun if you're stuck making 'pick a number between 1 and 10,000' type games (that was my first ever game :roll: ).

Alimonster
29-04-2003, 08:25 AM
DelphiX is a bugger to set up in later Delphi versions, but it's a bit exceptional (it's not been updated for yonks, unlike the latest bunch of component sets). Have a look out for Omega (http://www.blueworldtech.com/ds) (Bobby's work), Xcess GDK (http://www.xsdevkit.com/) (Harry Hunt), PowerDraw (http://turbo.gamedev.net/powerdraw.asp) (LifePower) or GameVision (http://gamevision.jarroddavis.com) (JDS Games) in absolutely no order of preference at all. All of these kits do 2D and work in recent Delphi versions -- plus all the authors are members here, so you can pester them if you get into difficulty ;).

Anyway, I'd advise this: keep it simple. Get the thing out the door. Or, to put it another way: "Customisable sprites are planned for version 2 of the project. Elegant code is planned for version 20." :P

Septimus
29-04-2003, 01:26 PM
Anyway, I'd advise this: keep it simple. Get the thing out the door. Or, to put it another way: "Customisable sprites are planned for version 2 of the project. Elegant code is planned for version 20."
Great tip. I spose I should stop procrastinating with changing things that already work and get to actually adding to the game.

I'll check out those components and no doubt be back here with all the rest of my problems.

Thanks.