Click here to Skip to main content
15,917,642 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CFormView control sizing Pin
Rage25-Aug-11 0:11
professionalRage25-Aug-11 0:11 
QuestionAmbiguity of 'this' and 'member function' [modified] Pin
Dean Seo24-Aug-11 15:12
Dean Seo24-Aug-11 15:12 
AnswerRe: Ambiguity of 'this' and 'member function' Pin
xrg_soft@163.com24-Aug-11 19:32
xrg_soft@163.com24-Aug-11 19:32 
GeneralRe: Ambiguity of 'this' and 'member function' Pin
Dean Seo24-Aug-11 20:53
Dean Seo24-Aug-11 20:53 
GeneralRe: Ambiguity of 'this' and 'member function' Pin
xrg_soft@163.com24-Aug-11 21:42
xrg_soft@163.com24-Aug-11 21:42 
GeneralRe: Ambiguity of 'this' and 'member function' Pin
Dean Seo24-Aug-11 22:36
Dean Seo24-Aug-11 22:36 
AnswerRe: Ambiguity of 'this' and 'member function' Pin
CPallini24-Aug-11 21:34
mveCPallini24-Aug-11 21:34 
GeneralRe: Ambiguity of 'this' and 'member function' Pin
Dean Seo24-Aug-11 22:37
Dean Seo24-Aug-11 22:37 
Questionfind task manager process Pin
trioum24-Aug-11 7:02
trioum24-Aug-11 7:02 
AnswerRe: find task manager process Pin
Code-o-mat24-Aug-11 7:19
Code-o-mat24-Aug-11 7:19 
GeneralRe: find task manager process Pin
Rage24-Aug-11 22:24
professionalRage24-Aug-11 22:24 
QuestionLens blur effect Pin
Dusan Paulovic24-Aug-11 6:07
Dusan Paulovic24-Aug-11 6:07 
AnswerRe: Lens blur effect Pin
enhzflep24-Aug-11 21:09
enhzflep24-Aug-11 21:09 
QuestionProgram execution hangs at accSelect. Pin
kartikdasani24-Aug-11 1:43
kartikdasani24-Aug-11 1:43 
AnswerRe: Program execution hangs at accSelect. Pin
enhzflep24-Aug-11 2:24
enhzflep24-Aug-11 2:24 
GeneralRe: Program execution hangs at accSelect. Pin
kartikdasani24-Aug-11 3:03
kartikdasani24-Aug-11 3:03 
GeneralRe: Program execution hangs at accSelect. Pin
enhzflep24-Aug-11 3:22
enhzflep24-Aug-11 3:22 
GeneralRe: Program execution hangs at accSelect. Pin
kartikdasani24-Aug-11 21:41
kartikdasani24-Aug-11 21:41 
Questionsnake problem Pin
CodeNomad23-Aug-11 20:08
CodeNomad23-Aug-11 20:08 
AnswerRe: snake problem Pin
enhzflep23-Aug-11 21:07
enhzflep23-Aug-11 21:07 
Sure can,

In pseudo-code:

Snake.Position += Snake.Velocity;


You may wish to represent both the position and the velocity as a 2d vector.
e.g
typedef vec2_t{
 int x;
 int y;
} vec2;

vec2 snakePosition;
vec2 snakeVelocity;

snakePosition.x += snakeVelocity.x;
snakePosition.y += snakeVelocity.y;


How you set snakeVelocity is up to you and the game you're creating. If this is the typical game of snake, as found on mobile phones etc, you simply need to respond to key-presses.

pseudo-code:

C++
switch(pressedKey)
{
    case leftArrow:
        snakeVelocity = (vec2){-1,0};
        break;
    case rightArrow:
        snakeVelocity = (vec2){1,0};
        break;
    case upArrow:
        snakeVelocity = (vec2){0,-1};
        break;
    case downArrow:
        snaeVelocity = (vec2){0,1};
        break;
}

GeneralRe: snake problem Pin
CodeNomad23-Aug-11 21:10
CodeNomad23-Aug-11 21:10 
GeneralRe: snake problem Pin
enhzflep23-Aug-11 21:29
enhzflep23-Aug-11 21:29 
JokeRe: snake problem Pin
aswinsayeeraman24-Aug-11 21:15
aswinsayeeraman24-Aug-11 21:15 
GeneralRe: snake problem Pin
ThatsAlok30-Aug-11 0:01
ThatsAlok30-Aug-11 0:01 
QuestionWhy GlobalAddAtom always returns none zero even if failed Pin
gaspher23-Aug-11 13:25
gaspher23-Aug-11 13:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.