PDA

View Full Version : Modifing TBackgroundSprite



kotai
04-11-2005, 01:48 AM
Hi, sorry my but english.

I have a TBackgroundSprite and i modifing in execution. Is a car game and i want cars paint the track when brake.

I modify surface, but not persistent:

DXDraw.Surface.Canvas.Pixels[Player.X,Player.Y] := clblack;

my code:


SpriteFondo : TBackgroundSprite;

.......

SpriteFondo := TBackgroundSprite.Create(DXSpriteEngine.Engine);

........

SpriteFondo.SetMapSize(1024,768);
SpriteFondo.Image := DXImageList.Items.Find('Circuito');
SpriteFondo.Tile := True;
SpriteFondo.Z := 0;

.........

DXSpriteEngine.Engine.X := -Player.X + DXSpriteEngine.Engine.Width div 2;
DXSpriteEngine.Engine.Y := -Player.Y + DXSpriteEngine.Engine.Height div 2;

.........

DXDraw.Surface.Fill(0);
DXDraw.BeginScene;
DXSpriteEngine.Draw;
..................................
DXDraw.EndScene;
with DXDraw.Surface.Canvas do
begin
.........
Relase;
end;
DXDraw.Flip;

the games is: www.miniracingonline.com

Thanks.

LP
04-11-2005, 02:37 AM
Looked at screenshots and... wow! :shock: That's a nice game!! :) It's been too long (5+ years) since I used DelphiX so can't help you :(

Lo que si, veo que el juego esta en espaA±ol... no esta nada mal! Ya quiero jugarlo...

Traveler
04-11-2005, 08:46 AM
Welcome to PGD!

Your game sure looks mighty nice! Im curious how did you do the background. Are those large imagemaps?

Anyhow, your question:
Changing de pixels of the surface like you suggested is certainly an option, but a very slow one a that, so not very favourable. Alternative you could draw a line between the point where braking starts and where it ends.
Drawback of this approach is that you can't create curves very easily.

czar
04-11-2005, 09:53 AM
Your game looks pretty good but it is still not very user friendly.

Took me a while to realise I could get the program use English.

It crashed twice during start up. Black screen with the music going and them bang. Send report to microsoft.

I found the setup screens very busy - especially if you just want a quick start. An instant action option would be great.

The track editor locked up on first go. I opened a track and that was that I had to ctrl-alt-del to kill the task.

I am using ATI 9700 Pro with recent drivers, windows XP with 1 gig RAM etc etc. Just in case you are wondering.

However, I think I will just have another go at racing.

kotai
09-11-2005, 03:41 PM
Hi.

The background are large image (1024 x 768 to 8192x4096)

The problem is that paint surface the change is not persistent. I was modify background, not paint over background. A¬ø How I can modify background ?


Since I change to unDelphiX I have a lot of problems when close game: "exception class EAccessViolation..." and "external exception....". With DelphiX (hori) i not have problems (but not compression in sockets and directx 6)

The version 0.81A is stable but 0.81E or latter not.
The track editor is more slow if you load a big circuit, please wait.


Asqs:

1) how can I modify background to make braking marks persistent? (without painting it in each frame)

2) anybody knows how to close a Delphix application without closing errors?

Close Procedure:

procedure TF_Principal.FormClose(Sender: TObject; var Action: TCloseAction);
begin
try
if Cerrando then
begin
Action := caNone;
exit;
end;
Cerrando := True;
DXTimer.Enabled := False;
DXDraw.Finalize;
DXDraw.Destroy;
DXSound.Finalize;
DXSound.Destroy;
DXSpriteEngine.Destroy;
DXImageList.Destroy;
DXPlay.Destroy;
DXTimer.Destroy;
DXInput.Destroy;
except
end;
end;


Thanks

kotai
09-11-2005, 04:10 PM
a screenshot of the game:

http://72.41.111.248/images/previews/01.JPG ('http://72.41.111.248/images/previews/01.JPG')

Kotai.

Legolas
09-11-2005, 04:13 PM
Hi.
1) how can I modify background to make braking marks persistent? (without painting it in each frame)

2) anybody knows how to close a Delphix application without closing errors?



About 1): what about using for braking marks something like particles? You could redraw only when visible and write an array of coordinates, in order to redraw when you reload the level.

About 2): do you have tried using free instead of destroy?

Some considerations: your game looks wonderful! :shock: Maybe you should try to optimize backgroud. Splitting it in smaller blocks and dynamically loading it could waste a smaller amount of resources, IMHO

savage
09-11-2005, 05:20 PM
I definatley agree, you should never be calling Destroy/Finalize directly. Calling the class' Free method is the correct way of freeing any object and this will call Destroy/Finalize internally at the right time.

czar
10-11-2005, 07:39 PM
Hi there,

Just tried running your program at work and it won't start up here either. You must have some serious issues still in your game.

As for delphix. I find that you have to free some of the components yourself e.g.

dxsound1.free; dxwavelist1.free; etc

That works for me.



Computer that didn't work; win xp, 768 ram, fx 5200 ultra dx 9.

Computer that did work AMD 3200 with NVIDIA GeForce 6600 GT

---

Observations:
1. I hate the way that way that the car just dissapears when going under bridges and sign. Looks terrible. Why not draw a bitmap over the top of the car.

2. We all agree at work you need a quick race option.

3. Rotating of the car is not very smooth.

4. Drive to top left hand corner, turn around and drive back to start line and hey presto lap won.

Traveler
10-11-2005, 09:34 PM
In regards to the drawing question.
Make sure you draw on the background surface, not dxdraw surface.
Have a look at this (http://www.pascalgamedevelopment.com/viewtopic.php?t=2560&start=0l) thread and check Crisp_N_Dry or my answer there to IaxFenris' question, i believe it's what you need.

User137
16-11-2005, 11:52 AM
If you draw on buffer surface instead of DXDraw.surface it may not show or is not accelerated if that bug still exists in undelphix...

to onClose event:
DXDraw.Finalize;

Edit: Hmm, maybe that buffer will work. For simple pixels there is no need to draw accelerated graphics on buffer :D However Canvas and acceleration is still a bad combination. You might consider making break marks as particles that start fading out after certain time or amount.

czar
17-11-2005, 07:58 AM
I made a supersprint type game a few years ago and solved the braking skid mark problem by using particles as suggested above. They had a certain population limit so that if too many were being drawn the oldest ones died.

ijcro
08-12-2005, 07:20 PM
Hello
You can try new version of TSpriteEngine from unDelphi...
Tile of TBackgroundImage can be accelerated and can be blended or added drawing....