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 - Kweepa

#2381
Check you haven't left some old code in there:

If you search for TryDiagonalMove, do you find two definitions of the function?
There should be one definition and four uses.
If there are more, remove the ones that don't correspond to the latest code posted here.

[EDIT] And trying to return a float from a "function" won't compile -- it says the return type is wrong, which by a staggering coincidence, it is.
#2382
General Discussion / Re: google madass names!
Wed 06/07/2005 16:13:32
A marketing consultant (using www.stevemccrea.com - swine!).
An alternative fuel vehicles consultant (I think it's the same guy).
A virtual tourist guide (probably the same dude again - an ecologist in Florida).
A further education language teacher (surely not the same fella, but Florida again!).
A "gifted and talented" teacher with a Gold Star.
And, er, me.
#2383
Advanced Technical Forum / Re: NewRoom Bug !??
Wed 06/07/2005 15:49:47
I think it's because it continues to run the script to the end even though the room has changed. So the player coordinates change to (299, 130) which is in walkable area 14, and the second NewRoomEx() command is issued.
(It works when you swap it because (53, 145) is not in walkable area 13.)

You should put elses before each check like you did in the SetMouseCursor block:

Code: ags

//if (GetWalkableAreaAt(player.x,player.y) == 11) NewRoomEx(87,40,89);
//else if (GetWalkableAreaAt(player.x,player.y) == 12) NewRoomEx(87,40,89);
else if (GetWalkableAreaAt(player.x,player.y) == 13) NewRoomEx(104,299,130);
else if (GetWalkableAreaAt(player.x,player.y) == 14) NewRoomEx(102,53,145);
#2384
Quote from: Ghost on Wed 06/07/2005 11:11:17
strangely, the game looks slightly gritty in the editor but perfect when I run it, even though the desktop col. depth is 16k.

Are you running it full screen? It will switch to 24 or 32 bit colour in that case.
#2385
Mittens is undercharging!
#2386
[EDIT] THIS IS THE WORKING CODE

Ok, I see the problem I think...
Direct is being set to DIR_NONE which isn't handled by the loop.
What is the difference between DIR_NONE and DIR_STOP?
If you don't know, just remove all references to DIR_NONE and replace them with DIR_STOP.
Or, change the line

if (Direct != DIR_STOP)

to

if (Direct != DIR_STOP || Direct != DIR_NONE)

I'm not near an AGS enabled pc at the moment.
If you'd rather I just got it working later and then got back to you I can do that.

Cheers,
Steve

EDIT - tested and working.

Code: ags

#define DIR_DOWN_LEFT 1
#define DIR_DOWN 2
#define DIR_DOWN_RIGHT 3
#define DIR_LEFT 4
#define DIR_STOP 5
#define DIR_RIGHT 6
#define DIR_UP_LEFT 7
#define DIR_UP 8
#define DIR_UP_RIGHT 9

int oldDirect = DIR_STOP;
int newDirect;
float characterX;
float characterY;
float animFrame = 0.0;

#define MAX_NEARBY_CHARS 8
int gNearbyChars[MAX_NEARBY_CHARS];
int gNumNearbyChars;

// unfortunately I don't see any way to find the character width (help?)
// should probably set up the blocking widths for characters before hand
int GetBlockingWidth(int candidateIndex)
{
Ã,  int blockingWidth = 16;
Ã,  Character *candidate = character[candidateIndex];
Ã,  if (candidate.BlockingWidth != 0)
Ã,  {
Ã,  Ã,  blockingWidth = candidate.BlockingWidth;
Ã,  }
Ã,  return blockingWidth;
}

int GetBlockingHeight(int candidateIndex)
{
Ã,  int blockingHeight = 8;
Ã,  Character *candidate = character[candidateIndex];
Ã,  if (candidate.BlockingHeight != 0)
Ã,  {
Ã,  Ã,  blockingHeight = candidate.BlockingHeight;
Ã,  }
Ã,  return blockingHeight;
}

// replace GetWalkableAreaAt with this
bool PlayerCanMoveHere(int x, int y)
{
Ã,  bool canMoveHere = false;
Ã,  if (GetWalkableAreaAt(x - GetViewportX(), y - GetViewportY()) > 0)
Ã,  {
Ã,  Ã,  canMoveHere = true;
Ã,  Ã,  int candidateIndexIndex = 0;
Ã,  Ã,  while (candidateIndexIndex < gNumNearbyChars && canMoveHere)
Ã,  Ã,  {
Ã,  Ã,  Ã,  int candidateIndex = gNearbyChars[candidateIndexIndex];
Ã,  Ã,  Ã,  Character *candidate = character[candidateIndex];
Ã,  Ã,  Ã,  int dxo = candidate.x - player.x;
Ã,  Ã,  Ã,  int dyo = candidate.y - player.y;
Ã,  Ã,  Ã,  int dxn = candidate.x - x;
Ã,  Ã,  Ã,  int dyn = candidate.y - y;
Ã,  Ã,  Ã,  int cdx = player.BlockingWidth/2 + GetBlockingWidth(candidateIndex)/2;
Ã,  Ã,  Ã,  int cdy = player.BlockingHeight/2 + GetBlockingHeight(candidateIndex)/2;
Ã,  Ã,  Ã,  // overlapping AND getting closer
Ã,  Ã,  Ã,  if ((dxn*dxn < cdx*cdx && dyn*dyn <Ã,  cdy*cdy)
Ã,  Ã,  Ã,  Ã,  Ã, && ((dxn*dxn + dyn*dyn) < (dxo*dxo + dyo*dyo)))
Ã,  Ã,  Ã,  {
Ã,  Ã,  Ã,  Ã,  canMoveHere = false;
Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  candidateIndexIndex++;
Ã,  Ã,  }
Ã,  }
Ã,  return canMoveHere;
}

float TryDiagonalMove(float dist, int dx, int dy, int slideDirX, int slideDirY)
{
Ã,  // test that direction
Ã,  float delta = 0.7071*dist;
Ã,  float dxf = IntToFloat(dx);
Ã,  float dyf = IntToFloat(dy);
Ã,  float newCharacterX = characterX + dxf*delta;
Ã,  float newCharacterY = characterY + dyf*delta;
Ã,  int pixelMoveX = FloatToInt(newCharacterX) - FloatToInt(characterX);
Ã,  int pixelMoveY = FloatToInt(newCharacterY) - FloatToInt(characterY);
Ã,  if (pixelMoveX != 0 || pixelMoveY != 0)
Ã,  {
Ã,  Ã,  // check the diagonal move
Ã,  Ã,  if (PlayerCanMoveHere(player.x + dx, player.y + dy))
Ã,  Ã,  {
Ã,  Ã,  Ã,  // can move that way
Ã,  Ã,  Ã,  float maxDelta = delta;
Ã,  Ã,  Ã,  if (maxDelta > 1.0)
Ã,  Ã,  Ã,  {
Ã,  Ã,  Ã,  Ã,  maxDelta = 1.0;
Ã,  Ã,  Ã,  Ã,  dist -= 1.414;
Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  else
Ã,  Ã,  Ã,  {
Ã,  Ã,  Ã,  Ã,  dist = 0.0;
Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  characterX += dxf*maxDelta;
Ã,  Ã,  Ã,  characterY += dyf*maxDelta;
Ã,  Ã,  }
Ã,  Ã,  else
Ã,  Ã,  {
Ã,  Ã,  Ã,  if (PlayerCanMoveHere(player.x + dx, player.y))
Ã,  Ã,  Ã,  {
Ã,  Ã,  Ã,  Ã,  // round off the position
Ã,  Ã,  Ã,  Ã,  characterY = IntToFloat(FloatToInt(characterY)) + 0.5;
Ã,  Ã,  Ã,  Ã,  newDirect = slideDirX;
Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  else
Ã,  Ã,  Ã,  {
Ã,  Ã,  Ã,  Ã,  // round off the position
Ã,  Ã,  Ã,  Ã,  characterX = IntToFloat(FloatToInt(characterX)) + 0.5;
Ã,  Ã,  Ã,  Ã,  newDirect = slideDirY;
Ã,  Ã,  Ã,  }
Ã,  Ã,  }
Ã,  }
Ã,  else
Ã,  {
Ã,  Ã,  // pixelMove == 0
Ã,  Ã,  // didn't change pixel so just move within the pixel
Ã,  Ã,  characterX = newCharacterX;
Ã,  Ã,  characterY = newCharacterY;
Ã,  Ã,  // stop
Ã,  Ã,  dist = 0.0;
Ã,  }

Ã,  return dist;
}

float TryStraightMove(float dist, int dx, int dy)
{
Ã,  float delta = dist;
Ã,  float dxf = IntToFloat(dx);
Ã,  float dyf = IntToFloat(dy);
Ã,  float newCharacterX = characterX + dxf*delta;
Ã,  float newCharacterY = characterY + dyf*delta;
Ã,  int pixelMoveX = FloatToInt(newCharacterX) - FloatToInt(characterX);
Ã,  int pixelMoveY = FloatToInt(newCharacterY) - FloatToInt(characterY);
Ã,  if (pixelMoveX != 0 || pixelMoveY != 0)
Ã,  {
Ã,  Ã,  // check the move
Ã,  Ã,  if (PlayerCanMoveHere(player.x + dx, player.y + dy))
Ã,  Ã,  {
Ã,  Ã,  Ã,  // can move that way
Ã,  Ã,  Ã,  float maxDelta = delta;
Ã,  Ã,  Ã,  if (maxDelta > 1.0)
Ã,  Ã,  Ã,  {
Ã,  Ã,  Ã,  Ã,  maxDelta = 1.0;
Ã,  Ã,  Ã,  Ã,  dist -= 1.0;
Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  else
Ã,  Ã,  Ã,  {
Ã,  Ã,  Ã,  Ã,  dist = 0.0;
Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  characterX += dxf*maxDelta;
Ã,  Ã,  Ã,  characterY += dyf*maxDelta;
Ã,  Ã,  }
Ã,  Ã,  else
Ã,  Ã,  {
Ã,  Ã,  Ã,  // round off the position
Ã,  Ã,  Ã,  characterX = IntToFloat(player.x) + 0.5;
Ã,  Ã,  Ã,  characterY = IntToFloat(player.y) + 0.5;
Ã,  Ã,  Ã,  // stop moving
Ã,  Ã,  Ã,  dist = 0.0;
Ã,  Ã,  }
Ã,  }
Ã,  else
Ã,  {
Ã,  Ã,  // pixelMove == 0
Ã,  Ã,  // didn't change pixel so just move within the pixel
Ã,  Ã,  characterX = newCharacterX;
Ã,  Ã,  characterY = newCharacterY;
Ã,  Ã,  // stop
Ã,  Ã,  dist = 0.0;
Ã,  }

Ã,  return dist;
}

function DirectionFromKeyPresses()
{
Ã,  int Direct = DIR_STOP;
Ã,  if ((IsKeyPressed (371) > 0) || (IsKeyPressed (55) > 0) || ((IsKeyPressed (372) > 0) && (IsKeyPressed (375) > 0))) Direct = DIR_UP_LEFT;
Ã,  else if ((IsKeyPressed (373) > 0) || (IsKeyPressed (57) > 0) || ((IsKeyPressed (372) > 0) && (IsKeyPressed (377) > 0))) Direct = DIR_UP_RIGHT;
Ã,  else if ((IsKeyPressed (379) > 0) || (IsKeyPressed (49) > 0) || ((IsKeyPressed (380) > 0) && (IsKeyPressed (375) > 0))) Direct = DIR_DOWN_LEFT;
Ã,  else if ((IsKeyPressed (381) > 0) || (IsKeyPressed (51) > 0) || ((IsKeyPressed (380) > 0) && (IsKeyPressed (377) > 0))) Direct =DIR_DOWN_RIGHT;
Ã,  else if ((IsKeyPressed (372) > 0) || (IsKeyPressed (56) > 0)) Direct = DIR_UP;
Ã,  else if ((IsKeyPressed (375) > 0) || (IsKeyPressed (52) > 0)) Direct = DIR_LEFT;
Ã,  else if ((IsKeyPressed (376) > 0) || (IsKeyPressed (53) > 0)) Direct = DIR_STOP;
Ã,  else if ((IsKeyPressed (377) > 0) || (IsKeyPressed (54) > 0)) Direct = DIR_RIGHT;
Ã,  else if ((IsKeyPressed (380) > 0) || (IsKeyPressed (50) > 0)) Direct = DIR_DOWN;

Ã,  return Direct;
}



#sectionstart game_startÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function game_start() {
Ã,  characterX = IntToFloat(player.x) + 0.5;
Ã,  characterY = IntToFloat(player.y) + 0.5;
}
#sectionend game_startÃ,  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart repeatedly_executeÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute() {
Ã,  // put anything you want to happen every game cycle here
Ã,  if (IsGamePaused()==0) {

Ã,  Ã,  int Direct = DirectionFromKeyPresses(); // as before

Ã,  Ã,  if (Direct != oldDirect) {
Ã,  Ã,  Ã,  // changing direction, so reset these
Ã,  Ã,  Ã,  characterX = IntToFloat(player.x) + 0.5;
Ã,  Ã,  Ã,  characterY = IntToFloat(player.y) + 0.5;
Ã,  Ã,  }
Ã,  Ã,  if (Direct != DIR_STOP) {
Ã,  Ã,  Ã,  float dist = 0.75;
Ã,  Ã,  Ã,  if (IsKeyPressed(65)) // 'A'
Ã,  Ã,  Ã,  {
Ã,  Ã,  Ã,  Ã,  dist = 1.5;
Ã,  Ã,  Ã,  }

Ã,  Ã,  Ã,  // before the movement in rep_ex
Ã,  Ã,  Ã,  gNumNearbyChars = 0;
Ã,  Ã,  Ã,  int candidateIndex = 0;
Ã,  Ã,  Ã,  int numCharacters = GetGameParameter(GP_NUMCHARACTERS, 0, 0, 0);
Ã,  Ã,  Ã,  if (player.BlockingWidth == 0) player.BlockingWidth = 16;
Ã,  Ã,  Ã,  if (player.BlockingHeight == 0) player.BlockingHeight = 8;
Ã,  Ã,  Ã,  while (candidateIndex < numCharacters && gNumNearbyChars < MAX_NEARBY_CHARS)
Ã,  Ã,  Ã,  {
Ã,  Ã,  Ã,  Ã,  Character *candidate = character[candidateIndex];
Ã,  Ã,  Ã,  Ã,  if (candidate != player && candidate.Solid && candidate.Room == player.Room)
Ã,  Ã,  Ã,  Ã,  {
Ã,  Ã,  Ã,  Ã,  Ã,  // check proximity to player
Ã,  Ã,  Ã,  Ã,  Ã,  int dx = player.x - candidate.x;
Ã,  Ã,  Ã,  Ã,  Ã,  // 10 is a made up number but I doubt the player will move more than 10 pix/frame
Ã,  Ã,  Ã,  Ã,  Ã,  int cdx = player.BlockingWidth/2 + GetBlockingWidth(candidateIndex)/2 + 10;
Ã,  Ã,  Ã,  Ã,  Ã,  int dy = player.y - candidate.y;
Ã,  Ã,  Ã,  Ã,  Ã,  int cdy = player.BlockingHeight/2 + GetBlockingHeight(candidateIndex)/2 + 10;
Ã,  Ã,  Ã,  Ã,  Ã,  if ((dx*dx < cdx*cdx) && (dy*dy < cdy*cdy))
Ã,  Ã,  Ã,  Ã,  Ã,  {
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  gNearbyChars[gNumNearbyChars] = candidateIndex;
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  gNumNearbyChars++;
Ã,  Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  Ã,  candidateIndex++;
Ã,  Ã,  Ã,  }

Ã,  Ã,  Ã,  newDirect = Direct;
Ã,  Ã,  Ã,  while (dist > 0.0) {
Ã,  Ã,  Ã,  Ã,  if (newDirect == DIR_DOWN_LEFT) {
Ã,  Ã,  Ã,  Ã,  Ã,  dist = TryDiagonalMove(dist, -1, 1, DIR_LEFT, DIR_DOWN);
Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  Ã,  else if (newDirect == DIR_DOWN_RIGHT) {
Ã,  Ã,  Ã,  Ã,  Ã,  dist = TryDiagonalMove(dist, 1, 1, DIR_RIGHT, DIR_DOWN);
Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  Ã,  else if (newDirect == DIR_UP_LEFT) {
Ã,  Ã,  Ã,  Ã,  Ã,  dist = TryDiagonalMove(dist, -1, -1, DIR_LEFT, DIR_UP);
Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  Ã,  else if (newDirect == DIR_UP_RIGHT) {
Ã,  Ã,  Ã,  Ã,  Ã,  dist = TryDiagonalMove(dist, 1, -1, DIR_RIGHT, DIR_UP);
Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  Ã,  else if (newDirect == DIR_LEFT) {
Ã,  Ã,  Ã,  Ã,  Ã,  dist = TryStraightMove(dist, -1, 0);
Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  Ã,  else if (newDirect == DIR_RIGHT) {
Ã,  Ã,  Ã,  Ã,  Ã,  dist = TryStraightMove(dist, 1, 0);
Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  Ã,  else if (newDirect == DIR_UP) {
Ã,  Ã,  Ã,  Ã,  Ã,  dist = TryStraightMove(dist, 0, -1);
Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  Ã,  else if (newDirect == DIR_DOWN) {
Ã,  Ã,  Ã,  Ã,  Ã,  dist = TryStraightMove(dist, 0, 1);
Ã,  Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  Ã,  player.x = FloatToInt(characterX);
Ã,  Ã,  Ã,  Ã,  player.y = FloatToInt(characterY);
Ã,  Ã,  Ã,  }
Ã,  Ã,  }
Ã,  Ã,  oldDirect = Direct;

Ã,  Ã,  // now animate the character
Ã,  Ã,  if (Direct != DIR_STOP)
Ã,  Ã,  {
Ã,  Ã,  Ã,  animFrame += 0.1;
Ã,  Ã,  Ã,  // based on Roger who has 10 frames in the walk loop
Ã,  Ã,  Ã,  if (animFrame >= 10.0)
Ã,  Ã,  Ã,  {
Ã,  Ã,  Ã,  Ã,  // 9 of which are the walk cycle
Ã,  Ã,  Ã,  Ã,  animFrame -= 9.0;
Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  // change these if you only have four directions
Ã,  Ã,  Ã,  if (newDirect == DIR_DOWN_LEFT) player.Loop = 6;
Ã,  Ã,  Ã,  else if (newDirect == DIR_DOWN_RIGHT) player.Loop = 4;
Ã,  Ã,  Ã,  else if (newDirect == DIR_UP_LEFT) player.Loop = 7;
Ã,  Ã,  Ã,  else if (newDirect == DIR_UP_RIGHT) player.Loop = 5;
Ã,  Ã,  Ã,  else if (newDirect == DIR_LEFT) player.Loop = 1;
Ã,  Ã,  Ã,  else if (newDirect == DIR_RIGHT) player.Loop = 2;
Ã,  Ã,  Ã,  else if (newDirect == DIR_UP) player.Loop = 3;
Ã,  Ã,  Ã,  else if (newDirect == DIR_DOWN) player.Loop = 0;
Ã,  Ã,  Ã,  player.Frame = FloatToInt(animFrame);
Ã,  Ã,  }
Ã,  Ã,  else {
Ã,  Ã,  Ã,  // set the standing frame and reset the walk cycle
Ã,  Ã,  Ã,  player.Frame = 0;
Ã,  Ã,  Ã,  animFrame = 1.0;
Ã,  Ã,  }

Ã,  } //end if paused
Ã,  
}
#sectionend repeatedly_executeÃ,  // DO NOT EDIT OR REMOVE THIS LINE


[EDIT] Changed back from cEgo to player, restored running code.
[EDIT2] Added GetViewPort* adjustments for GetWalkableAreaAt() calls.
[EDIT3] Changed round off in diagonal move to only round the required axis.
[EDIT4] Added animation code.
[EDIT5] Fixed occasional getting stuck in a wall.
[EDIT6] Updated to reset the walk cycle and add comments about the number of walk frames.
[EDIT7] Updated to collide with characters.
[EDIT8] Added room check to characters.
#2387
ANIM_SPEED should have given you the same problem as DIR_DISTANCE.
Just comment those lines out for now - you'll need to come up with good values for ANIM_SPEED (maybe 0.1, i.e. advance an animation frame every 10 game frames) and NUM_FRAMES (4 if the walk cycle is 4 frames) that correspond to the main character running/walking.

Phew, we're getting there...
#2388
Quote from: Kinoko on Tue 05/07/2005 14:25:01
EDIT: "Cannot convert int to float" ->Ã,  Ã, float dist = DIR_DISTANCE;

Damn. I'm surprised that didn't work.
Try this instead:
Code: ags

float dist = 0.75;
if (IsKeyPressed(keya))
{
Ã,  // running, so go twice the distance
Ã,  dist = 1.5;
}


0.75 and 1.5 are how far in pixels the player will move per frame. You'll need to tweak these.

A float is just a "real" number, as opposed to an integer, if you remember that from maths class. (It's short for floating-point number.)
#2389
General Discussion / Re: Hey dudes I'm back!
Tue 05/07/2005 14:19:03
Hey, welcome back.
There haven't been enough "nice" games made without you.
Looking forward to another!
#2390
You were supposed to substitute your block of code that finds the direction from key presses there.

Code: ags


function DirectionFromKeyPresses()
{
  int Direct = DIR_NONE;
       if ((IsKeyPressed (371) > 0) || (IsKeyPressed (55) > 0) || ((IsKeyPressed (372) > 0) && (IsKeyPressed (375) > 0))) Direct = DIR_UP_LEFT;
  else if ((IsKeyPressed (373) > 0) || (IsKeyPressed (57) > 0) || ((IsKeyPressed (372) > 0) && (IsKeyPressed (377) > 0))) Direct = DIR_UP_RIGHT; 
        else if ((IsKeyPressed (379) > 0) || (IsKeyPressed (49) > 0) || ((IsKeyPressed (380) > 0) && (IsKeyPressed (375) > 0))) Direct = DIR_DOWN_LEFT;
 else if ((IsKeyPressed (381) > 0) || (IsKeyPressed (51) > 0) || ((IsKeyPressed (380) > 0) && (IsKeyPressed (377) > 0))) Direct =DIR_DOWN_RIGHT;
  else if ((IsKeyPressed (372) > 0) || (IsKeyPressed (56) > 0)) Direct = DIR_UP; 
  else if ((IsKeyPressed (375) > 0) || (IsKeyPressed (52) > 0)) Direct = DIR_LEFT; 
  else if ((IsKeyPressed (376) > 0) || (IsKeyPressed (53) > 0)) Direct = DIR_STOP; 
  else if ((IsKeyPressed (377) > 0) || (IsKeyPressed (54) > 0)) Direct = DIR_RIGHT; 
  else if ((IsKeyPressed (380) > 0) || (IsKeyPressed (50) > 0)) Direct = DIR_DOWN; 

  return Direct;
}


You'll probably want to wrap the whole thing in a "IsGamePaused()", and I didn't look up the proper expression for testing the walkable area so that might be wrong too.

Also, I didn't write the code to animate the character. You'll need to do something about that.

Good luck!
#2391
No, it should all work from the global repeatedly_execute.
[EDIT - apart from that bit I said had to be in the room. Ugh. It should work pretty well without it though.]

Please send drinks to:
Creation of Adventures Studio Haven
Boat "The Onion Ring"
Ocho Rios Harbour
Jamaica
#2392
Sounds like a slowed down Jamiroquai song.
Or, in other words, I think it's too slow for a dance number.
#2393
Umm, no. I haven't had a chance to look into it.
I know it would be nice, and I'll be investigating it soon, but I can't promise anything.
#2394
There's a reason it was taken out of print :)

I don't get why the online version is B&W. It's hard to see what some of the images are supposed to represent.

Still, it's quite technical, so maybe the text is useful. And hey, it's free.
#2395
Bump to announce new version - fixes mpg/avi playback.
See first post for details or get it here:
http://www.adventuregamestudio.co.uk/mac/AGS271beta2c.dmg
Steve
#2396
I think it's going to be difficult to tweak your "old code" to do what you want.
Here's how I'd do it instead.

You'll need to know how many pixels the character moves every frame (every time repeatedly execute is run, in other words).
Use that to predict where the character will be next frame. Then break down the movement into pixels and see if there is walkable ground at each pixel. If so, move; if not, and you are moving diagonally, try the corresponding straight moves.
Then, animate the character independent of how it actually moves.

For the movements, you'll need to use floats to store character's position and the per frame movement.

//PSEUDOCODE (i.e. I haven't tested it :):
Code: ags

float characterX;
float characterY;
float animFrame = 0.0;

// character walks 30 = 0.75*GetGameSpeed() pixels per second
// (obviously assumes GetGameSpeed() is the default 40)
#define DIR_DISTANCE 0.75
// character changes animation frame every other game frame
#define ANIM_SPEED 0.5

// in player enters room:
// start in the middle of the pixel
characterX = IntToFloat(player.x) + 0.5;
characterY = IntToFloat(player.y) + 0.5;
int oldDirect = DIR_STOP;

// free functions
function TryDiagonalMove(float dist, int dir, int dx, int dy, int slideDirX, int slideDirY)
{
Ã,  int newDir = dir;
Ã,  // test that direction
Ã,  float delta = 0.7071*dist;
Ã,  float dxf = IntToFloat(dx);
Ã,  float dyf = IntToFloat(dy);
Ã,  float newCharacterX = characterX + dxf*delta;
Ã,  int pixelMove = FloatToInt(newCharacterX) - FloatToInt(characterX);
Ã,  if (pixelMove != 0)
Ã,  {
Ã,  Ã,  // check the diagonal move
Ã,  Ã,  if (GetWalkableAreaAt(player.x + dx, player.y + dy) != 0)
Ã,  Ã,  {
Ã,  Ã,  Ã,  // can move that way
Ã,  Ã,  Ã,  float maxDelta = delta;
Ã,  Ã,  Ã,  if (maxDelta > 1.0)
Ã,  Ã,  Ã,  {
Ã,  Ã,  Ã,  Ã,  maxDelta = 1.0;
Ã,  Ã,  Ã,  Ã,  dist -= 1.414;
Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  else
Ã,  Ã,  Ã,  {
Ã,  Ã,  Ã,  Ã,  dist = 0.0;
Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  characterX += dxf*maxDelta;
Ã,  Ã,  Ã,  characterY += dyf*maxDelta;
Ã,  Ã,  }
Ã,  Ã,  else
Ã,  Ã,  {
Ã,  Ã,  Ã,  // round off the position
Ã,  Ã,  Ã,  characterX = IntToFloat(FloatToInt(characterX)) + 0.5;
Ã,  Ã,  Ã,  characterY = IntToFloat(FloatToInt(characterY)) + 0.5;
Ã,  Ã,  Ã,  if (GetWalkableAreaAt(player.x + dx, player.y) != 0)
Ã,  Ã,  Ã,  {
Ã,  Ã,  Ã,  Ã,  newDir = slideDirX;
Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  else
Ã,  Ã,  Ã,  {
Ã,  Ã,  Ã,  Ã,  newDir = slideDirY;
Ã,  Ã,  Ã,  }
Ã,  Ã,  }
Ã,  }
Ã,  else
Ã,  {
Ã,  Ã,  // pixelMove == 0
Ã,  Ã,  // didn't change pixel so just move within the pixel
Ã,  Ã,  characterX = characterX + dxf*delta;
Ã,  Ã,  characterY = characterY + dyf*delta;
Ã,  Ã,  // stop
Ã,  Ã,  dist = 0.0;
Ã,  }
Ã,  
Ã,  return newDir;
}

function TryStraightMove(float dist, int dx, int dy)
{
Ã,  float delta = dist;
Ã,  float dxf = IntToFloat(dx);
Ã,  float dyf = IntToFloat(dy);
Ã,  float newCharacterX = characterX + dxf*delta;
Ã,  float newCharacterY = characterY + dyf*delta;
Ã,  int pixelMoveX = FloatToInt(newCharacterX) - FloatToInt(characterX);
Ã,  int pixelMoveY = FloatToInt(newCharacterY) - FloatToInt(characterY);
Ã,  if (pixelMoveX != 0 || pixelMoveY != 0)
Ã,  {
Ã,  Ã,  // check the move
Ã,  Ã,  if (GetWalkableAreaAt(player.x + dx, player.y + dy) != 0)
Ã,  Ã,  {
Ã,  Ã,  Ã,  // can move that way
Ã,  Ã,  Ã,  float maxDelta = delta;
Ã,  Ã,  Ã,  if (maxDelta > 1.0)
Ã,  Ã,  Ã,  {
Ã,  Ã,  Ã,  Ã,  maxDelta = 1.0;
Ã,  Ã,  Ã,  Ã,  dist -= 1.0;
Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  else
Ã,  Ã,  Ã,  {
Ã,  Ã,  Ã,  Ã,  dist = 0.0;
Ã,  Ã,  Ã,  }
Ã,  Ã,  Ã,  characterX += dxf*maxDelta;
Ã,  Ã,  Ã,  characterY += dyf*maxDelta;
Ã,  Ã,  }
Ã,  Ã,  else
Ã,  Ã,  {
Ã,  Ã,  Ã,  // round off the position
Ã,  Ã,  Ã,  characterX = IntToFloat(FloatToInt(characterX)) + 0.5;
Ã,  Ã,  Ã,  characterY = IntToFloat(FloatToInt(characterY)) + 0.5;
Ã,  Ã,  Ã,  // stop moving
Ã,  Ã,  Ã,  dist = 0.0;
Ã,  Ã,  }
Ã,  }
Ã,  else
Ã,  {
Ã,  Ã,  // pixelMove == 0
Ã,  Ã,  // didn't change pixel so just move within the pixel
Ã,  Ã,  characterX = characterX + dxf*delta;
Ã,  Ã,  characterY = characterY + dyf*delta;
Ã,  Ã,  // stop
Ã,  Ã,  dist = 0.0;
Ã,  }Ã,  
}

// in repeatedly execute:

Direct = DirectionFromKeyPresses(); // as before

if (Direct != oldDirect)
{
Ã,  // changing direction, so reset these
Ã,  characterX = IntToFloat(player.x) + 0.5;
Ã,  characterY = IntToFloat(player.y) + 0.5;
}
if (Direct != DIR_STOP)
{
Ã,  float dist = DIR_DISTANCE;
Ã,  if (IsKeyPressed(keya))
Ã,  {
Ã,  Ã,  // running
Ã,  Ã,  dist = 2.0*DIR_DISTANCE;
Ã,  }
Ã,  int newDir = Direct;
Ã,  while (dist > 0.0)
Ã,  {
Ã,  Ã,  if (newDir == DIR_DOWN_LEFT)
Ã,  Ã,  {
Ã,  Ã,  Ã,  newDir = TryDiagonalMove(dist, newDir, -1, 1, DIR_LEFT, DIR_DOWN);
Ã,  Ã,  }
Ã,  Ã,  else if (newDir == DIR_DOWN_RIGHT)
Ã,  Ã,  {
Ã,  Ã,  Ã,  newDir = TryDiagonalMove(dist, newDir, 1, 1, DIR_RIGHT, DIR_DOWN);
Ã,  Ã,  }
Ã,  Ã,  else if (newDir == DIR_UP_LEFT)
Ã,  Ã,  {
Ã,  Ã,  Ã,  newDir = TryDiagonalMove(dist, newDir, -1, -1, DIR_LEFT, DIR_UP);
Ã,  Ã,  }
Ã,  Ã,  else if (newDir == DIR_UP_RIGHT)
Ã,  Ã,  {
Ã,  Ã,  Ã,  newDir = TryDiagonalMove(dist, newDir, 1, -1, DIR_RIGHT, DIR_UP);
Ã,  Ã,  }
Ã,  Ã,  else if (newDir == DIR_LEFT)
Ã,  Ã,  {
Ã,  Ã,  Ã,  TryStraightMove(dist, -1, 0);
Ã,  Ã,  }
Ã,  Ã,  else if (newDir == DIR_RIGHT)
Ã,  Ã,  {
Ã,  Ã,  Ã,  TryStraightMove(dist, 1, 0);
Ã,  Ã,  }
Ã,  Ã,  else if (newDir == DIR_UP)
Ã,  Ã,  {
Ã,  Ã,  Ã,  TryStraightMove(dist, 0, -1);
Ã,  Ã,  }
Ã,  Ã,  else if (newDir == DIR_DOWN)
Ã,  Ã,  {
Ã,  Ã,  Ã,  TryStraightMove(dist, 0, 1);
Ã,  Ã,  }
Ã,  }
Ã,  
Ã,  // now animate the character
Ã,  animFrame += ANIM_SPEED;
Ã,  int animFrameInt = FloatToInt(animFrame);
Ã,  if (animFrameInt > NUM_FRAMES) animFrameInt = 0;
Ã,  // TODO: set the player loop and frame depending on Direct and animFrameInt
}
else
{
  // TODO: set the standing frame based on oldDirect
}
player.x = FloatToInt(characterX);
player.y = FloatToInt(characterY);
oldDirect = Direct;


Sorry it's a bit long.
It might have been better using some lookup tables, but AGS doesn't lend itself to setting those up.
#2397
Dang.
Please pass these questions on to the testers:

What sort of mac? What version of Tiger? What screen resolution and colour depth?
What was the error message?
Send me the 'agserror.txt' file in the game directory.
Plus, open
~/Library/Logs/CrashReporter/AGSRunTime.crash.log
and send me the contents.

Then PM me with any feedback.
Also, can you provide me with a link to the game and I can test it here? Unless you'd rather not...

Thanks,
Steve
#2398
Advanced Technical Forum / Re: Sound of stairs
Mon 04/07/2005 05:56:58
Gil, I presume the "same result" is the result from the "steps onto region" method, i.e., it only plays the sound occasionally.

Here's what I'd do...
Just block out the whole stairs as region 2.
Then:

int lastStepSoundY = 0;
int stepIntervalY = 9;

repeatedly_execute_always

if (Region.GetAtRoomXY(player.x, player.y) == region[REGION_STAIR])
{
Ã, // round y to the nearest interval
Ã, int thisStepSoundY = player.y/stepIntervalY;
Ã, thisStepSoundY = stepIntervalY*thisStepSoundY;
Ã, // if it changes interval, play the sound
Ã, if (thisStepSoundY != lastStepSoundY)
Ã, {
Ã,  Ã, PlaySound(SOUND_CREAK);
Ã,  Ã, lastStepSoundY = thisStepSoundY;
Ã, }
}

Alternatively, if you want the sound to at the same rate when walking diagonally on the stairs...

int lastStepX = 0;
int lastStepY = 0;

int stepInterval = 9;

repeatedly_execute_always

if (Region.GetAtRoomXY(player.x, player.y) == region[REGION_STAIR])
{
Ã, int dx = lastStepX - player.x;
Ã, int dy = lastStepY - player.y;
Ã, if ((dx*dx + dy*dy) < stepInterval*stepInterval)
Ã, {
Ã,  Ã, PlaySound(SOUND_CREAK);
Ã,  Ã, lastStepX = player.x;
Ã,  Ã, lastStepY = player.y;
Ã, }
}

These aren't entirely equivalent - the first method might produce an irregular rhythm of sounds, depending on the speed of the character. You can adapt the second to the first (only Y) though.

Cheers,
Steve
#2399
General Discussion / Re: Gaming Hacks
Sun 03/07/2005 21:50:15
It sounds like he didn't actually buy the book.
And who could blame him, when it's $15 cheaper on amazon?

How dare they call AGS game creation "hacking"?
It's a craft and an art, I tell ye.
(Unless they mean hacking in the original sense... I don't think so though.)
#2400
Hear hear.
Glad to see not all australians are totally berko.

Federer really seems like a nice guy. Although is it possible these days for a tennis player to go a match without punching the air? That would be good.
SMF spam blocked by CleanTalk