PDA

View Full Version : 4E4 Contest Entry - Unnamed RTS



cairnswm
10-06-2005, 06:22 AM
If you dont know what E4E is

http://www.gamedev.net/community/forums/forum.asp?forum_id=71&ByPassCookie=true

Its the GameDev.Net Four Elements Contest.

I have decided I will be making a full RTS game. Not sure exactly of the units yet but there will be three Races - Robot, Zombie and Human - the Humans will have Ninjas and Pirates as special units.

Anyway - I have started working on the entry and thought it would be nice to show my progress as I work along.

Last night I got the Map Class started. It allows scrolling, a minimap, stops at map limits, centering on a location - clicking on the minimap centers the main map on the clicked point. Press End to move to near the bottom right of map - press A centers on a brown block just below the opening view.

http://www.cairnsgames.co.za/files/rts0-01.jpg

The exe can be downloaded from

http://www.cairnsgames.co.za/download.asp?file=files/RTS0-01.zip

(Please let me know if you would like me to continue adding to this thread as I work on my entry)

Traveler
10-06-2005, 07:47 AM
A bold undertaking! I wish you good luck.

I tried the sample and I must say the whole thing is working quite nice! The only thing I am a bit worried about is your framerate. The pc I tried it on doesn't have a really good graphics card (radeon 7000, which is well below the given minimum) but I imagine that at this stage fps should be higher than 39 (even drops to 26 with scrolling).


(Please let me know if you would like me to continue adding to this thread as I work on my entry)

Yes please!

cairnswm
10-06-2005, 07:51 AM
SDL seldom gets really high framerates. A blank SDL project on my notebook gives me about 25-30 FPs and with the code in it I get just over 20.

How does Run-A-War run on that PC - its using the same calls and should be similar. This is actually slightly more optimised than run-a-0war.

Traveler
10-06-2005, 08:10 AM
I cant tell exactly as Run-A-War doesn't display fps but it does appear to be running at pretty much the same speed judging by the scrolling.

{MSX}
10-06-2005, 08:47 AM
what about using opengl in 2d mode ? possibly this would greatly increase performances.

cairnswm
10-06-2005, 09:06 AM
MSX - how do you do that with SDL - I've read up on it but can;t work it out.

How do you initialise it?
How do you load and display images? - The docs says its the same way but the examples show a much more complicated way of showing images.

{MSX}
10-06-2005, 10:37 AM
well to initialize, you use Opengl-sdl initializations, which is just a little more than standard SDL.
Then you set OPENGL as Orthographic 2d projection. You can disable all 3d stuff such as depth buffer etc.
At this point you can draw sprites drawing opengl quads (2 triangles). You use UV coordinates to choose the sprite in a sprite sheet.
It is possible to build a easy to use blitting function, with usual parameters such as destination rectangle, source, etc.

The only problem is that the texture must be squared with power-of-2 size, a limitation that you probably don't have in SDL.
This can possibly create some problems such arranging the sprite in a squared spritesheet.

But there are *lots* of benefits, first of all performances (standard SDL go really slow on my pc (20-30 fps for empty project), while OPENGL runs hundreds of FPS *with* objects), but you also get:
- performant and easy scaling
- performant and very customizable transparency (shadows, explosions, etc)
- rotations
- lighting & colors (you can choose the base color when you blit, think like drawing a sprite onto a colored piece of paper).

If you like, i can help you out with some code for this things.

cairnswm
10-06-2005, 12:09 PM
Do you think you could write me a small example that initializes the OpenGL SDL screen, then loads a texture, and then displays a transparent sprite (Rect from original texture)? If I had this I'm sure I would be able to convert it into my S2DL library quite easily.

If I can convery my S2DL library to use opengl through SDL like this I'd be really happy :)

Thanks

savage
10-06-2005, 12:19 PM
Hi William,
I ported Nehe's tutorial 21 to JEDI-SDL a while ago, and that is a 2D game using OpenGL call Grid Crazy ( for details read http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=21 ).

The source is part of both v0.5 and v1.0 JEDI-SDL CVS.

cairnswm
10-06-2005, 12:32 PM
I stole half an hour off work and did the next changes.

Added more brown spots so the scrolling is clearer.

Added the first Objects to the map.

http://www.cairnsgames.co.za/files/rts0-02.jpg

Exe downloadable from
http://www.cairnsgames.co.za/download.asp?file=files/rts0-02.zip

Trees are basically the lowest level of item. They dont move, they take up only one collision array location.

cairnswm
10-06-2005, 12:46 PM
Its not in either my 0.5 of ver 1 download files - I'll try get it from the CVS repository.

savage
10-06-2005, 12:53 PM
This is looking very good.

I could be wrong, but I think the mini-map is slightly off.

Btw, is this engine built from your RunAWar code base or are you building it from scratch?

cairnswm
10-06-2005, 01:02 PM
I'm building it from scratch. It will be very similar to the run-a-war code when its finished but it will be a completely new engine.

By the time I finished Run-A-War I felt that I had strayed to far from the original OO model I had used. So I think I'll get a better result by starting agian.

The reason the minimap looks off is that it has a Sqare instead of rectangular view. I'm using rectangular tiles in the main map but single (square?) pixels for the minimap.

I have a sort of development process mapped out:
1. Scrolling Map
2. Small Map
3. First Items - Trees
4. Collision Map
5. Units.
6. Buildings
7. Orders
8. User Interface

Up to number 3 already. Of course 5 and over will take a lot longer per phase.

cairnswm
10-06-2005, 01:03 PM
I cannot download the sound files for the tutorial :(

{MSX}
10-06-2005, 01:16 PM
ok, i've made a small demo for 2D opengl as you asked.
I'll upload somewhere lately, now i'm at work.. why can't one attack file to posts ? :P

PS if you need it i've also a nice GUI system that works this way.

savage
10-06-2005, 01:19 PM
I cannot download the sound files for the tutorial :(

Grab the sound files from this ]http://nehe.gamedev.net/data/lessons/vc/lesson21.zip[/url]

cairnswm
10-06-2005, 01:49 PM
Thanks MSX - just let me know where it is and I'll download it and give it a try. I'll need to update all my S2DL libraries but then all my S2DL based game should work :) The beauty of an abstracted interface :)

(Maybe I should have S2DLGL for the OpenGL enabled code)

cairnswm
10-06-2005, 01:50 PM
Cool - thanks Savage

{MSX}
10-06-2005, 04:45 PM
ok, i've uploaded it to
http://www.lugato.net/stuff/demo.rar

Let me know if you find it useful :P

Bye!

cairnswm
10-06-2005, 04:54 PM
Thanks MSX

When I run the EXE I get:
"The procedure entry point SDL_RWFromConstMem could not be located in dynamic link library SDL.dll"

Maybe I have an old version of SDL.dll - I'll have a look at it anyway.

cairnswm
10-06-2005, 04:59 PM
Ok - took the DLL from JEDI-SDL ver 1 and it works properly now.

Thansk a lot MSX. Now I just have to try understand what was done.

I'll also first add a FPS count so that I can see the difference.

cairnswm
10-06-2005, 06:33 PM
I added an FPS counter and got 186 when I ran the program :) A bit better than the 30 I was getting from my code.

Now I need to convert my S2DL units to use OpenGL.

How do I draw a small portion of an image tot he screen? I have png files that contain full sets of Sprites.

How do I define a transparent color per image?

How do I create a temporary surface on which to do a drawing? I want to create the current background on a surface and blit this to the screen and only update it when the background needs to change.

I'm sure there are going to be a pile more questions before this is done :)

My goal is not to change my interfaces into my S2DL units - this will allow me to just recompile game like Run-A-War and make them use OpenGL.

cairnswm
10-06-2005, 07:29 PM
Ok - got drawing a portion of the image to the screen.

{MSX}
10-06-2005, 07:43 PM
I added an FPS counter and got 186 when I ran the program :) A bit better than the 30 I was getting from my code.

very well :P
[quote]


>How do I draw a small portion of an image tot he screen? I have png files that contain full sets of Sprites.

Just act on the glTextCoord on the DrawRectangle.

>How do I define a transparent color per image?

More than a transparent color you should use the alpha channel. If you look at the pointer.png image, you'll see that it have an alpha channel that makes the background trasparent (0).
BTW this let you have continuos alpha values, not just 1 or 0. You can have 50%, 30% etc on different portion of the same image..

>How do I create a temporary surface on which to do a drawing? I want to >create the current background on a surface and blit this to the screen >and only update it when the background needs to change.

Umm you should generate a texture at runtime. This is not very easy as all textures must be squared. So you should map the screen on a large texture (1024x1024). Once you create the texture, you should use some Render-to-texture tecnique, and then use the generated one for the background.

>My goal is not to change my interfaces into my S2DL units - this will allow me to just recompile game like Run-A-War and make them use OpenGL.

Well, probably you'll have to change something.. But if it's done well there will be only minor changes.

Bye!

cairnswm
10-06-2005, 07:48 PM
Thanks MSX :)

Just got the Transparency work well - using the Alpha Channel (Thank Goodness for TheGimp).

So what is the render-to-texture technique?

I dont mind having to create a 1024/1024 texture if it will let me get a faster blitting working.

Can I use SDL_ttf and SFont with the OpenGL stuff or is there another Font component I can use?

I almost have my template working again. Except for background and Text I have been able to encapsulte everyting in my S2DL units and will not have to change any code in the main programs. :)

{MSX}
10-06-2005, 08:20 PM
Thanks MSX :)

Just got the Transparency work well - using the Alpha Channel (Thank Goodness for TheGimp).

The gimp is simply great :P
The best graphic program ever!


So what is the render-to-texture technique?


Well there are lots of different tecniques to do "render to texture" (that is, you render on a texture instead that on the screen, and then use that texture for the rendering)
Here's a ]http://developer.nvidia.com/object/gdc_oglrtt.html[/url]

Anyway entering "opengl render to texture" on google gives you lots of good answares.
I've never implemented this becouse i never needed it. Don't know how much impact it can have..



Can I use SDL_ttf and SFont with the OpenGL stuff or is there another Font component I can use?


Savage and me did some experimenting on running SFont.. you can probably find the post by him.
The problem is again with squared textures, since SFont expect straight font bitmaps.
In the program savage generated a texture for each word the program have to display. This is good if you have fixed text, but for dynamic text it's not good.
I thought about reading the straight bitmap and then for each character generate a small (32x32 or so) texture. This solution should work with bitmap variable size fonts (that was what i was searching when we experimented).

Alternatively, if you have fixed size font, you can create your own font texture and some functions that find the characters and render them. With fixed size fonts this is quite easy (you can find this in any of my programs)



I almost have my template working again. Except for background and Text I have been able to encapsulte everyting in my S2DL units and will not have to change any code in the main programs. :)

Great, that's already more than i thought :P

savage
10-06-2005, 09:35 PM
Can I use SDL_ttf and SFont with the OpenGL stuff or is there another Font component I can use?

Under the SDL_ttf directory, there should be an OpenGL demo of one way to render true type text using OpenGL.

cairnswm
11-06-2005, 07:22 PM
Version 0-03 - Converted to OpenGL and Added a Cursor

http://www.cairnsgames.co.za/files/rts0-03.jpg

Converted all graphics routines to OpenGL - this was a bit of a nightmare but in the end I got everything converted. Images were modified (thus included again).

The minimap had to be a factor of 2 so the map size has been downgraded from 100x100 to 64x64 but its still quite big enough.

Added a Nice sword as a mouse cursor.

Download the game so far from http://www.cairnsgames.co.za/download.asp?file=files/rts0-03.zip
Download the source from http://www.cairnsgames.co.za/download.asp?file=files/rtssource0-03.zip

The source will need the EXE images to be able to run.

There are in fact very very minor changes in the way the program was written from 0-02 to 0-03 and the OpenGL calls. In fact only the code for the mini map and the removal of a predrawn background (I draw each tile now) were required - all other changes were done in my Images unit (S2DLImage for those looking at the code).

My thanks to Savage and MSX for thier help over the last few days.

savage
11-06-2005, 07:38 PM
Well done William, scrolls very nicely on my laptop.

{MSX}
11-06-2005, 07:49 PM
Well done!
I tryed to compile it under linux and it went with little changes.. You could consider to correct some things to make it linux compatible.. I'll make lots of people happy :)
Here's a screenshot:

http://www.lugato.net/screenshots/cairnswm.png

PS 180 fps .. not bad :)

cairnswm
11-06-2005, 07:59 PM
Thanks MSX - would you like to let me know what needs to change to make it Linuc compatible.

I want to use scripting for the units - does DWS compile under linux?

savage
11-06-2005, 09:07 PM
According to http://sourceforge.net/projects/dws it does work on Linux, though it only mentions Kylix. Maybe no one has tried using FreePascal.

Another cross-platform alternative is Pascal Script 3.0 - http://www.remobjects.com/page.asp?id={9A30A672-62C8-4131-BA89-EEBBE7E302E6}

cairnswm
12-06-2005, 07:18 AM
Ver 0-03 has a memory access violation at the mottom of the map (easily repeatable if you click the bottom of the minimap) - Already fixed -ver 0-04 should be released later today (I'm planning on adding - map bookmarks and a selection box).

I'm downloading Pascal Script. It doesn;t say compiles under freepascal though. Also does anyone know of a scripting system that DOESNT use the VCL - adding the VCL to my program at the moment adds over 500KB to my file size (from 150kb to 800kb :( )

{MSX}
12-06-2005, 07:31 AM
Thanks MSX - would you like to let me know what needs to change to make it Linuc compatible.

There are three things:
- On S2DLImage you use the graphics unit. I couldn't find this unit on fpc, but you only use it on CopyBitmap function, a function that is not used. You could both remove the function or use some SDL functions instead to copy the bitmap. BTW the unit Graphics is included in another unit (the main one iirc), without being used.
- In S2DLSound you use GetTickCount from Windows. Use SDL_GetTicks from SDL instead.
- In all units, you have wrong case for files to open :P This is bad in a case sensitive filesystem :P
Example: 'images/xxxx.PNG' when the file really is 'Images/Xxxx.png'
Also you could use the / instead of the \
The \ doesn't work on linux, whereas the / works on both (you can also have a DirectorySeparator constant, of course).

It should be all (i'm quite in hurry now :P )

Bye!

cairnswm
12-06-2005, 07:52 AM
I'll start moving it toward being compilable on Linux as well :)

savage
12-06-2005, 09:55 AM
Once you have Linux compatability, MacOS X compatability will be little to no work at all.

cairnswm
12-06-2005, 05:57 PM
Version 0-04

http://www.cairnsgames.co.za/files/rts0-04.jpg

I've added the code to do a selection box.
I;ve added code to place bookmarks on the map - go somewhere on the map and press Ctrl-<Alpha Key> - move somewhere else and press Alt-<Same Alpha Key> to jump back to where you were.
Fixed the memory bug
Increates the scrolling border of the screen - will be better when the screen is full screen anyway.
Made it more linux friendly.

MSX over at www.pascalgamedevelopment.com has already been able to compile the game under linux :)

The Game is available from http://www.cairnsgames.co.za/download.asp?file=files/rts0-04.zip
The Source from http://www.cairnsgames.co.za/download.asp?file=files/rtssource0-04.zip

savage
12-06-2005, 06:26 PM
The Link to the binary does not appear to work.

cairnswm
12-06-2005, 06:54 PM
Fixed. (Note it needs the images as distributed with 0-03)

Traveler
16-06-2005, 07:41 AM
Your latest version ran much better now. 118 fps with a radeon 7000 gfx card. Thats also during scrolling.

You might want to include a resource check upon startup though. I jumped from version 0.1 to 0.4 and I was obviously missing a few images. The error that followed did gave a hint, but a custom error message would be nicer imo.

Anyhow, its looking quite nice. Looking foward to the next update.

HopeDagger
16-06-2005, 02:00 PM
Absolutely love the graphics. I can see that the game is starting to take form in a very attractive manner! Did you make them yourself? :D

EDIT: Just tried the game, and it's crashing on me. Here's the log file it spews out (looks like init problems :/):



STATUS INFO : @ 10:02:37 AM MSG : Starting Application IN : Initialization
STATUS INFO : @ 10:02:37 AM MSG : SDL being started up. IN : S2DLDraws.Initialization
STATUS INFO : @ 10:02:39 AM MSG : Closing down fonts IN : S2DLText.Finalization
STATUS INFO : @ 10:02:39 AM MSG : SDL being closed down. IN : S2DLDraws.Finalization
STATUS INFO : @ 10:02:39 AM MSG : S2DLDraw surface being cleared IN : TS2DLDraw.Destroy
STATUS INFO : @ 10:02:39 AM MSG : Terminating Application IN : Finalization

cairnswm
20-06-2005, 04:46 AM
Sorry about the missing images problem - I'm just trying to save some web space and still be able to keep all the versions on my web site for someone that wants to see the progress.

I may put some FileExists checks at the start and exit if the files dont exist.

I will be continuing the progress a bit later this week - unfortunatly I will also be working 14hour days over the next 2 or 3 weeks so I'm not sure how much time I'll have :(

cairnswm
05-07-2005, 07:21 PM
Done a little work on this again :) - yes I know its about time! :)

I changed the way the items are draw so that they (mostly) are draw in reverse Y order (ie this draws the back items before the foreground items) - mostly - as the position of the item is defined by the topleft corner of the item instead the actual 'feet' of the item.

I have added some skeletons and some robot buildings (thanks WilliamHK - NAG forums - will be doing the robot units for the game) to the program. These items can be selected by using the selection rectangle (Ill add click to select a specific item at a later stage - as well as shift to 'add' select items)

Here is a screen shot:
http://www.cairnsgames.co.za/files/rts0-05.jpg

After creating the image I relealised that the picture making the biggest impact of the size of the download was the trees, so I trimmed out some trees to minimise the download. So the exe only has 8 tree pictures.

The download is here:
http://www.cairnsgames.co.za/download.asp?file=files/rts0-05.zip

If anyone wants the source please PM me with your email address (I'm saving space on my site).

Started implementing some of my object model now.

Basically I have something called an TRTSGame (All classes in Delphi start with a T) - This actually manages the whole game data. It knows how to draw itself and items in it, it knows when to tell items to move, it knows about selecting etc. Any item that needs to know about another item in the game asks TRTSMap about the other item. (Basically a cross between a game object and an object factory).

All items that get displayed on the map are decentant of TRTSItem. An item basically knows how to do very basic functions such as controlling selection, drawing etc. It will have no collision management, no AI options, no movement ability.
From TRTSItem there are a number of branches. For now I just added TRTSUnit and TRTSBuilding - however in the final object model these will probably inherit from a TRTSPlayerItem as opposed to a TRTSObstruction item.

Trees are currently just TRTSItems but will later become children of the Obstruction class. The obstruction class will have no movement or other interaction methods but be a static object that gets in the units way. :)

(Man - its good to get back to game dev... I have spent 150 hours at work over the last 2 weeks - excl travel time).

Traveler
06-07-2005, 08:35 AM
Sweet, another update!

Everything seems to work quit well. I didn't find any bugs in any case, so good work there. I see you're also testing for missing images now :) nice!

As always,.. looking forward to the next version.

PS. I'm not really sure why but your "fan club" at NAG appears to be quite a bit larger. :?

cairnswm
06-07-2005, 09:24 AM
I never knew I had a fan club - If I had known I might have updated my web site more often :)

NAG is a local game magazine - the forum has only been up for a month or so - so a lot more people will be joining the forum over thenext while :)

Keep the bug reports coming - the more testers :) I have now the less errors there will be when I hand it in... I am away (again) this week end - so maybe a change tonight else the saga continues next week. (Also NAG have a contest on for this month so need to develop something for that tooo).

Crisp_N_Dry
06-07-2005, 07:56 PM
60fps (VSYNC enabled I'm guessing) on a GeforceFX 5800. I like the unit selection, very cool. Although a click select is pretty much standard fare for RTS' but I'm sure that's on the way. Keep us updated, this is definately one to watch.

cairnswm
06-07-2005, 08:04 PM
What version of the download are you trying? Versions 0-01 to 0-03 are using straight SDL (pretty much DirectX 5) - and I get a FPS of around 30 on my notebook. From Version 0-04 onwards I have integrated OpenGL with my SDL libraries. Now I get an FPS of about 80.

If you want to look for bottlenecks most of the source code is availabel for download and you can compile for yourself.

cairnswm
06-07-2005, 08:14 PM
Version 0-06

http://www.cairnsgames.co.za/files/rts0-06.jpg

Added life counter to the units.
Added movement (Use rect to select units - right click to move to the location)
Add formations - Up to 9 units will walk and move in formation.

Exe is here (PREVIOUS IMAGE FILES REQUIRED - see RTS0-05.zip)
http://www.cairnsgames.co.za/download.asp?file=files/rts0-06.zip

I want to add Unit animations but that will increase the file download sizes too much. I am going to leave this until later in the process.

I am going away for the weekend. More updates starting sometime around wednesday. :)

lief
07-07-2005, 05:57 AM
cairns, how did you handle formations? once selected will they keep current formation while walking (im at work, cant download it)? I'm workin on a little abstract tactical squad thingo, ive got terrain modifiers, line of sight, viewing arcs (can only see forwards) and waypoints working. i was thinking over a formation system and how strict to make it. its very wooden to have 5 men marching in a five-dot-dice pattern through a forest while chasing the enemy. I was hoping to plan a slightly random path for each soldier, with lagged adjustments so it is more general. More like a swarming algorithm I guess but adding angle estimates to squadmates as well as min & max distances.

cairnswm
07-07-2005, 06:33 AM
At the moment I'm using the 5 dot dice pattern :) Add a little bit of randomness to where they stop/start and you should have something that looks quite good.

When it comes to movement each unit will use their own path finding system. This means that they will not walk in the formation but will each choose their own path. While walking they will check collisions along the path and stop when bumping into each other. (Too many bumps will mean trying to find a new path).

While using swarming to manage the formations I feel it is important to weigh up the amount of work to benefit, at this time I feel something like that will not add greatly to what I am achieving. Therefore the 5 dot dice pattern (10% work effort - 80% as good) is the better option.

Because of the limited time I have to work on games (usually about 4-8 hours a week) I always do this sort of cost/benefit evaluation. I want to get games done and finished. If they are only 80% of what they could be because of using the 10-20% effort routines well thats fine :) Remember the old adage - 80% of the work is in 20% of the code - I just always avoid that 20% of the code :)

lief
07-07-2005, 06:50 AM
that is a good adage. here's another one - "10% of the work is coding the game, 90% is your wife letting you have enough time to even bloody well think about planning a game"

yes with the movement. a final positioning should be more important than how each soldier individually gets there, that sort of sums up what i was saying (or trying to say).

does your system allow for other formations? how does it actually get the soldiers into position, does it calculate the 4 corner soldiers from the middle soldier? a lot of systems seem to keep track of available positions in a formation block, when a soldier is sent to a position inside the formation block it requests an available position, if no position available then a new formation is built.

my system only works because it is not a rts, and I know the maximum amount of soldiers I have on each squad.

you have a waypoint system working yet?

cairnswm
07-07-2005, 07:02 AM
Ok this might be embarassing but:

Const
Formation : Array[0..8] of Record DX, DY : Integer End =
((DX:0;DY:0),(DX: 30;DY: 30),(DX:-30;DY:-30),
(DX:-30;DY: 30),(DX: 30;DY:-30),(DX: 0;DY:30),
(DX: 0;DY:-30),(DX:30;DY:0),(DX:-30;DY:0));
procedure TRTSMap.MoveItems(X, Y: Integer);
Var
I : Integer;
Item : TRTSItem;
IC : Integer;
Begin
IC := 0;
For I := 0 to Items.Count-1 do
Begin
Item := TRTSItem(Items[I]);
If Item.Selected then
Begin
If IC < 9 then
Item.MoveTo(X+Formation[IC].DX,Y+Formation[IC].DY)
Else
Item.MoveTo(X+(Trunc(Random*120)-60),Y+(Trunc(Random*120)-60));
IC := IC + 1;
End;
End;
end;


Thats the complete code for the formations and controlling the Movement of units :oops:

So I have a fixed formation system. I might entend this later to manage formations of different number of units - for example four guys might stand around the move to point, two guys might stand left and right of the point :)

I dont think I'll use a way point system. My method of doing collision detection and path finding seems to be efficient enough not to require it. I have in the past worked out how to do a way point type system. For pathfinding and collision detection I create a collision array that overlays the map. Each item in the map registers their presence against one or more spaces in the collision array. When any object moves it does:
:arrow: Remove Self from Collision Array
:arrow: Calculate Destination Position
:arrow: Check Destination Position againsty Collision Array
:arrow: If Empty - Add self to Collision Array at new location
:arrow: Else Put self back at Old Position (Then decide about attacking etc)
:arrow: Remove from Draw Array
:arrow: Add to Draw array in new location (Only neccessary if Y changes)

For a way point system I'd implement a different system where the map is broken into sectors - each sector knows its neighbours and if a unit can move from one sector to another - pathfinding first finds the shortest sector route then does pathfinding through these sectors to the final destination - ignoring all area outside these sectors. (Not quite way points but then I'm using not quite A* pathfinding - (see very old post in tutorials forum)) :)

cairnswm
07-07-2005, 07:10 AM
"10% of the work is coding the game, 90% is your wife letting you have enough time to even bloody well think about planning a game"


I have been married for 12 years :) My wife and I did go through a period where this was a problem. We ended up sitting down and having a discussion about the problem. We resolved as follows -

:arrow: William is not allowed to sit at his computer until 8pm at night. This applies to every night except Sunday and Thursdays which are family (wife) nights.
:arrow: Saturdays and Sundays William is allowed to work on his PC unless Yolande wants him to do something else - then the something else always comes first UNLESS agreed up front that William wants time - ie Game Dev Contest - LD48 and GDC72 for example.

Now - William has as much time at the PC as he can do without sleep - But I find I have to be asleep by 11pm else I dont funtion right. Also PGD and other sites take up much too much time :P

Sly
07-07-2005, 07:51 AM
Sounds familiar. I got married and suddenly had less time on the PC than before. :)

Traveler
07-07-2005, 09:04 AM
LOL :)

There are times I enjoy being single :)

lief
07-07-2005, 10:28 PM
We ended up sitting down and having a discussion about the problem. We resolved as follows


... We resolved as follows


...resolved...

i don't understand, I thought you said you were married...
that code should work find for formations, you could set it up as instead of points you use a grid, with flags on and off for each sector as available positions so:

x-x
-x-
x-x

would be a 5-dot formation like you have. this way you could resize the grid object and the formation would automatically spread.

Crisp_N_Dry
08-07-2005, 05:27 PM
Cairnswm -
I was using version 0.5 previously before, in fact I tested all of them. 0.3 crashed everytime but that's not an issue now. However, 0.6 which I just downloaded is missing all but one of the image files and so halts on startup. I ransacked the 0.5 zip file and cppied the images over. Just a heads up, not really a big deal unless somebody doesn't have the previous versions in which case you might miss out on some valuable feedback. Anyways, 0.6 ran at the same speed as 0.5. I dare say the refresh on your laptop is 80hz hence the 80fps framerate, whereas my monitor is running at a 60mhz refresh (2 year old TFT). I would check out your code but time constraints don't allow for it, not tonight anyway. The earlier versions (pure SDL) ran at 30 frames at best which seemed very slow considering what it was doing but since you are now using OpenGL this shouldn't be a concern.



There are times I enjoy being single My wallet loves me for it :D

cairnswm
13-07-2005, 05:06 AM
However, 0.6 which I just downloaded is missing all but one of the image files and so halts on startup.

I was aware of this - therefore my note in the previous message of:

(PREVIOUS IMAGE FILES REQUIRED - see RTS0-05.zip)

I am just trying to save a bit of space :) RTS0-06.zip has only been downloaded a total of 8 times and I dont think I should waste the web space for that few interested people :(


Anyway - onto the next post :)

I've been doing some thinking about optimisation of drawing for a while now. Basically while sitting on holiday for the weekend I gave some thought to the following:


For I := 0 to DrawItems.Count -1 do
Begin
Item := TRTSItem(DrawItems[I]);
If (Item.X > MapLeftInt-128) and (Item.X < MapLeftInt + 928) and
(Item.Y > MapTopInt-128) and (Item.Y < MapTopInt + 728) then
Item.Draw;
End;


Obviously the first optimisation is to stop checking once Item.Y is no longer in the area. Also some changes to the 128 number can improve it a bit as well. And of course pre calculating the (MapLeftInt-128) calculations.

HOWEVER :)

(I think this solution is sort of a quadterion (sp?) solution).

What if I have an array covering my map in 16x16 pixel areas (similar to my collision array I use for collision checking - defined elsewhere). Each time an item moves it updates its feet position into this array. When drawing the screen I just go through all the drawing array squares, if an item is positioned in the array at that square then I draw the item.

This means I would have 3000

If DrawArray[I,J] <> nil then


as opposed to the big If statement above. As the statement above is already doing an assignement, and a number of checks I think this may be faster. (I suppose I need to check it :) )

Also

What about splitting the DrawingItems List into multiple lists - each covering a half of the screen, when an Item is registered into the draw list it gets put into the draw list relevant for its locations. This way I need to cycle a max of 9 lists to get the objects instead of having to check every object in every location.

Any ideas?

lief
13-07-2005, 05:34 AM
Keep a track if objects were drawn last frame... if not, only do checking if they haven't moved (or camera position moved). would need to add an extra flag to track this.

i presume the first thing you posted was just a screen area check?

i call this fantasy pascal

on Event MoveObject
Object.draw_flag := Object is inside ScreenRectangle
Object.might_need_to_draw_soon_flag := Object is inside SlightlyBiggerThanScreenRectangle

on Event MoveCamera
check all objects with might_need_to_draw_soon_flag to see if they need their draw_flag set or unset

or instead of the draw_flag, which would cause you to need to still check every object, if the object needs to be drawn, just keep one list. why do the array squares if they all need to be drawn anyway? aha... you might need the z order kept correct yes? no.. that wouldnt work for multiple objects in grid square... hmmm

anyway...

keep three lists and housekeep them every so often.... (you might be able to figure a way so you don't have to do a full sort every processing cycle)

the lists

1. Will not need to draw now, next frame, or the next 10 frames...
2. Not drawing now, but hey, you never know what will happen... sprites move, cameras pan...
3. Lights, camera, action!

this probably doesn't help you at all.
hehe

Paulius
13-07-2005, 08:34 AM
Partitioning space for movable units is very likely to be slower than simple culling using bounding rectangles, you could make a container object with a pretty large bounding box and put all unmovable objects in its area in it, so if it?_Ts culled you don?_Tt draw objects which it owns. You could also optimize for OpenGL, but since it?_Ts not likely to become you?_Tre bottleneck you may not want to bother and it will break you?_Tre current structure. You?_Tre objects shouldn?_Tt know how to draw themselves, but better just contain material and coordinate data. You should do some kind of material management to minimize state changes, you could sort objects by material or at the very least check if it?_Ts the same as the current one and doesn?_Tt need to be passed to OpenGL again. glbegin/glend are also a bit expensive, sorting by material will help you to minimize them.

Traveler
09-08-2005, 07:10 PM
What's happening cairnswm? Last update was over four weeks ago. Are you still working on this? (please say yes :roll:)

cairnswm
10-08-2005, 04:17 AM
Yes, I will still be working on it. Just too hectic at work at the moment. I dont seem to feel like doing anything on my PC at home at the moment.

The project should be going into testing next week and hopefully I'll have a lot more time from then. I will also probably be taking a few days off in early october to work on the game as well.