boolsoft message board Forum Index
Crash Invaders
Goto page Previous  1, 2
 
Post new topic   Reply to topic    boolsoft message board Forum Index -> Software ideas
View previous topic :: View next topic  
Author Message
Boscop
Member
Member


Joined: 05 Sep 2007
Posts: 17
Location: Germany

PostPosted: Sat Dec 08, 2007 8:39 pm    Post subject: Reply with quote

I'm encountering another problem:
I need two varialbe-length arrays in a structure (in the LEVEL structure, more exactly) and tried this:
c:
  1. // Header File
  2. // Created 27.11.2007; 17:46:10
  3.  
  4. #ifndef ALIEN_H
  5. #define ALIEN_H
  6.  
  7. #define COORD_SHIFT 7
  8.  
  9. typedef enum {
  10.         MOVE,
  11.         WAIT,
  12.         SET_ANGLE, INC_ANGLE, DEC_ANGLE,
  13.         SET_X,     INC_X,     DEC_X,
  14.         SET_Y,     INC_Y,     DEC_Y,
  15.         END_CODE,
  16. } COMMAND;
  17.  
  18. typedef char CODE;
  19.  
  20. typedef struct {
  21.         const unsigned char *sprt;
  22.         unsigned char width;
  23.         unsigned char sprt_width;
  24.         unsigned char sprt_height;
  25. } ALIEN_SPRITE;
  26.  
  27. #define ALIEN_NUMBER 1
  28. ALIEN_SPRITE alien_sprites[ALIEN_NUMBER] = {
  29.         {_alien_1, 16, 2, 16},
  30. };
  31.  
  32. typedef struct {
  33.         short x, y;
  34.         unsigned char angle;
  35.         unsigned char speed;
  36.         unsigned char id;                     //alien type
  37.  
  38.         unsigned char line;                         //line in the code
  39.         unsigned char counter;
  40.         CODE *code;
  41. } ALIEN;
  42.  
  43. typedef struct {
  44.         const short x, y;
  45.         const unsigned char speed;
  46.         const unsigned char id;   //alien type
  47.         const unsigned char group;
  48.         const unsigned char line;                     //line in the code
  49.         const unsigned char counter;
  50. } LEVEL_ALIEN;
  51.  
  52.  
  53. typedef struct {
  54.         const unsigned char alien_nr;
  55.         const LEVEL_ALIEN *aliens;
  56.         const CODE *code;
  57. } LEVEL;
  58.  
  59. #define LEVEL_NR 1
  60. const LEVEL levels[LEVEL_NR] = {
  61. {
  62.         2,
  63.         (const LEVEL_ALIEN *)&{
  64.                 {
  65.                         32,               //x
  66.                         32,               //y
  67.                          1,               //speed
  68.                          0,               //type
  69.                          0,               //group
  70.                          0,               //line
  71.                          0,               //counter
  72.                 },
  73.                 {
  74.                         60,
  75.                         32,
  76.                          1,
  77.                          0,
  78.                          0,
  79.                          0,
  80.                          0,
  81.                 }
  82.         },
  83.         (const CODE *)&{
  84.                 DEC_ANGLE, 64,
  85.                 MOVE,      100,
  86.                 INC_ANGLE, 64,
  87.                 MOVE,          30,
  88.                 INC_ANGLE, 64,
  89.                 MOVE,          100,
  90.                 INC_ANGLE, 64,
  91.                 MOVE,      30,
  92.                 END_CODE,
  93.         }
  94. },
  95. };
  96.  
  97. const LEVEL *current_lvl;
  98. ALIEN *aliens;
  99.  


but I get around 158 warnings, saying all the same:
'Initialization of ... makes pointer from integer without a cast'
and
'Braces around scalar initializer'
or
'Missing initializer, near declaration of...'
They are related to lines of the level's definition.
It didn't help to write casts into the definition...
What did I do wrong?

// EDIT by saubue: Added syntax highlighting
Back to top
View user's profile Send private message
Boscop
Member
Member


Joined: 05 Sep 2007
Posts: 17
Location: Germany

PostPosted: Thu Dec 13, 2007 9:18 pm    Post subject: Reply with quote

I have found a better solution for this problem:
I stored the code of alle levels in one large array and passed pointers to the specific level section to the structure.
I did the same with the aliens and everything works fine Very Happy
This makes it also easier to store the levels external...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    boolsoft message board Forum Index -> Software ideas All times are GMT + 1 Hour
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum



Powered by phpBB and Ad Infinitum v1.03


Anti Bot Question MOD - phpBB MOD against Spam Bots