i need help with c++ tutorial ep. 5 !
-
- Posts: 4
- Joined: April 13th, 2012, 12:47 pm
i need help with c++ tutorial ep. 5 !
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;
}
}
{
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;
}
}
Re: i need help with c++ tutorial ep. 5 !
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
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) ;
}
-
- Posts: 4
- Joined: April 13th, 2012, 12:47 pm
Re: i need help with c++ tutorial ep. 5 !
ok ermm im not sure i understand but i will work it out, thanks for the help
-
- Posts: 4
- Joined: April 13th, 2012, 12:47 pm
Re: i need help with c++ tutorial ep. 5 !
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
lol thanks for thatCode: 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) ; }
-
- Posts: 4
- Joined: April 13th, 2012, 12:47 pm
Re: i need help with c++ tutorial ep. 5 !
YES ! THANKS SOOOO MUCH I FOUND OUT THE PROBLEM !!!
Re: i need help with c++ tutorial ep. 5 !
np. Keep on coding
Re: i need help with c++ tutorial ep. 5 !
Thanks for handling that Dlotan.
By the way, what lesson are you on now?
By the way, what lesson are you on now?
Chili
Re: i need help with c++ tutorial ep. 5 !
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.chili wrote:Thanks for handling that Dlotan.
By the way, what lesson are you on now?
Right now im thinking about implementing my socket class to ur framework and program the tictactoe for multiplayer... i think this will be fun
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
Re: i need help with c++ tutorial ep. 5 !
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!
Let's see your program when you're finished bro!
Chili
Re: i need help with c++ tutorial ep. 5 !
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 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
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 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