# Pong help

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

## Recommended Posts

I decided to cook up a quick pong remake, and I'm in need of some help. First of all I need some CC. (Before anybody posts, I know that I need to add 1)sound 2)more menus (and possibly options) 3)A paused state) Note that I only worked on this for 30 minutes, so some of it doesn't always work right. I've searched for articles on pong ai and found EnemyBoss's post of his code. I plugged it in and it 'kindof works'. First off, since my ball doesn't have fancy directions on it, it almost always goes the same way (I'm working on figuring this out). You ALWAYS score the second time the ball bounces. Any help and comments would be appreciated. Thanks! Edit: Fixed the link I guess it helps if I post the link:Ricochet (Sorry, I didn't get very much sleep yesterday.) [Edited by - Programmer16 on June 22, 2005 10:00:42 AM]

##### Share on other sites
As for your ball, you could easily make it move differently each time by making the x and y directions have different speeds. Start them out with the same speed then when the ball hits a paddle, add a random # between whatever and whatever. That way the ball will always have different ways to go.

##### Share on other sites
Thanks kelcharge, I'll do that.

I'm having some wierd artifacts show up in some of my graphics. I have code that is loading my textures (the code is exactly the same for each, other than a different filename and texture pointer), they all seem to load fine. Then they are rendered like so:
D3DXCreateTextureFromFileEx(g_pDevice, "Textures\\MainMenu.bmp", D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, D3DX_FILTER_NONE, D3DX_FILTER_NONE, 0xffff00ff, 0, 0, &g_pMainMenu);D3DXCreateTextureFromFileEx(g_pDevice, "Textures\\Paddle.bmp", D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, D3DX_FILTER_NONE, D3DX_FILTER_NONE, 0xffff00ff, 0, 0, &g_pPaddle);D3DXCreateTextureFromFileEx(g_pDevice, "Textures\\Ball.bmp", D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, D3DX_FILTER_NONE, D3DX_FILTER_NONE, 0xffff00ff, 0, 0, &g_pBall);D3DXCreateTextureFromFileEx(g_pDevice, "Textures\\Background.bmp", D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, D3DX_FILTER_NONE, D3DX_FILTER_NONE, 0xffff00ff, 0, 0, &g_pBackground);

Draws the textures
if(g_bMainMenu){	g_pSprite->Draw(g_pMainMenu, 0, 0, &D3DXVECTOR3(242, 241, 0), 0xffffffff);}else{	g_pSprite->Draw(g_pBackground, 0, 0, 0, 0xffffffff);	g_pSprite->Draw(g_pPaddle, 0, 0, &g_LeftPaddle.GetPosition(), 0xffff0000);	g_pSprite->Draw(g_pPaddle, 0, 0, &g_RightPaddle.GetPosition(), 0xff0000ff);	g_pSprite->Draw(g_pBall, 0, 0, &g_Ball.GetPosition(), 0xffffffff);			RECT WndRect;	GetClientRect(g_WndHandle, &WndRect);	char Msg[256];	sprintf(Msg, "Player 1: %i\nPlayer 2: %i", g_nLeftScore, g_nRightScore);	g_pFont->DrawTextA(g_pSprite, Msg, -1, &WndRect, 0, 0xff000000);}

My Background render fine and my left paddle renders fine, but the right paddle and ball seem to have filtering on. They all have power of 2 sizes and are square (width == height).

Also, I'm adding a background and I'm going to add animated graphics (like the paddles, balls, and buttons)

Edit: And just in case somebody asks, I'm doing this in C++ with DirectX9.

##### Share on other sites
One, you just might want to add the required dll's to your game. Also, do the graphics that have artifacts in them get them when they move, or do they have them all the time? The only time that I have achieved artifacts in my graphics is when my components in my PC overheat. Hope that helps some.

##### Share on other sites
I didn't realise that it needed a dll, but I just upgraded my DirectX, so it probably needs d3dx9_25.dll?

I wouldn't really call them artifacts, but the graphics aren't appearing like they shoud (only the right paddle and the ball; the left paddle is fine.) They seem to have filtering turned sometimes (because my black lines are blending.)

Also, it only does it sometimes, not always.

##### Share on other sites
Didn't run at all on my computer, could be due to my lack of video card though [smile].

##### Share on other sites
Sorry guys, I screwed up my device creation (I just tried hardware instead of both.) I've fixed it, and uploaded the new version. It now has a background and a smaller ball.

Ricochet

Thanks!

##### Share on other sites
Work great here! Only comment is, the ball at one point was bouncing pretty much straight up and down, and taking ages to get to the other side. You should introduce some type of constraint :)

##### Share on other sites
Thanks. I noticed that if the ball hit the top or bottom of a paddle, it would start going up and down (straight, so it just sat there.) I'm working on fixing this. Also, I fixed my download (I included the d3dx9d_25.dll instead of d3dx9_25.dll). Evidentally this is new this year (I've been using last years version, so I didn't know that I had to include this.)

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 10
• 11
• 13
• 9
• 11
• ### Forum Statistics

• Total Topics
634092
• Total Posts
3015447
×