• Create Account

## erasing text

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

31 replies to this topic

### #1phil67rpg  Members

215
Like
-2Likes
Like

Posted 30 October 2012 - 07:49 PM

case WM_TIMER:
{
switch(wParam)
{
case ID_TIMER:
{
HRESULT hr=D3DXCreateFont(g_pd3dDevice, //D3D Device
22, //Font height
10, //Font width
FW_NORMAL, //Font Weight
1, //MipLevels
false, //Italic
DEFAULT_CHARSET, //CharSet
OUT_DEFAULT_PRECIS, //OutputPrecision
ANTIALIASED_QUALITY, //Quality
DEFAULT_PITCH|FF_DONTCARE,//PitchAndFamily
"Arial", //pFacename,
&g_font); //ppFont

D3DCOLOR fontColor = D3DCOLOR_XRGB(0,0,0);
RECT rct;
rct.left=200;
rct.right=600;
rct.top=20;
rct.bottom =50;
g_font-> DrawText(NULL,"Welcome to DX9 Pong",-1,&rct,DT_CENTER,fontColor);

KillTimer(hWnd,ID_TIMER);
}
break;
}
return 0;
}
I am using the windows timer function to draw black text to the screen to cover up red text which I already drew to the screen.
I am trying to erase text for my pong game.I have done a lot of research on this topic but I still need help.

### #2SiCrane  Moderators

11526
Like
4Likes
Like

Posted 30 October 2012 - 07:56 PM

I don't know why this is so hard for you to understand: if you make a post and you have a question, then you need to actually ask the question. If you have an error you can't figure out, post the error. If you have a problem, describe the problem. Just posting code and saying that you are having troubles doesn't cut it.

### #3phil67rpg  Members

215
Like
0Likes
Like

Posted 30 October 2012 - 08:06 PM

ok well my problem is that I can write to the screen using text but I want the text to only be there for 5 seconds and then I want to erase the text I want the player to read the instructions on how to interact with the mouse and then vanish so the player can play unimpeded. I have also decided to have the left paddle to be controlled by the computer. That is my next problem.

### #4L. Spiro  Members

24837
Like
0Likes
Like

Posted 30 October 2012 - 09:20 PM

Every time I see, from the list of topics, a topic started by phil67rpg, I put my hand to my forehead and look down, not dissimilar to this:

I already know what is inside before I click it:
• A code dump.
• Without [CODE] tags.
• 1 or 2 sentences explaining what he wants to happen.
• But not what actually happens.
• No actual question.
So this time I bet my friend that the contents of this topic would be as per my expectations.
I just won $1 (approximately). I tend to just stay away from these topics because just reading them frustrates me. phil67rpg, you can read any other topic anywhere else on the forum to see how a proper question looks, what it contains, the fact that code is inside [CODE] tags, etc. You have been here long enough to have actually seen other topics before, so there is no excuse for the way you ask questions. Even after you were asked to actually ask a question, you didn’t! You just explained what you want, not what actually happens, and there was no question. Twice! How hard is it to ask a question? Check any other post. You have literally 10’s of thousands of examples. There are even places you could check online that are meant to specifically help you learn how to ask questions. http://www.google.co... Ask a Question Thank you for the$1, but I couldn’t help you even if I tried. No one can.
You don’t know how to ask for help. You give no information at all that someone could use to help you. Every. Single. Time.

Others are obviously just as frustrated by it.
Until you learn how to ask questions…

L. Spiro

Edited by L. Spiro, 30 October 2012 - 09:23 PM.

### #5phil67rpg  Members

215
Like
1Likes
Like

Posted 30 October 2012 - 09:43 PM

well thanks I like the thumbnail picture, and yes star trek rocks.

### #6phil67rpg  Members

215
Like
1Likes
Like

Posted 01 November 2012 - 04:58 PM

My problem is that I can use dx9 to print text to the screen. I created a font and used the drawtext function to print text to the screen. What I want to do is that after the text is sent to the screen that the text would be cleared from the screen. Basically all I want to do is give instructions to the player on how to interact with the GUI and then to be able to play the game without text on the screen. This is something like a splash screen. I have tried printing text to the screen in red color and then printing the same text to the screen in black but it does not erase the text that is already printed there. I hope you can understand my problem and hopefully help me to solve. Let me know if need more information or code.

### #7SimonForsman  Members

7585
Like
0Likes
Like

Posted 01 November 2012 - 05:28 PM

aren't you clearing the screen each frame anyway ? , if so couldn't you just stop drawing the text when you no longer want it to show up ?
I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

### #8Daniel_RT  Members

484
Like
0Likes
Like

Posted 01 November 2012 - 05:35 PM

I've never used ID_TIMER, is it called every frame? Anyway just create a bool and stick an if check around your draw text function? The bool becomes false when you don't want the text, I.e. new screen. Also why would you think drawing black text over red would erase it? Did you not think that it would draw black text? If that timer message is called all the time then you might want to re locate that create font code

If ( bSplashScreen )
// draw text

### #9fastcall22  Moderators

9747
Like
0Likes
Like

Posted 01 November 2012 - 05:39 PM

What I want to do is that after the text is sent to the screen that the text would be cleared from the screen

I have tried printing text to the screen in red color and then printing the same text to the screen in black but it does not erase the text that is already printed there.

You cannot erase what is already drawn to the screen. If you had an integer x, would you be able to see what values it previously held? No, keeping track of such data for every variable and every pixel is infeasible. It is faster and easier to redraw everything, excluding the stuff you don't want visible.

Phil, I strongly recommend researching game loops and structuring your game accordingly. In your case, it probably look something like this:

load_fonts

while ( not user_quit ) {
while ( events_to_be_processed )
process_window_event()

clear_screen()
draw_game()
if ( should_draw_instructions )
draw_instructions()
}

release_resources
release_fonts


Edited by fastcall22, 01 November 2012 - 05:51 PM.

zlib: eJzVVLsSAiEQ6/1qCwoK i7PxA/2S2zMOZljYB1TO ZG7OhUtiduH9egZQCJH9 KcJyo4Wq9t0/RXkKmjx+ cgU4FIMWHhKCU+o/Nx2R LEPgQWLtnfcErbiEl0u4 0UrMghhZewgYcptoEF42 YMj+Z1kg+bVvqxhyo17h nUf+h4b2W4bR4XO01TJ7 qFNzA7jjbxyL71Avh6Tv odnFk4hnxxAf4w6496Kd OgH7/RxC

### #10L. Spiro  Members

24837
Like
0Likes
Like

Posted 01 November 2012 - 05:49 PM

My God. It learns.

As was mentioned, standard practice is to clear the screen every frame within a game loop, such as the one provided by fastcall22.

Each frame you draw only what you want to be on the screen. This way you don’t have to keep track of what you had drawn in the past.
Imagine any 3D game that had to keep track of what it had drawn last frame and carefully erase that before putting a new image up.
Therefor you redraw the entire screen every frame after clearing it to black at the start of the frame. Draw only what you want to appear each frame and don’t draw what you don’t want to appear. No fuss with timers.

L. Spiro

### #11phil67rpg  Members

215
Like
0Likes
Like

Posted 01 November 2012 - 05:54 PM

thanks spiro, I will work on your solution. I will study up on game loops.I am trying to write better questions.

### #12Khatharr  Members

7674
Like
0Likes
Like

Posted 03 November 2012 - 05:50 AM

OMG Spiro. Laughing so hard.

ね, スピロさん, 日本語がわかりますか?

Edited by Khatharr, 03 November 2012 - 05:58 AM.

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

### #13phil67rpg  Members

215
Like
-1Likes
Like

Posted 03 November 2012 - 02:03 PM

I have done a great deal of research about game loops, message pumps, windows messages, windows threads and timer functions. I also read about splash screens and finite state machines. I still want to erase text on the screen. After much research I am still stuck on how to solve this problem. Google is my friend. Go easy on me I am attempting to ask better questions. Basically I am confused about how to use game loops.My question is when in the game loop do you print text to the screen and then print black text to the screen. Fastcall22 gave me some code and a explanation on how to use game loops I would like just little more information on how to use game loops.

### #14Khatharr  Members

7674
Like
0Likes
Like

Posted 03 November 2012 - 05:49 PM

Such as?
void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

### #15mhagain  Members

12437
Like
0Likes
Like

Posted 03 November 2012 - 06:27 PM

OK, fundamental misunderstanding here.

When you're drawing stuff you don't just set down a baseline and then only change stuff that needs to be changed.

Instead, for each frame, you first clear the screen - everything goes away - then you draw everything all over again. The "draw everything all over again" part is where you can remove stuff that you don't want to draw and add new stuff that you do want.

This flies in the face of all logic if you come from an "everything is software" mode of thinking, but this is actually the way GPUs like to be used. So don't try anything tricksy to circumvent it; instead use your GPU the way it wants to be used and it will be good to you in return.

If by now you're recoiling in horror and thinking "surely that's going to give awful performance" - remember - Quake did this in 1996. It wasn't a problem then and it's not a problem now.

Edited by mhagain, 03 November 2012 - 06:33 PM.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.

### #16phil67rpg  Members

215
Like
-1Likes
Like

Posted 03 November 2012 - 08:07 PM

hey kathar thanks for the reputation boost, and to mhagain can you post some code.

### #17Such1  Members

435
Like
0Likes
Like

Posted 03 November 2012 - 08:40 PM

Ok, I don't think you are actually learning DirectX, you are just using precoded functions right?
I would suggest you to learn about it first, you are missing the basic of it while you are trying to create a game.
If you don't want to get stuck in every single thing you want to do you should learn how DirectX works.
http://directxtutorial.com this is a good site to get started.

### #18phil67rpg  Members

215
Like
0Likes
Like

Posted 03 November 2012 - 08:51 PM

ok I am going to study this tutorial, then later go back to my game

### #19phil67rpg  Members

215
Like
0Likes
Like

Posted 03 November 2012 - 09:52 PM

I give up on dx9.I am going to study up on win 32.

### #20Such1  Members

435
Like
0Likes
Like

Posted 04 November 2012 - 12:27 AM

I assume you already familiar with c++, right?

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.