loadimage...ok...now go away!

Started by
5 comments, last by gameprogrammerwiz 23 years, 12 months ago
a not before i ask my question: you may have noticed that i have posted about 5 messages on this board in the last 3 days. you may be thinking that you''re programming my game for me. well, you''re not. i only have problems coding in directdraw. i''m begining to understand it now though, because i have started examining the code, and figuring out what each line does. ============================================================ anyway...in my last post, i asked about using the mouse to control the users walkability. ive scrapped that idea, i want to use the keyboard to control everything. i wrote a good chunck of code that puts a red isometric marker on map, and the user an use the arrow keys to control the marker, and the warrior in my game, fallows the marker around. now, i have another problem. the marker, leaves a trail of where its been before. i need to know how to clear all of the images on the lpDDSmarker surface.
==============================
whats a signature?
htm[s]l[/s]
Advertisement
Rather than clear all of the images on the back surface, you should copy your background again on it.

Here''s a piece of pseudo-code :

void draw_my_frame()
{
... // Do some stuff

// Draw the background on the surface

backSurface->FastBlt( 0, 0, NULL, myBackground, flags);

// Draw all your sprites (your marker)

backSurface->FastBlt( 0, 0, NULL, coulMarker, flags);

... // Other stuff (flip surface !)

}

Dude, nobody thinks they''re writing your program for you. DirectX is incredibly difficult in semantics when you first start it. When I started, all I could do was ask ''simple'' questions like "how do I make a surface?" "how do I get a pointer to that surface" and "why do I get a blank screen."

DirectX, OpenGL, and all these API programs are written with someone''s idea of a good linear system in mind. Chances are, it''s not yours. I know it''s not mine. Now that I''ve learned it, I see the efficiency of it, but when I was first starting, the methods of the calls, and the idea of calling a function so that you can get the next function, so that you can get the next function, so that you can get the function that initializes directx was incredibly alien to me. It was like the first time I tried assembler-- but assembler was EASIER because assembler is a simpler language than directx. And the amount of background knowledge you need to know in order to make the simplest directx program in incredible.

So keep asking. And one day, keep answering. There''s always gonna be new folks.


-- Goodlife

-----------------------------
Think of your mind as a door on a house. Leave the door always closed, and it's not a house, it's a prison. Leave the door always open, and it's not a house, it's a wilderness-- all the vermin creep in.
-- Goodlife-----------------------------Those whom the gods would destroy, they first drive mad.--DirectX design team official motto
Ok, dont actually understand what you want to do. But, if you want to clear a surface you can use a simple blitterFill,(Dont remeber the precise syntax) or use a
memset :
1. Lock the surface and retrieve address of surfaceData...
2. Calcultate number of bytes to clear, ie) pitch*ysize
3. memcpy(surfaceDataPtr,0,size)

Hope this helped, otherwise send me a mail and can
help you out...

/tooon
well, that could work, but it wont accomplis what i want to do, for some reason, the more images a i pain on the screen, the more it lags. i only said "for some reason" because i only paint about 2 images before it starts lagging, so if i just redraw the tile''s surface over each marker point, it will lag down. i know this is hard to understand, if anyone wants to look at the source or the program i will email it to you.
==============================
whats a signature?
htm[s]l[/s]
woah, look at all those typos! this is what i meant to say:

well, that could work, but it wont accomplish what i want to do, for some reason, the more images a i paint on the screen, the more it lags. i only said "for some reason" because i only paint about 20 images before it starts lagging, so if i just redraw the tile''s surface over each marker point, it will lag down. i know this is hard to understand, if anyone wants to look at the source or the program i will email it to you.

fyi: one reason my program may be lagging is my own computer, its OLD. about 5 years old. i do have a new one thats only 2 months old, and my program works fine on it.
==============================
whats a signature?
htm[s]l[/s]
ACK NO! I saw someone''s post for how to clear the back buffer. Please don''t use that, it''s way to slow! Use something like this instead and let Blt do the work it''s supposed to do:

bool CDirDraw::FillSurface(LPDIRECTDRAWSURFACE7 pSurface, int r, int g, int b) {	// Check for valid surface	if (!pSurface) return false;	// fill that puppy	DDBLTFX ddBFX = {sizeof(ddBFX)};	ddBFX.dwSize = sizeof(ddBFX);	r = (r >> (8-pPixel.bR));	g = (g >> (8-pPixel.bG));	b = (b >> (8-pPixel.bB));	ddBFX.dwFillColor = (r<	HRESULT hr = pSurface->Blt(NULL, NULL, NULL, DDBLT_COLORFILL, &ddBFX);    return SUCCEEDED(hr);} 


In case you''re wondering what all the pPixel.sR stuff is, it''s my way of keeping track of the pixel format. bR is the number of bits for Red, etc. sR is the "shift", etc. You can use your own methods here, whatever works the best for you.
-Michael

This topic is closed to new replies.

Advertisement