HELP!!!!

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
bexrazyallday
Posts: 2
Joined: June 2nd, 2012, 6:40 am

HELP!!!!

Post by bexrazyallday » June 2nd, 2012, 6:51 am

Hey chili, I was going to make a game that involved a triangle spaceship that moved around and collected stuff. I am confused on how I get it to move as one object. As you will see that when you move around with the arrow keys, the triangle is there, but it doesn't move. All that happens is the line segment moves. Is there any way to make it all move as if it were one object? I am using your standard line drawing technique from your 10th video.


/******************************************************************************************
* Chili DirectX Framework Version 11.12.17 *
* Game.cpp *
* Copyright 2011 PlanetChili.net *
* *
* This file is part of The Chili DirectX Framework. *
* *
* The Chili DirectX Framework is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* The Chili DirectX Framework is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with The Chili DirectX Framework. If not, see <http://www.gnu.org/licenses/>. *
******************************************************************************************/
#include "Game.h"

Game::Game( HWND hWnd,const KeyboardServer& kServer )
: gfx ( hWnd ),
kbd( kServer ),
x( 400 ),
y( 300 ),
r( 0 ),
g( 255 ),
b( 0 )
{}
void Game::LineMovements()
{
if (kbd.RightIsPressed())
{
x = x + 1;
}
if (kbd.LeftIsPressed())
{
x = x - 1;
}
if (kbd.UpIsPressed())
{
y = y - 1;
}
if (kbd.DownIsPressed())
{
y = y + 1;
}
}
void Game::Go()
{
gfx.BeginFrame();
ComposeFrame();
gfx.EndFrame();
}

void Game::ComposeFrame()
{
LineMovements();
gfx.DrawLine(350,300,x,y,r,g,b);
gfx.DrawLine(350,300,400,250,r,g,b);
gfx.DrawLine(400,250,450,300,r,g,b);
gfx.DrawLine(350,300,450,300,r,g,b);
}

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: HELP!!!!

Post by chili » June 2nd, 2012, 7:39 am

gfx.DrawLine(350,300,x,y,r,g,b);
gfx.DrawLine(350,300,400,250,r,g,b);
gfx.DrawLine(400,250,450,300,r,g,b);
gfx.DrawLine(350,300,450,300,r,g,b);

You're using your x and y variables for the first drawline only. The rest of them have their points hardcoded, so of course they won't move. You need to add x and y to each of the points of your shape.
Chili

bexrazyallday
Posts: 2
Joined: June 2nd, 2012, 6:40 am

Re: HELP!!!!

Post by bexrazyallday » June 2nd, 2012, 6:26 pm

I changed their values to the x and y, but it still gives me trouble. When I press any direction it all moves, but it changes shape and goes all funky. How do I fix that

gfx.DrawLine(350,300,x,y,r,g,b);
gfx.DrawLine(350,300,x,y - 50,r,g,b);
gfx.DrawLine(400,250,x + 50,y,r,g,b);
gfx.DrawLine(350,300,x + 50,y,r,g,b);

User avatar
LuX
Posts: 1492
Joined: April 22nd, 2012, 12:33 pm
Location: Finland

Re: HELP!!!!

Post by LuX » June 2nd, 2012, 8:35 pm

Apply it to the other side as well?
ʕ •ᴥ•ʔ

Post Reply