Game authors and players, please read this thread!

Author Topic: Illegal Exception when setting DrawingColor?  (Read 357 times)  Share 

Nine Toes

  • Thorry, I didn't mean to thpit all over you!
    • I can help with play testing
    •  
    • I can help with proof reading
    •  
    • I can help with scripting
    •  
    • I can help with story design
    •  
    • I can help with voice acting
    •  
Illegal Exception when setting DrawingColor?
« on: 10 May 2009, 21:53 »
I get this message when I test out my game:

Quote
---------------------------
Illegal exception
---------------------------
An exception 0xC0000005 occurred in ACWIN.EXE at EIP = 0x00403946 ; program pointer is -42, ACI version 3.12.1074, gtags (0,2)

AGS cannot continue, this exception was fatal. Please note down the numbers above, remember what you were doing at the time and post the details on the AGS Technical Forum.

in "GlobalScript.asc", line 19
from "GlobalScript.asc", line 34

An error file CrashInfo.dmp has been created. You may be asked to upload this file when reporting this problem on the AGS Forums. (code 0)

Here is my script:

[code]
// main global script file
#define MAP_TILES_HIGH 9
#define MAP_TILES_WIDE 9
#define MAP_TILES_TOTAL 81
#define TILE_HEIGHT 32
#define TILE_WIDTH 32

int tile[MAP_TILES_TOTAL];

DrawingSurface *surface;

function SetTile (int x,  int y,  int value) {
  if (x<0 || x>MAP_TILES_WIDE || y<0 || y>MAP_TILES_HIGH) {
    Display ("Error: Out of bounds");
    QuitGame (0);
  }
  tile[y*MAP_TILES_WIDE+x] = value;
  surface = Room.GetDrawingSurfaceForBackground();
  surface.DrawingColor = Game.GetColorFromRGB(255, 0, 0);  // <---Illegal exception, line 19
  surface.DrawRectangle(x, y, x+TILE_HEIGHT, y+TILE_WIDTH);
  surface.Release();
}

function GetTile (int x,  int y) {
  if (x<0 || x>MAP_TILES_WIDE || y<0 || y>MAP_TILES_HIGH) {
    Display ("Error: Out of bounds");
    QuitGame(0);
  }
  return tile[y*MAP_TILES_WIDE+x];
}

#sectionstart game_start  // DO NOT EDIT OR REMOVE THIS LINE
function game_start() { // called when the game starts, before the first room is loaded
  SetTile(0, 0, 0);  // <--- Illegal exception, line 34
  SetTile(32, 0, 0);
  SetTile(64, 0, 0);
  SetTile(96, 0, 0);
  SetTile(128, 0, 0);
  SetTile(160, 0, 0);
  SetTile(192, 0, 0);
  SetTile(224, 0, 0);
  SetTile(256, 0, 0);
  SetTile(0, 32, 0);
  SetTile(32, 32, 0);
  SetTile(64, 32, 0);
  SetTile(96, 32, 0);
  SetTile(128, 32, 0);
  SetTile(160, 32, 0);
  SetTile(192, 32, 0);
  SetTile(224, 32, 0);
  SetTile(256, 32, 0);
  SetTile(0, 64, 0);
  SetTile(32, 64, 0);
  SetTile(64, 64, 0);
  SetTile(96, 64, 0);
  SetTile(128, 64, 0);
  SetTile(160, 64, 0);
  SetTile(192, 64, 0);
  SetTile(224, 64, 0);
  SetTile(256, 64, 0);
  }
#sectionend game_start  // DO NOT EDIT OR REMOVE THIS LINE
[/code]

I've got no idea why I'm getting this message, I was literally doing everything by the book.

EDIT:  Sorry, I forgot to mention what I was doing when this happened - Um, well, this script is supposed to be for a tile-based game.  I got the original script from Scorpiorus, in this thread.  I really don't know what I'm doing, but I'm trying to learn as I go.

Basically what I was trying to do is to see if I could get these tiles to represent themselves on screen by using the DrawRectangle command.
« Last Edit: 10 May 2009, 22:12 by Nine Toes »
Watch, I just killed this topic...

Pumaman

  • Creator of AGS
  • Administrator
  • Mittens TRAITOR
  • I sense danger.
    • Lifetime Achievement Award Winner
    •  
Re: Illegal Exception when setting DrawingColor?
« Reply #1 on: 10 May 2009, 22:46 »
You can't use Room.GetDrawingSurfaceForBackground() in game_start, because no room is loaded so there is no background to draw onto.


Khris

  • Evil Dark Emperor Death-Kill
    • Lifetime Achievement Award Winner
    •  
    • I can help with play testing
    •  
    • I can help with scripting
    •  
    • I can help with translating
    •  
Re: Illegal Exception when setting DrawingColor?
« Reply #2 on: 10 May 2009, 22:47 »
Hmm:
[code]function game_start() { // called when the game starts, before the first room is loaded[/code]

Considering the above comment, I'm surprised the error doesn't occur sooner, at this line:

[code] surface = Room.GetDrawingSurfaceForBackground();[/code]

Try calling SetTile() in room_Load().
http://whathaveyoutried.com/

The other day on yahoo answers:
"Can you print colored images with black ink? If so tell me how please Thanx Kimberly"

Nine Toes

  • Thorry, I didn't mean to thpit all over you!
    • I can help with play testing
    •  
    • I can help with proof reading
    •  
    • I can help with scripting
    •  
    • I can help with story design
    •  
    • I can help with voice acting
    •  
Re: Illegal Exception when setting DrawingColor?
« Reply #3 on: 10 May 2009, 22:51 »
You can't use Room.GetDrawingSurfaceForBackground() in game_start, because no room is loaded so there is no background to draw onto.

*laughs*  Yeah, I suppose.  Wow, I'm a dummy. :P

I will try KhrisMUC's solution.
Watch, I just killed this topic...