i need help with c++ tutorial ep. 5 !

The Partridge Family were neither partridges nor a family. Discuss.
theendofthefear
Posts: 4
Joined: April 13th, 2012, 12:47 pm

i need help with c++ tutorial ep. 5 !

Post by theendofthefear » April 13th, 2012, 12:55 pm

im noury and i have been following these tutorials with out any problems, but now my keyboard commands dont react to the code i have entered this is my code : void Game::ComposeFrame()
{
int x ;
int y ;
int gb;
x = 400 ;
y = 300 ;
gb = 255;

gfx.PutPixel( x, y,255,gb,gb) ;
gfx.PutPixel( -5 + x, y,255,gb,gb) ;
gfx.PutPixel( -4 + x, y,255,gb,gb) ;
gfx.PutPixel( -3 + x, y,255,gb,gb) ;
gfx.PutPixel( 3 + x, y,255,gb,gb) ;
gfx.PutPixel( 4 + x, y,255,gb,gb) ;
gfx.PutPixel( 5 + x, y,255,gb,gb) ;
gfx.PutPixel( x,-5 + y,255,gb,gb) ;
gfx.PutPixel( x,-4 + y,255,gb,gb) ;
gfx.PutPixel( x,-3 + y,255,gb,gb) ;
gfx.PutPixel( x, 3 + y,255,gb,gb) ;
gfx.PutPixel( x, 4 + y,255,gb,gb) ;
gfx.PutPixel( x, 5 + y,255,gb,gb) ;

if( kbd.LeftIsPressed())
{
x = 300;
}

if( kbd.RightIsPressed())
{
x = 500;
}

if( kbd.UpIsPressed())
{
y = 200;
}

if( kbd.DownIsPressed())
{
y = 400;
}

if( kbd.SpaceIsPressed())
{
gb = 0;
}
}

Dlotan
Posts: 32
Joined: April 10th, 2012, 4:58 pm

Re: i need help with c++ tutorial ep. 5 !

Post by Dlotan » April 13th, 2012, 1:39 pm

Okay heres ur problem:

Step 1:

int x ;
x = 400 ;

Step 2:

gfx.PutPixel( -5 + x, y,255,gb,gb) ;

Step 3:

if( kbd.LeftIsPressed())
{
x = 300;
}

Step 4:
int x;
x = 400;

etc....

So u say x = 400... then u print it... and then u change it.... and after u changed it... u change it back again. So u never print the changed one

So it should be like

1.

int x;
x = 400;

2.

change the value here!!!!!!! by doing all the ifs

3.

Print it here


edit: if ur lazy

Code: Select all

{
int x ;
int y ;
int gb;
x = 400 ;
y = 300 ;
gb = 255;

if( kbd.LeftIsPressed())
{
x = 300;
}

if( kbd.RightIsPressed())
{
x = 500;
}

if( kbd.UpIsPressed())
{
y = 200;
}

if( kbd.DownIsPressed())
{
y = 400;
}

if( kbd.SpaceIsPressed())
{
gb = 0;
}


gfx.PutPixel( x, y,255,gb,gb) ;
gfx.PutPixel( -5 + x, y,255,gb,gb) ;
gfx.PutPixel( -4 + x, y,255,gb,gb) ;
gfx.PutPixel( -3 + x, y,255,gb,gb) ;
gfx.PutPixel( 3 + x, y,255,gb,gb) ;
gfx.PutPixel( 4 + x, y,255,gb,gb) ;
gfx.PutPixel( 5 + x, y,255,gb,gb) ;
gfx.PutPixel( x,-5 + y,255,gb,gb) ;
gfx.PutPixel( x,-4 + y,255,gb,gb) ;
gfx.PutPixel( x,-3 + y,255,gb,gb) ;
gfx.PutPixel( x, 3 + y,255,gb,gb) ;
gfx.PutPixel( x, 4 + y,255,gb,gb) ;
gfx.PutPixel( x, 5 + y,255,gb,gb) ;

}

theendofthefear
Posts: 4
Joined: April 13th, 2012, 12:47 pm

Re: i need help with c++ tutorial ep. 5 !

Post by theendofthefear » April 13th, 2012, 1:47 pm

ok ermm im not sure i understand but i will work it out, thanks for the help :mrgreen:

theendofthefear
Posts: 4
Joined: April 13th, 2012, 12:47 pm

Re: i need help with c++ tutorial ep. 5 !

Post by theendofthefear » April 13th, 2012, 1:48 pm

Dlotan wrote:Okay heres ur problem:

Step 1:

int x ;
x = 400 ;

Step 2:

gfx.PutPixel( -5 + x, y,255,gb,gb) ;

Step 3:

if( kbd.LeftIsPressed())
{
x = 300;
}

Step 4:
int x;
x = 400;

etc....

So u say x = 400... then u print it... and then u change it.... and after u changed it... u change it back again. So u never print the changed one

So it should be like

1.

int x;
x = 400;

2.

change the value here!!!!!!! by doing all the ifs

3.

Print it here


edit: if ur lazy

Code: Select all

{
int x ;
int y ;
int gb;
x = 400 ;
y = 300 ;
gb = 255;

if( kbd.LeftIsPressed())
{
x = 300;
}

if( kbd.RightIsPressed())
{
x = 500;
}

if( kbd.UpIsPressed())
{
y = 200;
}

if( kbd.DownIsPressed())
{
y = 400;
}

if( kbd.SpaceIsPressed())
{
gb = 0;
}


gfx.PutPixel( x, y,255,gb,gb) ;
gfx.PutPixel( -5 + x, y,255,gb,gb) ;
gfx.PutPixel( -4 + x, y,255,gb,gb) ;
gfx.PutPixel( -3 + x, y,255,gb,gb) ;
gfx.PutPixel( 3 + x, y,255,gb,gb) ;
gfx.PutPixel( 4 + x, y,255,gb,gb) ;
gfx.PutPixel( 5 + x, y,255,gb,gb) ;
gfx.PutPixel( x,-5 + y,255,gb,gb) ;
gfx.PutPixel( x,-4 + y,255,gb,gb) ;
gfx.PutPixel( x,-3 + y,255,gb,gb) ;
gfx.PutPixel( x, 3 + y,255,gb,gb) ;
gfx.PutPixel( x, 4 + y,255,gb,gb) ;
gfx.PutPixel( x, 5 + y,255,gb,gb) ;

} 
lol thanks for that :D

theendofthefear
Posts: 4
Joined: April 13th, 2012, 12:47 pm

Re: i need help with c++ tutorial ep. 5 !

Post by theendofthefear » April 13th, 2012, 1:51 pm

YES ! THANKS SOOOO MUCH I FOUND OUT THE PROBLEM !!!

Dlotan
Posts: 32
Joined: April 10th, 2012, 4:58 pm

Re: i need help with c++ tutorial ep. 5 !

Post by Dlotan » April 13th, 2012, 1:56 pm

np. Keep on coding ;)

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

Re: i need help with c++ tutorial ep. 5 !

Post by chili » April 13th, 2012, 2:07 pm

Thanks for handling that Dlotan.

By the way, what lesson are you on now?
Chili

Dlotan
Posts: 32
Joined: April 10th, 2012, 4:58 pm

Re: i need help with c++ tutorial ep. 5 !

Post by Dlotan » April 13th, 2012, 3:11 pm

chili wrote:Thanks for handling that Dlotan.

By the way, what lesson are you on now?
Im on lesson 13 right now... I just skipped some parts where u just talk about new programming things coz i already had 1 year c and 2 years java at school.

Right now im thinking about implementing my socket class to ur framework and program the tictactoe for multiplayer... i think this will be fun :D

I would really appreciate if u would upload the updated framework somewhere coz im superlazy usually and suck at copying code from yt vids XD

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

Re: i need help with c++ tutorial ep. 5 !

Post by chili » April 15th, 2012, 1:45 am

Yeah, a turn-based deal like TicTacToe is ideal for trying out networking because it's a lot more tolerant of latency. I once made a networked 2D space dogfighting game. It worked great as long as the computers were in the same room, but take it over the internet and it was a disaster. Algorithms for compensating for lag can be pretty tricky, but luckily I don't think you'll need that for TicTacToe.

Let's see your program when you're finished bro! :)
Chili

Dlotan
Posts: 32
Joined: April 10th, 2012, 4:58 pm

Re: i need help with c++ tutorial ep. 5 !

Post by Dlotan » April 15th, 2012, 1:56 am

At 12th grade i made a programm for school which was like some kind of simple browsergame for the console in ascii.

I also used mysql.

The plan was to make a game which has a client as a website but also as a .exe... they connection would have been the sql. But well i just completed the console thing coz i dont have that much motivation to lean PHP

http://twoeighteen.googlecode.com/svn/trunk/

theres the code...

yes its in nearly pure c and its not that well written :D but its now like 2 years ago

I will try to start a new Project of that kind but now witch directx graphics soon. I have 2 rl friends and when the structure is clear i will watch out for some motivated programmers. I really got some nasty good ideas this time :D

Post Reply