Yes - crowds are Objects, tank is Character.
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//defs
int tmx, tmy, cx, cy; //x,y coords of tankman (tmx,tmy) and yourself (cx,cy)
float Ftmx, Ftmy, Fcx, Fcy; //their float equivalents
float vc[4]; //define direction vectors
vc[0]=-1.0;
vc[1]=-1.0;
vc[2]=-1.0;
vc[3]=-1.0; //set to -1 so non-existant directions don't come back as shortest vector ie. 0 distance
...
Ftmx=IntToFloat(tmx); //get Float values from original ints
Ftmy=IntToFloat(tmy);
Fcx=IntToFloat(cx);
Fcy=IntToFloat(cy);
if (C.up==1) { //if we have direction up...
cy--;
if(cy<0)cy=9;
vc[0] = Maths.Sqrt((Fcx-Ftmx)^2 + (Fcy-Ftmy)^2); <----- ERROR! Type mismatch: cannot convert 'int' to 'float'
managed struct Crowd {
int aX; //actual x eg. 312
int aY; //actual y eg. 472
int tX; //target x - x centre of target tile
...
import void ResetTimers(Crowd *crowd);
...
void Crowd::ResetTimers(Crowd *crowd)
{...}
[much lower down]
void Crowd::ResetCrowd(Crowd *crowd)
{
...
ResetTimers(this); <-----ERROR: 'Undefined token ResetTimers'
...
}
Tile *theGrid[]; //dynamic array of pointers
Crowd* rabble[5]; //5 crowds
function game_start()
{
theGrid[]=new Tile[numRows*numCols]; //define it as a new Tile array of size rows*colums <----error this line
}
// new module header
struct __Tankman
{
import function Enable();
import function Disable();
};
import __Tankman Tankman;
#define numRows 8
#define numCols 10
managed struct Tile {
int x; //x centre of tile
int y; //y centre of tile
//String refName;
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 5
managed struct Crowd {
int aX; //actual x eg. 312
int aY; //actual y eg. 472
int tX; //target x - target char/tile x coord - '3' for 'tile 34'
int tY; //target y - target char/tile y coord - '4' for 'tile 34'
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 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
int id; //0..4
import void SetupCrowds();
import void ResetCrowd(Crowd *crowd);
import void ResetTimers(Crowd *crowd);
import void FindTargetBasedOnMode(Crowd *crowd, int mode);
import void MoveCrowdToTarget(Crowd *crowd);
import int SetNogo(int dir);
};
__Tankman Tankman;
export Tankman;
bool gEnabled = false;
export gEnabled;
Tile *theGrid[numRows*numCols]; //global tile grid <----ERROR! Tankman.asc(7): Error (line 7): expected ']'
Crowd *rabble[5]; //global crowd array
function __Tankman::Enable()
{
gEnabled = true;
}
function __Tankman::Disable()
{
gEnabled = false;
}
export Tile;
export Crowd;
//true=even, false=odd
bool isEven(int n)
{
...
// new module header
struct __Tankman
{
import function Enable();
import function Disable();
};
import __Tankman Tankman;
#define numRows 8
#define numCols 10
struct Tile {
int x; //x centre of tile
int y; //y centre of tile
String refName;
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?
};
managed struct Grid {
import void SetupGridValues();
import Tile Grid::RandomFreeSquare(); <---------------ERROR: Tankman.ash(26): Error (line 26): Member variable cannot be struct
import Tile Grid::TileFromRef(String refName);
};
#define numCrowds 5
managed struct Crowd {
int aX; //actual x eg. 312
int aY; //actual y eg. 472
int tX; //target x - target char/tile x coord - '3' for 'tile 34'
int tY; //target y - target char/tile y coord - '4' for 'tile 34'
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 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
int id; //0..4
import void SetupCrowds();
import void ResetCrowd(Crowd *crowd);
import void ResetTimers(Crowd *crowd);
import void FindTargetBasedOnMode(Crowd *crowd, int mode);
import void MoveCrowdToTarget(Crowd *crowd);
import int SetNogo(int dir);
};
__Tankman Tankman;
export Tankman;
bool gEnabled = false;
export gEnabled;
Tile *theGrid[numRows*numCols]; //global tile grid
Crowd *rabble[5]; //global crowd array
function __Tankman::Enable()
{
gEnabled = true;
}
function __Tankman::Disable()
{
gEnabled = false;
}
export Tile;
export Crowd;
//true=even, false=odd
bool isEven(int n)
{
...
}
//put in y, get x
int GetRowRange(int y)
{
...
}
//put in x, get y
int GetColRange(int x)
{
...
}
//set opposite direction to current direction; you cannot ever go in this direction
//eg. you are headed right; you cannot go backwards, so nogo=left
int Crowd::SetNogo(int dir)
{
...
}
//x1 is to the left of x2
//0=left
//1=same square
//2=right
int IsLeftOf(int x1, int x2)
{
...
}
//y1 is above y2
//0=up
//1=same square
//2=down
int IsUpOf(int y1, int y2)
{
...
}
//look up tile number, get actual tile returned
Tile Grid::TileFromRef(String refName)
{
...
}
//get a tile's refName from it's x,y coords eg x=3, y=4, refname string "34"
String RefFromTile(int x, int y)
{
...
}
//reset a crowd's timers
//todo: put something here to get new decision on where to go, or put in next planned decision
void Crowd::ResetTimers(Crowd *crowd)
{
...
}
//get a random free square pointer
//free is content=0
Tile* Grid::RandomFreeSquare()
{
...
}
//is an object overlapping a character, even by a pixel?
//note: doesn't account for transparent squares overlapping
bool IsOverlappingCO(Character *ch, Object *ob)
{
...
}
//is an character overlapping another character, even by a pixel?
//note: doesn't account for transparent squares overlapping
bool IsOverlappingCC(Character *ch1, Character *ch2)
{
...
}
//reset crowd's variables/initialise a new crowd
void Crowd::ResetCrowd(Crowd *crowd)
{
...
}
//go through crowd array, intialise all
void Crowd::SetupCrowds()
{
...
}
//intial setup for grid values
void Grid::SetupGridValues()
{
...
}
//using mode, set x,y target and strategy
void Crowd::FindTargetBasedOnMode(Crowd *crowd, int mode)
{
...
}
//move a crowd it's tX,tY target coord,
//and set 'moving' to '1' for 'not on a tile centre, better move 1 closed'
//and '0' for 'on a tile's centre; better make my next decision now i'm at tile 67, my target tile'
void Crowd::MoveCrowdToTarget(Crowd *crowd)
{
...
}
// room script file
///////////////
// VARIABLES //
///////////////
#define DISTANCE 1 //0000// distance player walks in Tapping mode before he stops
#define MAX_BULLETS 3
#define MAX_LNDMINE 5
#define AG_WALL 2
#define FirstCrowdIndex 5
#define LastCrowdIndex 9
int AG_BULLETS=1;
int AG_LNDMINE=0;
int KeyboardMovement_KeyDown = 380; // down arrow
int KeyboardMovement_KeyLeft = 375; // left arrow
int KeyboardMovement_KeyRight = 377; // right arrow
int KeyboardMovement_KeyUp = 372; // up arrow
KeyboardMovement_Directions KeyboardMovement_CurrentDirection;// = eKeyboardMovement_Stop; // stores current walking direction of player character
KeyboardMovement_Directions newdirection; // declare variable storing new direction
//I must add these to reference and use them outside the module.ash, but... it doesn't work :/
import bool isEven(int n);
import int GetRowRange(int y);
import int GetColRange(int x);
import int IsLeftOf(int x1, int x2);
import int IsUpOf(int y1, int y2);
import String RefFromTile(int x, int y);
import Tile Grid::RandomFreeSquare();
import Tile Grid::TileFromRef(String refName);
import bool IsOverlappingCO(Character *ch, Object *ob);
import bool IsOverlappingCC(Character *ch1, Character *ch2);
import int Crowd::SetNogo(int dir);
import void Crowd::ResetTimers(Crowd *crowd);
import void Crowd::ResetCrowd(Crowd *crowd);
import void Crowd::SetupCrowds();
import void Grid::SetupGridValues();
import void Crowd::FindTargetBasedOnMode(Crowd *crowd, int mode);
import void Crowd::MoveCrowdToTarget(Crowd *crowd);
////////////////////
// ROOM FUNCTIONS //
////////////////////
function room_Load()
{
Tankman.Enable();
gIconbar.Visible=false;
cTankman.Baseline=768;
cTankman.SetAsPlayer();
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;
oC0.SetView(322); //set crowd views
oC1.SetView(322);
oC2.SetView(322);
oC3.SetView(322);
oC4.SetView(322);
}
function room_RepExec()
{
//control tank - set joystick according to direction
if (IsKeyPressed(KeyboardMovement_KeyDown)) {
newdirection = eKeyboardMovement_Down; // down arrow
oJoyStick.Graphic=4122;
//Display("currdir %d",KeyboardMovement_CurrentDirection);//2
}
else if (IsKeyPressed(KeyboardMovement_KeyLeft)) {
newdirection = eKeyboardMovement_Left; // left arrow
oJoyStick.Graphic=4124;
//Display("currdir %d",KeyboardMovement_CurrentDirection);//3
}
else if (IsKeyPressed(KeyboardMovement_KeyRight)) {
newdirection = eKeyboardMovement_Right; // right arrow
oJoyStick.Graphic=4118;
//Display("currdir %d",KeyboardMovement_CurrentDirection);//4
}
else if (IsKeyPressed(KeyboardMovement_KeyUp)) {
newdirection = eKeyboardMovement_Up; // up arrow
oJoyStick.Graphic=4120;
//Display("currdir %d",KeyboardMovement_CurrentDirection);//5
}
//check if area in front of tank is a wall
if (GetWalkableAreaAt(cTankman.x, cTankman.y)!=AG_WALL) {
switch (newdirection) {
case eKeyboardMovement_Down:
oJoyStick.Graphic=4122;
if (GetWalkableAreaAt(cTankman.x, cTankman.y+(DISTANCE))!=AG_WALL) {
cTankman.Loop=0;
cTankman.y+=DISTANCE;
} else {
newdirection=KeyboardMovement_CurrentDirection;
}
break;
case eKeyboardMovement_Left:
oJoyStick.Graphic=4124;
if (GetWalkableAreaAt(cTankman.x-(DISTANCE), cTankman.y)!=AG_WALL) {
cTankman.Loop=1;
cTankman.x-=DISTANCE;
} else {
newdirection=KeyboardMovement_CurrentDirection;
}
break;
case eKeyboardMovement_Right:
oJoyStick.Graphic=4118;
if (GetWalkableAreaAt(cTankman.x+(DISTANCE), cTankman.y)!=AG_WALL) {
cTankman.Loop=2;
cTankman.x+=DISTANCE;
} else {
newdirection=KeyboardMovement_CurrentDirection;
}
break;
case eKeyboardMovement_Up:
oJoyStick.Graphic=4120;
if (GetWalkableAreaAt(cTankman.x, cTankman.y-(DISTANCE))!=AG_WALL) {
cTankman.Loop=3;
cTankman.y-=DISTANCE;
} else {
newdirection=KeyboardMovement_CurrentDirection;
}
break;
}//switch
}//if
// update current direction to new direction
KeyboardMovement_CurrentDirection = newdirection;
}
...
struct Crowd {
int aX; //actual x eg. 312
int aY; //actual y eg. 472
int tX; //target x - target char/tile x coord - '3' for 'tile 34'
int tY; //target y - target char/tile y coord - '4' for 'tile 34'
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 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
int id; //0..4
import void SetupCrowds();
import void ResetCrowd(Crowd *crowd); <--ERROR!
import void ResetTimers(Crowd *crowd);
import void FindTargetBasedOnMode(Crowd *crowd, int mode);
import void MoveCrowdToTarget(Crowd *crowd);
};
struct Grid {
int x;
int y;
String refName;
bool up;
bool right;
bool down;
bool left;
};
#define numRows 8
#define numCols 10
//10 rows * 8 columns
Grid *theGrid[numRows*numCols];
Grid SetupValues()
{
theGrid[0].x=0; theGrid[0].y=0; theGrid[0].refName="00"; theGrid[0].up=0; theGrid[0].right=1; theGrid[0].down=0; theGrid[0].left=1; //0,0
theGrid[1].x=0; theGrid[1].y=0; theGrid[1].refName="01"; theGrid[1].up=1; theGrid[1].right=1; theGrid[1].down=0; theGrid[1].left=1; //0,1
......
}
Grid* XYToIndex(int x, int y)
{
//note for ref 52, x=5, y=2
return theGrid[y*numRows+x];
}
function IndexToXY(int i)
{
return theGrid[(i % numCols)*(i / numCols)];
}
By continuing to use this site you agree to the use of cookies. Please visit this page to see exactly how we use these.
Page created in 0.043 seconds with 14 queries.