Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - bx83

#41
...How do I request a feature from the developers?
#42
I have a huge number of variables in Global Variables (like >500), and I was wondering if there was a way to check:
-if any had 0 or 1 only usages (in which case, I can delete or repurpose them)
-if you can count the number of variables?

Thanks!
#43
Code: ags
Overlay* CreateOverlayText(int x, int y, int width, FontType font, int color, int bgColor, String text) {
  int border = 2;
  textOverlay = DynamicSprite.Create(width + border * 2, GetTextHeight(text, font, width) + border * 2);
  DrawingSurface* ds = textOverlay.GetDrawingSurface();
  ds.Clear(COLOR_TRANSPARENT);  // background color
  ds.DrawingColor = bgColor;
  ds.DrawStringWrapped(border, border, width, font, eAlignLeft, text);
  ds.DrawStringWrapped(-border, border, width, font, eAlignLeft, text);
  ds.DrawStringWrapped(border, -border, width, font, eAlignLeft, text);
  ds.DrawStringWrapped(-border, -border, width, font, eAlignLeft, text);
  ds.DrawingColor = color;
  ds.DrawStringWrapped(0, 0, width, font, eAlignLeft, text);
  ds.Release();
  return Overlay.CreateGraphical(x, y, textOverlay.Graphic, true);
}


Close enough :P
#44
I did - I want a black outline around red text.
#45
Code: ags
Overlay* CreateOverlayText(int x, int y, int width, FontType font, int color, int bgColor, String text) {
  int border = 2;
  textOverlay = DynamicSprite.Create(width + border * 2, GetTextHeight(text, font, width) + border * 2);
  DrawingSurface* ds = textOverlay.GetDrawingSurface();
  ds.Clear(COLOR_TRANSPARENT);  // background color
  ds.DrawingColor = bgColor;
  ds.DrawStringWrapped(border, border, width, font, eAlignLeft, text);
  ds.DrawingColor = color;
  ds.DrawStringWrapped(0, 0, width, font, eAlignLeft, text);
  ds.Release();
  return Overlay.CreateGraphical(x, y, textOverlay.Graphic, true);
}


It's pretty bad but there's sort of a shadow. IDK, colouring background black seemed counter productive.
#46
GlobalScript.asc
Code: ags
Overlay* CreateOverlayText(int x, int y, int width, FontType font, int color, int bgColor, String text) {
  int border = 5;
  textOverlay = DynamicSprite.Create(width + border * 2, GetTextHeight(text, font, width) + border * 2);
  DrawingSurface* ds = textOverlay.GetDrawingSurface();
  ds.Clear(bgColor);  // background color
  ds.DrawingColor = color;
  ds.DrawStringWrapped(border, border, width, font, eAlignLeft, text);
  ds.Release();
  return Overlay.CreateGraphical(x, y, textOverlay.Graphic, true);
}

...

String overlayString = String.Format("room %d  mouse x%d,y%d   ft %d   translation %02d:%02d   puppet %02d:%02d   smallone %02d:%02d", 
                                            player.Room, mouse.x,mouse.y, FutureTime, BMin, BTimerSec, PMin, PTimerSec, SMin, STimerSec);
      
if (ovCoords != null && ovCoords.Valid) ovCoords.Remove();
ovCoords = CreateOverlayText(50, 720, 1000, eFontNormal, 51520, 17, overlayString);


demo:


No outline, whether I make the last argument for CreateOverlayText() true or false (missing in original, had to add it).
#47
Code: ags
ovCoords = CreateOverlayText(50, 720, 1356, eFontNormal, 51520, 17, 
                     String.Format("room %d  mouse x%d,y%d   ft %d   translation %02d:%02d   puppet %02d:%02d   smallone %02d:%02d",
                     player.Room, mouse.x,mouse.y, FutureTime, BMin, BTimerSec, PMin, PTimerSec, SMin, STimerSec) );


Error: Type mismatch: cannot convert 'String*' to 'string'
#48
I have:

Code: ags
if (ovCoords != null && ovCoords.Valid) ovCoords.Remove();
      ovCoords = Overlay.CreateTextual(50, 720, 1366, eFontNormal, 51520, "TEXT"


This create a nice red 'TEXT' on any background. But what if the background's red? I then need a black (or whatever colour) border around the text. How do I add this?
#49
Khris, fantastic it works :)

Code: ags
function repeatedly_execute_always()
{
...

    //do sacebar coordinates
    if (ovCoordsVisible) {
      //BookTranslationTimer - number of game loops it takes to translate homer's book
      //PuppetTimer - number of game loops it takes to make current puppet
      
      //timer countdowns
      if (BookTranslationTimer>=0) BookTranslationTimer-=1;
      if (PuppetTimer>=0) PuppetTimer-=1;
      
      int GameSpeed=GetGameSpeed();
      
      int BSec=BookTranslationTimer/GameSpeed;
      int BMin=BSec/60;
      int BTimerSec=BSec%60;
      
      int PSec=PuppetTimer/GameSpeed;
      int PMin=PSec/60;
      int PTimerSec=PSec%60;
      
      if (ovCoords != null && ovCoords.Valid) ovCoords.Remove();
      ovCoords = Overlay.CreateTextual(50, 720, 1366, eFontNormal, 51520, 
      String.Format("room %d  mouse x%d,y%d   ft %d   tr %02d:%02d   pt %02d:%02d",
                     player.Room, mouse.x,mouse.y, FutureTime, BMin, BTimerSec,
                     PMin, PTimerSec)
                     );
    }
...
}


I just copied the timer (tics*min*sec etc.) to a var, starting reducing it by 1 in repeatedly_execute_always() if it was non-0.
#50
Is there a wonderful way of saying:

Code: ags
#define TIMER_BOMB 1
SetTimer(TIMER_BOMB,GetGameSpeed()*10*60);   //10 minutes
Display("You have %d:%d till bomb explodes",<get how much time in seconds is left from timer 1>);


This is all something I've pulled out of my arse, but you get what I mean. How do we get the current time-out for a timer? Or should I use the module timer, which will take me.... a long time.
#51


Or that. Time to redesign the game for the 5th time :/
At least it's solid now and matches the text-books I just looked up...
#52
Because:
a) I needed to redo implementation, it's stuffed
b) I have trouble remembering left/right, x/y, row/column etc - I usually need lots of visual clues burnt into my brain to be able to nicely record stuff about these hither/thither binaries. Is 'x' a row or column? My brain just flips back and forth until I draw a picture.


Code: ags
//get the X-AXIS COLUMN
int GetColRange(int x)
{
  Display("x=%d",x);
  if (x>=0 && x<=50)    return 0;
  if (x>=51 && x<=100)  return 1;
  if (x>=101 && x<=150) return 2;
  if (x>=151 && x<=200) return 3;
  if (x>=201 && x<=250) return 4;
  if (x>=251 && x<=300) return 5;
  if (x>=301 && x<=350) return 6;
  if (x>=351 && x<=400) return 7;
  if (x>=401 && x<=450) return 8;
  if (x>=451 && x<=500) return 9;  
}

//get the Y-AXIS ROW
int GetRowRange(int y)
{
  Display("y=%d",y);
  if (y>=0 && y<=50)    return 0;
  if (y>=51 && y<=100)  return 1;
  if (y>=101 && y<=150) return 2;
  if (y>=151 && y<=200) return 3;
  if (y>=201 && y<=250) return 4;
  if (y>=251 && y<=300) return 5;
  if (y>=301 && y<=350) return 6;
  if (y>=351 && y<=400) return 7;
}


#53
I wrote this function:

Code: ags
int GetRowRange(int y)
{
  Display("provided with %d",y);
  switch (y) {    
    case (y>=0 && y<=50):    return 0; break;//return x/row
    case (y>=51 && y<=100):  return 1; break;
    case (y>=101 && y<=200): return 2; break;
    case (y>=201 && y<=300): return 3; break;
    case (y>=301 && y<=400): return 4; break;
    case (y>=401 && y<=500): return 5; break;
    case (y>=501 && y<=600): return 6; break;
    case (y>=601 && y<=700): return 7; break;
    case (y>=701 && y<=800): return 8; break;
    case (y>=801 && y<=900): return 9; break;
  }
}


I plugged in y=156.
It goes through every case, doesn't pick any, and returns 0 - instead of 2, which is what it should return. Do we have ranges? Am I using it properly?

ps I added redundant break;s to make absolutely sure it stopped after the return statement.
#54
Code: ags
...

//fill out theGrid with Tile objects
  int size = numRows*numCols;
  
  theGrid=new Tile[size]; //instantiate theGrid
  for (int i = 0; i < size; i++) {
    theGrid[i] = new Tile;
  }
  SetupGridValues();
  
  for (int j=0; j<numCrowds;j++) {
    rabble[j]=new Crowd;
  }

  TMan=new TM;



...and it works :P
#55
It all works now, thank you :)

....except TMan. As usual I will try all combinations of definition before complaining.

*does this over 20 minutes*

Okay, I'm out of ideas.

Tankman.ash
Code: ags
...
import Tile *theGrid[];
import Crowd* rabble[numCrowds];    //4 crowds: red, yellow, green, purple
import TM* TMan;


Tankman.asc
Code: ags
__Tankman Tankman;
export Tankman;

bool gEnabled = false;
export gEnabled;


function __Tankman::Enable()
{
  gEnabled = true;
}

function __Tankman::Disable()
{
  gEnabled = false;
}


Tile *theGrid[];    //dynamic array of pointers
Crowd* rabble[4];    //4 crowds: red, yellow, green, purple
TM* TMan;
export theGrid; 
export rabble;
export TMan;
...


Room52.asc
Code: ags
function room_Load()
{
  Tankman.Enable();
  
  gIconbar.Visible=false;
	
  oTM.Baseline=768;
  
  
  cJulius.x=2000;   //the main character of the game; he's here, but off-screen
  cJulius.y=2000;
  
  AG_playing=true;
  AG_gameover=false;
  
  newdirection=eKeyboardMovement_Up;

  //set crowd views
  oC0.SetView(330); //red
  oC1.SetView(332); //yellow
  oC2.SetView(331); //green
  oC3.SetView(329); //purple
  oTM.SetView(314); //tankman
  
  
  //fill out theGrid with Tile objects
  int size = numRows*numCols;
  
  theGrid=new Tile[size]; //instantiate theGrid
  for (int i = 0; i < size; i++) {
    theGrid[i] = new Tile;
  }
  SetupGridValues();
  
  for (int j=0; j<numCrowds;j++) {
    rabble[j]=new Crowd;
  }
  
  //now, setup crowds:
  
  ///////////
  // 0 RED //
  ///////////
  rabble[0].mode=Random(1);       //chase or scatter
  
  //get random start tile
  Tile *rt0 = GetTile();
  rabble[0].aX=rt0.x;

....

 else if (rt3.left==1)  rabble[3].dir=3;
  
  //set nogo based on dir
  rabble[3].nogo=SetNogo(rabble[3].dir);
  

  //setup tankman:
  
  /////////////
  // Tankman //
  /////////////
  
  
  TMan.tileX=6;  <----NULL POINTER REFERENCED


so you know :(
TMan is still not acting as a nice global.
#56
Alrighty, that worked, exports were the missing piece (which I... should have remembered. I need lunch).

Now, it gets back in room 52 to:

Code: ags
function room_Load()
{
  Tankman.Enable();
  
	gIconbar.Visible=false;
	
  oTM.Baseline=768;
  
  
  cJulius.x=2000;   //the main character of the game; he's here, but off-screen
  cJulius.y=2000;
  
  AG_playing=true;
  AG_gameover=false;
  
  newdirection=eKeyboardMovement_Up;

  //set crowd views
  oC0.SetView(330); //red
  oC1.SetView(332); //yellow
  oC2.SetView(331); //green
  oC3.SetView(329); //purple
  oTM.SetView(314); //tankman
  
  
  
  theGrid=new Tile[numRows*numCols];  //define it as a new Tile array of size rows*colums
  
  Display("%p %d %d",theGrid, numRows, numCols);    <---------displays "<8 random hex characters> 8 10"
  theGrid[0].x=25;              <---------------------------------Error: null pointer referenced, PROGRAM STOPS HERE
  Display("%p %d %d",theGrid, numRows, numCols);
  
  Display("rgarghath");
  SetupGridValues();
  GetTargetRed();
#57
Tankman.ash
Code: ags
// new module header
struct __Tankman
{
  import function Enable();
  import function Disable();
};
import __Tankman Tankman;


#define numRows     8
#define numCols     10
#define tankLoop  314

managed struct Tile {
  int x;  //x centre of tile
  int y;  //y centre of tile
  bool up;      //has up direction
  bool right;   //has right direction
  bool down;    //has down direction
  bool left;    //has left direction
  int content;  //is it a free tile or blocked space?
};

#define numCrowds   4


managed struct Crowd {
  int aX;     //actual x eg. 312
  int aY;     //actual y eg. 472
  int tX;     //target x - x centre of target tile
  int tY;     //target y - y centre of target tile
  
  int mode;   //mode, 0=chase, attack=1, scatter=2, scared=3, regen=4
  
  int timer1; //timer to stay in mode
  int timer2; //timer to stay aggressive
  int waittimer;  //timer for wait between attacks/cooldown time
  int timercontrol; //a timer is on=1/off=0
  
  int dir;    //0=up, 1=right, 2=down, 3=left  Never Eat Soggy Wheatbix
  int nogo;   //opposite direction to where your pointed; dir/nogo 0/2 1/3 2/0 3/1
  int moving; //1=moving to next coord, 0=not moving, decision/action time
  bool attack;  //are they programmed to be aggressive? 0-no 1-yes
  int id;     //object ID, leads to control of object loop/position
  bool dead;  //0=alive, 1=dead
  
  import void ResetTimers(Crowd *crowd);
  import void FindTargetBasedOnMode(Crowd *crowd, int mode);
  import void MoveCrowdToTarget(Crowd *crowd);
  import int CleanUpDeadCrowd(Crowd *crowd);
};

managed struct TM {
  int tileX;  //tm's current tile
  int tileY;
  int dir;  //tm's current dir
  int nogo; //diametric opposite to dir
  int mode; 
  int id;   //object id
};

import int SetNogo(int dir);
import int DirToLoop(int dir);
import int LoopToDir(int loop);
import Tile* GetTile(int x=-1, int y=-1);


Tankman.asc
Code: ags
__Tankman Tankman;
export Tankman;

bool gEnabled = false;
export gEnabled;


function __Tankman::Enable()
{
  gEnabled = true;
}

function __Tankman::Disable()
{
  gEnabled = false;
}


Tile *theGrid[];    //dynamic array of pointers
Crowd* rabble[4];    //4 crowds: red, yellow, green, purple
TM* TMan;

...


Room52
Code: ags
...

function room_Load()
{
  Tankman.Enable();
  
  gIconbar.Visible=false;
	
  oTM.Baseline=768;
  
  
  cJulius.x=2000;   //the main character of the game; he's here, but off-screen
  cJulius.y=2000;
  
  AG_playing=true;
  AG_gameover=false;
  
  newdirection=eKeyboardMovement_Up;

  //set crowd views
  oC0.SetView(330); //red
  oC1.SetView(332); //yellow
  oC2.SetView(331); //green
  oC3.SetView(329); //purple
  oTM.SetView(314); //tankman
  
  
  
  theGrid=new Tile[numRows*numCols];  <------ Error: Undefined token 'theGrid'



EDIT: added these to the bottom of Tankman.ash:

Code: ags
import Tile *theGrid[];
import Crowd* rabble[4];    //4 crowds: red, yellow, green, purple
import TM* TMan;


Gets through compile, but then has a runtime error on startup in room52:

Error: unable to create local script: Runtime error: unresolved import 'theGrid'
#58
Okay, that explains that.
Now I've got:

Room52.asc:
Code: ags
function room_Load()
{
...

  theGrid=new Tile[numRows*numCols];  //define it as a new Tile array of size rows*colums
  Display("%d %d",numRows, numCols);
  theGrid[0].x=25;   theGrid[0].y=25;    theGrid[0].up=0;  theGrid[0].right=1;  theGrid[0].down=1;  theGrid[0].left=0;  theGrid[0].content=0;
  theGrid[1].x=75;   theGrid[1].y=25;    theGrid[1].up=0;  theGrid[1].right=1;  theGrid[1].down=0;  theGrid[1].left=1;  theGrid[1].content=0;
  theGrid[2].x=125;  theGrid[2].y=25;    theGrid[2].up=1;  theGrid[2].right=1;  theGrid[2].down=0;  theGrid[2].left=1;  theGrid[2].content=0;
  
  
  Display("rgarghath");
  SetupGridValues();
  GetTargetRed();


It displays:
8 10
'Runtime error: null pointer referenced'

The first line, theGrid[0].x=25, etc etc is the null pointer. So instantiation is right, but then 'theGrid' drops from memory. Or something. :/
#59
I have a script (header/code) for my little Tankman module. In room52, where I have the graphics for the game, I have a game_start() function.
In game_start(), I've put all the initialisation code, and the code for 'theGrid', an array which represents my game-map:

Tankman.ash
Code: ags
Tile *theGrid[];    //dynamic array of pointers


Room52.asc
Code: ags
function game_start()
{
...
theGrid=new Tile[numRows*numCols];  //define it as a new Tile array of size rows*colums
Display("rgarghath");
SetupGridValues();    <------Display output for testing, sets up grid values now it's been properly instantiated
GetTargetRed();   <----- function than generates Display output
}


Nothing displays output, nothing runs.
If I put SetupGridValues() in room_Load(), it runs it, and then says theGrid is a null pointer (obviously never instantiated).

I would've thought that game_start() would be the first and foremost thing to run?

How and where do I run 'theGrid=new Tile[numRows*numCols];' to set it as a global variable (within game/room52), then run all 'setup' code, and then just get to the actual game-loop in room_RepExec()?
#60
Code: ags
vc[0] = Maths.Sqrt( Maths.RaiseToPower(Fcx-Ftmx, 2) + Maths.RaiseToPower(Fcy-Ftmy, 2) );


vc[] is an array of floats, all variables inside expression are floats, RaiseToPower is a floats-only function.

Error: Type mismatch: cannot convert 'int' to 'float'

???
SMF spam blocked by CleanTalk