Click here to Skip to main content
15,889,335 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
AnswerRe: Why GlobalAddAtom always returns none zero even if failed Pin
Chris Losinger23-Aug-11 13:42
professionalChris Losinger23-Aug-11 13:42 
GeneralRe: Sorry I can't type in the 'Text' field. I use the GlobalGetAtomName to retrieve the atom name, and it doesnot match the origin name. This occurs when I Add more than 0x4000 atoms. Pin
gaspher23-Aug-11 13:56
gaspher23-Aug-11 13:56 
GeneralRe: Sorry I can't type in the 'Text' field. I use the GlobalGetAtomName to retrieve the atom name, and it doesnot match the origin name. This occurs when I Add more than 0x4000 atoms. Pin
Chris Losinger24-Aug-11 1:12
professionalChris Losinger24-Aug-11 1:12 
QuestionEXE AcitveX Control Pin
Tracy Software23-Aug-11 3:34
Tracy Software23-Aug-11 3:34 
QuestionFreeing the memory using delete operator for a class object created using new operator gives exception Pin
manoharbalu23-Aug-11 1:52
manoharbalu23-Aug-11 1:52 
AnswerRe: Freeing the memory using delete operator for a class object created using new operator gives exception Pin
Chris Losinger23-Aug-11 1:54
professionalChris Losinger23-Aug-11 1:54 
AnswerRe: Freeing the memory using delete operator for a class object created using new operator gives exception Pin
CPallini23-Aug-11 1:56
mveCPallini23-Aug-11 1:56 
AnswerRe: Freeing the memory using delete operator for a class object created using new operator gives exception Pin
Hans Dietrich23-Aug-11 2:14
mentorHans Dietrich23-Aug-11 2:14 
AnswerRe: Freeing the memory using delete operator for a class object created using new operator gives exception Pin
Nemanja Trifunovic23-Aug-11 2:22
Nemanja Trifunovic23-Aug-11 2:22 
QuestionRe: Freeing the memory using delete operator for a class object created using new operator gives exception Pin
CPallini23-Aug-11 2:27
mveCPallini23-Aug-11 2:27 
AnswerRe: Freeing the memory using delete operator for a class object created using new operator gives exception Pin
Nemanja Trifunovic23-Aug-11 3:20
Nemanja Trifunovic23-Aug-11 3:20 
GeneralRe: Freeing the memory using delete operator for a class object created using new operator gives exception Pin
CPallini23-Aug-11 3:25
mveCPallini23-Aug-11 3: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.