Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

gameprogrammerwiz

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

This topic is 6937 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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 !)

}

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!