Results 1 to 19 of 19

Thread: [resolved] ZeroMemory, for() loop, struct

Threaded View

  1. #1

    Thread Starter
    Fanatic Member McCain's Avatar
    Join Date
    Jan 2002
    Location
    Sweden/Denmark
    Posts
    802

    [resolved] ZeroMemory, for() loop, struct

    Why won't this work?

    Code:
    typedef struct _GHOST
    {
    	int width;
    	int height;
    	int x;
    	int y;
    	int arrayx;
    	int arrayy;
    	int drctn;
    	int speed;
    }GHOST;
    
    GHOST g_Ghost[3];
    
    for(int i = 0; i < 3; i++);
    	{
    		ZeroMemory(&g_Ghost[i], sizeof(g_Ghost[i]));
    		g_Ghost[i].width = 20;
    		g_Ghost[i].height = 20;
    		g_Ghost[i].arrayx = 18;
    		g_Ghost[i].arrayy = 1;
    		g_Ghost[i].x = 360;
    		g_Ghost[i].y = 20;
    		g_Ghost[i].drctn = 1;
    		g_Ghost[i].speed = 4;
    	}
    It works if I replace the i with a 1.

    Then I have 165 lines of code moving this ghost around the screen (mostly collision detection). All the code will be the same for all my ghost (I think I will have four ghosts), should I put all the 165 lines of code in one big for() loop or should I copy and paste the code four times. As this code is inside a game-loop it needs to be as fast as possible.
    Last edited by McCain; Dec 11th, 2002 at 04:00 PM.
    Never argue with fools, they will only drag you down to their level, and beat you with experience.

    Q: How do you tell an experienced hacker from a novice?
    A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width