www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/12/15/03:31:13

From: Bill Lachance <billl AT synapse DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Pointers, arrays and assignments
Date: Sat, 14 Dec 1996 23:36:15 -0800
Organization: Synapse Internet <www.synapse.net>
Lines: 50
Message-ID: <32B3AA6F.1302@synapse.net>
Reply-To: billl AT synapse DOT net
NNTP-Posting-Host: violin-12.synapse.net
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Ahoy there,

I'm re-writing my tile-based game under Allegro to work better, 
cleaner, and faster. That means switching from global variables
to pointers. ;)

For some reason though, when I try to assign values to my pointer
to player structures, the thing crashes.

I've initialised them like so: player *plyr[3] (the game will 
support up to three players, and the array seemed to be the
best way of supporting that). But when I try a stunt like:
plyr[0]->X=4960, the program crashes abruptly (I've isolated the
problem).

Am I breaking some unknown rule here?

here's the player structure:

typedef struct
  {
    // for display only..
    BITMAP *dirty;
    // entity oriented variables
    char w, h;
    char clip_w, clip_h;
    unsigned long X, Y;
    long HP;
    unsigned long mv;
    char dir;
    char frame;
    char reload;
    char ch_frame;
    // input oriented variables
    char control_type;
    int key_left;
    int key_right;
    int key_up;
    int key_down;
    int key_fire;
    int key_magic;
    // for multiplayer games..
    int xoff, yoff;
  }
player;

Thanx,

Bill Lachance
billl AT synapse DOT net

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019