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

#221
Hey guys!

Sorry I havent replied in a while, I havent had time to work at all on my game since the last time :P

@Khris: WOw, this is great! I tried it, everything works with a "normal" player, however when I use it with my car player, Ive got this line in rep_exec (taken from the Taxi Demo game):

Code: ags

    player.x = oCar.X + half_sprite_size;
    player.y = oCar.Y - half_sprite_size;


How do I integrate that to your script so that the car's front/back part of the sprite is detected exactly when it touches the region? Right now since Ihave those 2 lines, the car can "enter" the region almost halfway before triggering my debug line "player is inside region":

Code: ags

bool InsideBounds_ISO(this Character*, int iX1, int iY1, int iX2, int iY2) //iMinX's vector (x,y) and iMax's vector(x,y)
{
  int iXp = this.x;
  int iYp = this.y;
  // d is vector from X1;Y1 to X2;Y2
  float dx = IntToFloat(iX2 - iX1), dy = IntToFloat(iY2 - iY1);
  // a is vector from X1;Y1 to top corner
  // b is vector from X1;Y1 to bottom corner  (a + b = d)
  float bx = (m*dx - dy)/(2.0*m);
  float ax = dx - bx;
  float ay = m * ax, by = -m * bx;
  // express character coords using a & b
  // p is vector from X1,Y1 to character
  float px = IntToFloat(iXp - iX1), py = IntToFloat(iYp - iY1);
  float det = ay*bx - ax*by;
  // p = k*a + l*b
  float k = (bx*py - by*px)/det;
  float l = (ay*px - ax*py)/det;
  // => if both k & l are inside [0;1], character is inside parallelogram
  return (k >= 0.0 && k <= 1.0 && l >= 0.0 && l <= 1.0);
}

// in rep_exec:

    if (player.InsideBounds_ISO(2323, 1593, 2473, 1623)) //REGION A
    {
      Display("player is inside REGION A!"); //debug line
    }




@Sephiroth: Wow thanks for that script :) Im going to try that tonight and see how it goes: I can use it in conjunction with Khris's and see what I come up with. Ill post the results so others can use it too! :)

**
Code: ags
 
doesnt seem to work right now (?)[/s]
#222
Ok I  think I got it to work...here is what I did (I placed it in a BOOL function). Do you see any problems with this code? Also, (if you feel like it), what would be a nicer, more efficient and more elegant way of writing what I did?

Also, I placed this in my rep_exec...meaning it will constantly check the player's position in relation to where the "virtual rhombus region" is...and Im surely going to be making a crap load of them, so could  this be potentially too heavy to
run constantly? One of the main reasons I was thinking I could use this is to have pretty much an infinite amount of regions/hotspots/walkable areas. (It should work, right?)
Code: ags

bool InsideBounds_ISO(this Character*, int iMinX, int iMaxX, int iMinY, int iMaxY)
{
  int iXc; //Center X of rhombus area
  int iYc; //Center Y of rhombus area 
  int iXp = player.x;
  int iYp = player.y;

  int iY_TL; //Y on the TOP-LEFT tangeant
  int iY_TR; //Y on the TOP-RIGHT tangeant
  int iY_BL; //Y on the BOTTOM-LEFT tangeant
  int iY_BR; //Y on the BOTTOM-RIGHT tangeant

  int iX; //X on the tangeant
  float fSin30 = Maths.Sin(Maths.DegreesToRadians(30.0));
  int iSin30 = FloatToInt(fSin30, eRoundNearest);
  int iTL;
  int iTR;
  int iBL;
  int iBR;

  iXc = (iMinX + iMaxX)/2;  
  iYc = (iMinY + iMaxY)/2;

  iTL = iYc - iSin30 * iMinX;         //TOP LEFT LINE
  iTR = iYc - (-1*iSin30) * iMaxX;  //TOP RIGHT LINE
  iBL = iYc - (-1*iSin30) * iMinX;  //BOTTOM LEFT LINE
  iBR = iYc - iSin30 * iMaxX;         //BOTTOM RIGHT LINE

  iY_TL = iSin30 * iXp + iTL;
  iY_TR = (-1*iSin30) * iXp + iTR;
  iY_BL = (-1*iSin30) * iXp + iBL;
  iY_BR = iSin30 * iXp + iBR;
  if ((iYp <= iY_TL) && (iYp <= iY_TR) && (iYp >= iY_BL) && (iYp >= iY_BR))  return true;
  else return false;
}
#223
Wow ok its that easy? NICE!

Ill check out the tutorials then on how to do all that.  :)
#224
QuoteYes but I can't be arsed.

Lol! haha ok.

For those of use that cant change the editor, do you think that increasing the object limit to 80 or 100 (like icy asked) could be implemented in your next release?

Pwetty please!! :)

#225
Could the dark theme be a checkbox you select? Maybe then we could have different color schemes that users can save, and load?
#226
Nice!

Ok, Im gonna try  that right now!

Just to be sure sure sure I understand your full post, method "1a" is for a perfect diamond-rhombus, the rest (steps 1 through 5) are for irregular rhombuses such as the green ones...right?

Thanks btw! :)
#227
I put this is advanced but Im not sure how easy/hard this really is.

Ive got a script that checks if  the player is inside a certain boundary, but its rectangular in shape:
Code: ags

function playerInsideBounds(int iMinX, int iMaxX, int iMinY, int iMaxY)
{
  //Display("**function playerInsideBounds...");
  return ((player.x >= iMinX && player.x <= iMaxX) && (player.y >= iMinY && player.y <= iMaxY));
}


Since Id like to check if a player is inside a diamond-shape boundary (isometric) without using hotspots or regions, what is the math I need to make sure the extra "triangles" get cut off of the rectangle so that the area is for a diamond (blue lozenge below) (Do I have to multiply the y coordinates by sin(30°), ~ 0.454 ?)

**EDIT**
(And would that same formula work for non-diamond rhombuses too, like the green zones in the above picture?)

#228
I guess this should be in advanced then :P
#229
Critics' Lounge / Re: Character sprite
Sun 15/04/2012 06:41:42
My first reaction was it looked like he is wearing ear muffs or big headphones. I like Anian's modification to the character's hairline.

He looks pretty cool, a PI eh...! No Selleck mustache? :P
#230
This is awesome, integrating it now! Thanks once again :)
#231
Id also rather:
cJack.speech("Hello, my name is Jack", 475);

Cool plugin so far!
#232
Ill try to post a quick vid on youtube to show what Ive been able to figure out myself so far...maybe this will give a better idea!

**edit:

Ive got almost everything figured out myself (yay!) except for how to do the block animation of the car turning (getting the trigonometry math)...I'll still continue to fiddle away on that last part myself for now...but if I get REALLY stuck on it I'll post again here again to beg for help, hehe!

Here is another pic to help clarify what I mean:


How do I calculate the pivot point's position (x,y)...it seems by manual placing its something around (0, 3.25)...but how do I get to those numbers mathematically?

Also, Im not sure of the mathematic formula to get the waypoint vectors along the curves generated between points.

#233
Hi guys,

Ive been trying a few things (from this thread: http://www.adventuregamestudio.co.uk/yabb/index.php?topic=44508.msg610016#msg610016) and I though of something that I think would work...but not too sure of how to get the math for a trigonometry reflection on vectors:



It would go something like this:

0) Once the car walks onto the region before an intersection, we save/get some variables (speed, direction of car, current car sprite, if the light is green or red, if the turn indicator is set to turn right, left, or straight ahead ) and then move the car with blocking animation from point A to point B, while deccelerating to an almost stop (decceleration code taken from the Taxi Demo)

1) Once the car walks off the region, if one of the turn indicators on the GUI was set to "turn right", for example, the variable is read and start the procedure of turning the car right at the intersection: we save the current position of the car...then calculate the car's destination position using trigonometry math (reflection on the imaginary y axis that divides the intersection in 2, since we are turning right)

2) With blocking animation, move the car along a curved line from current position to the destination position, using an "x" amount of frames from a pool of sprites pre-rendered by increments of xº angles. The smaller the curve, the less frames the animation gets ("x" minimum), and the longer the curve, the more it gets ("x" maximum.) **Dont know what these "x" values should be  :P

3) Once  the blocking animation is done and the car is now at its destination position in the Destination Region (with proper direction angle + sprite), the car resumes its movement forward with the same speed settings that was saved when the car originally walked onto  the "Turn Region".

Could anyone be kind enough to workout some code to show how I could accomplish all this?
;D

#234
Hmm, ok I see what you mean. Crap!!

Ok, I  think I remember you talking about the "circle solution" before with 2 radiuses...Ill see what I can manage, but it does seem over my head at first glance.

Ill try and see what I can come up with! Thnx Ryan
#235
Hey Ryan,

Yeah, Ive decided to make it closer to the old police quest games...more like police quest 1 mixed in with police quest 3. It wont be like GTA (free roam)...its too much for me to handle so Id rather start small and see where it leads me.

Basically if you "miss" your intersection turn (not pressing the right keypress at the right time when you're over the hotspot/region), then you dont turn...heh. You have to go around the block like in PQ3...annoying, but I guess I always liked punishing players mUAAaa.

Also, if you do a lane change at the wrong time (say an oncoming car is in your lane)...well unless you have time to do another lane change back, you will crash and die a horrible death (like in PQ1 EGA).

Where it will differ from the old police quest games is the map will be detailed and isometric...not quite a cutscene, there will be more playability but not as much as GTA.

Why should I stay away from hotspots/regions? Im not too sure how else I can get the car to detect when its at an intersection without using those.
#236
I know, its long!

Ill still try to debug it myself in the meantime
#237
Hi guys,

Ive been away for a while due to losing my job via "downsizing", so I had to put my hobby on hold until I got a new job...man that really sucked! Didnt have much time at all to work on this.

Anyways, Ive got a new job so Im back to my hobby :)

Ive been slowly trying to put together an isometric driving module for my  game with pretty good results so far. However, Ive tried a few things here and there by mixing some code snippets and using the source of Taxi Demo (a lot, actually). Im currently attempting to modify the Taxi Demo code to suit my needs. Ive decided to try a different approach than what I posted previously (thanks Wyz for the code, for now I will put that "driving mode" on hold)

Here is mostly the Taxi Demo code, but modified to get what I want...I put in "Display debug lines" to help explain what Im trying to do...SORRY for the LONG code...I hope I dont scare anyone away!
Code: ags

// room script file

//int iCar_1stSprite = 4090; //4181, 4090 -->angle plus the 1st sprite's number in the car's sprite list...
int iCar_1stSprite = 4181;

struct vector
{
	float x;
	float y;
};

vector car;
vector oldcar;
vector tires[4];
vector oldtires[4];
vector velocity;
vector acceleration;
vector velocity_world;
vector acceleration_world;
float Ftraction = 0.0;
float Fside = 0.0;
float Fside_friction = 15000.0; //15000
vector Fdrag;
vector Frr;
vector F;

vector screenoffset;
vector wanted_screenoffset;
#define screenoffset_step 1.0
#define half_screen_width 512
#define half_screen_height 384
#define screen_width 1024
#define screen_height 768

float drive_angle = 0.0;
float body_angle = 0.0;
float turn_speed = 0.0;
float max_turn_speed = 6.0; //7
float max_turn_speed_multiply = 3.0; //7
float body_turn_speed = 0.0;
float max_body_turn_speed = 8.0; //10
float steer_angle = 0.0;
float max_steer_angle = 0.2;

int wall_angles[16];
int wallareas[3];

#define Fthrottle 5000.0 //8000
#define Fbrake 8000.0
#define Cdrag 0.1
#define Crr 20.0
#define scale 7.5
#define mass 410.0//410
#define delta_time 0.025
#define half_sprite_size 22//22
#define half_wheel_base 1.5
#define half_rail_width 0.6

float pulsate = 0.0;

float fAbs(float in)
{
	if(in < 0.0) return -in;
	else return in;
}

float fMax(float a, float b)
{
	if(a < b) return b;
	else return a;
}

float fMin(float a, float b)
{
	if(a > b) return b;
	else return a;
}

function IsWalkable(int x, int y)
{
	intare = 0;
	whileare < 3)
  {
		if(GetWalkableAreaAt(x - GetViewportX(), y - GetViewportY()) == wallareas[r]) return false;
	are++;
	}	
	return true;
}

function GetWalkable(int x, int y)
{
	return GetWalkableAreaAt(x - GetViewportX(), y - GetViewportY());
}

function moveToWalkable()
{
  if (iDriveMode == 1)
  {
    intare = 0;
    whileare < 4)
    {
      int newx = FloatToInt(tires[r].x * scale, eRoundNearest);
      int newy = FloatToInt(tires[r].y * scale, eRoundNearest);
      int oldx = newx;
      int oldy = newy;
      bool onwalk = false;
      int movement = 1;
      while(!onwalk)
      {
        if (IsWalkable(newx, newy)) onwalk = true;
        else
        {
          if (IsWalkable(newx + movement, newy))
          {
            onwalk = true;
            newx += movement;
          }
          else if (IsWalkable(newx - movement, newy))
          {
            onwalk = true;
            newx -= movement;
          }
          else if (IsWalkable(newx, newy + movement))
          {
            onwalk = true;
            newy += movement;
          }
          else if (IsWalkable(newx, newy - movement))
          {
            onwalk = true;
            newy -= movement;
          }	
          movement++;
        }
      }
      if (oldx != newx|| oldy != newy)
      {
        car.x += IntToFloat(newx - oldx) / scale;
        car.y += IntToFloat(newy - oldy) / scale;
      }	
     are++;
    }
  }
}

void updateCarSprite()
{ 
	if (iDriveMode == 1)
  {

    //with 360 sprites
    int iAdd;
    int angle = FloatToInt(body_angle, eRoundNearest);
    if (angle == 0 || angle == 360) iAdd = 0;
    else if ((angle >= 29 && angle <= 31) || (angle >= 209 && angle <= 211)) iAdd = 11;
    else if ((angle >= 149 && angle <= 151) || (angle >= 329 && angle <= 331)) iAdd = -11;
    //else if (angle) iAdd = 11; //+ 5 increments
    else iAdd = 1;
    oCar.Graphic = angle+iCar_1stSprite+iAdd; //add 1 for the first sprite that is 0°
  }
}

function on_key_press(int keycode) 
{
  //rotate car's angle when immobile only:
  if (velocity.x == 0.0)
  {
    if (keycode == 375)
    {
      Display("Rotate Left");
      body_angle = body_angle-30.0;
      drive_angle = body_angle;
    }
    else if (keycode == 377)
    {
      Display("Rotate Right");
      body_angle = body_angle+30.0;
      drive_angle = body_angle;
    }
    else if (IsKeyPressed(380)) //Down 
    {
      
    }
    else if (IsKeyPressed(372)) //Up
    {
      
    }
  }
}

function room_Load()
{
  //gTitleBar.Visible =false;
  //iDriveMode = 0; //mouse-iso style
  iDriveMode = 1; //taxi style (press keyboard once, the car will eventually slowly stop)
  //iDriveMode = 2; //keyboard tapping mode (press keyboard once, the car continues in that direction forever)
  cPatrolCar.SetAsPlayer();
  if (iDriveMode == 2) cPatrolCar.LockView(110);
  
  body_angle = 330.0;
  drive_angle = body_angle;
      
	System.VSync = true;

	if (iDriveMode == 1)
  {
    wallareas[0] = 0;
    wallareas[1] = 2;
    wallareas[2] = 0;

    screenoffset.x = 0.0;
    screenoffset.y = 0.0;
    wall_angles[2] = 0;
    wall_angles[3] = 90;
    wall_angles[6] = 0;
    wall_angles[7] = 90;
    Debug(4, 1);

    car.x = IntToFloat(oCar.X) / scale;
    car.y = IntToFloat(oCar.Y) / scale;
    oCar.X = FloatToInt(car.x * scale, eRoundNearest) - half_sprite_size;
    oCar.Y = FloatToInt(car.y * scale, eRoundNearest) + half_sprite_size;
    
    updateCarSprite();
    
    SetViewport(oCar.X - half_screen_width + half_sprite_size + FloatToInt(screenoffset.x, eRoundNearest), oCar.Y - half_screen_height - half_sprite_size + FloatToInt(screenoffset.y, eRoundNearest));
  }
}

function room_RepExec()
{
  if (iDriveMode == 1)
  {
    if (IsKeyPressed(375)) //Left key
    {
      if (velocity.x > 0.0) Display("Left Strafe key is pressed, car is moving forward, strafe car Left...");
      else
      {
        if (velocity.x < 0.0) Display("Left key pressed, car is in reverse, do nothing..."); //reverse
        else Display("Left key pressed, car is immobile, rotate car Left...");
      }
    }
    else if (IsKeyPressed(377)) //Right key
    {
      if (velocity.x > 0.0) Display("Right Strafe key is pressed, car is moving forward, strafe car right...");
      else
      {
        if (velocity.x < 0.0) Display("Right key pressed, car is in reverse, do nothing..."); //reverse
        else Display("Right key pressed, car is immobile, rotate car right...");
      }
    }

    if (IsKeyPressed(380)) //Down 
    {
      //Display("Down key pressed...");
      if (velocity.x > 0.0)
      {
        Display("Down key is pressed, car is moving forward, decelerate or brake car...");
        Ftraction = -Fbrake; // brake
      }
      else // reverse
      {	
        if (velocity.x > -25.0)
        {
          Ftraction += -Fthrottle / 16.0;
          if (Ftraction < -Fthrottle / 2.0) Ftraction = -Fthrottle / 2.0;
        }	
        else Ftraction = 0.0;
      }
    }
    else if (IsKeyPressed(372)) //Up
    {
      if (velocity.x < 0.0) 
      {
        Display("Up key pressed, car in reverse, brake car...");
        Ftraction = Fbrake;  // brake
      }
      else // throttle
      {
        if (velocity.x == 0.0) Display("Up key pressed, car is stopped...accelerate car...");
        else Display("Up key pressed, car is moving forward...accelerate to next speed level...");
        Ftraction += Fthrottle / 8.0;
        if (Ftraction > Fthrottle) Ftraction = Fthrottle;
      }
    }
    else //if nothing is pressed...slowly stop the car...
    {
      if (velocity.x == 0.0)
      {
        Ftraction = 0.0;
        velocity.x = 0.0;        
      }
      /*
      if (velocity.x > 0.1) //car is moving forward, come to a stop
      {
        Ftraction += -Fbrake / 32.0;
        if (Ftraction < -Fbrake / 4.0) Ftraction = -Fbrake / 4.0;
      }
      else if (velocity.x < -0.1) //car is moving backwards, come to a stop
      {
        Ftraction += Fbrake / 32.0;
        if (Ftraction > Fbrake / 4.0) Ftraction = Fbrake / 4.0;
      }
      else //if car is not moving, do nothing...
      {
        Ftraction = 0.0;
        velocity.x = 0.0;
      }*/
    }
  }
}

function repeatedly_execute_always()
{
  if (iDriveMode == 1)
  {
    if (steer_angle > max_steer_angle) steer_angle = max_steer_angle;
    else if (steer_angle < -max_steer_angle) steer_angle = -max_steer_angle;
    
    turn_speed = steer_angle * velocity.x * 1.0; //2.0
    
    body_turn_speed = 0.0;
    if (Region.GetAtRoomXY(player.x, player.y) == region[1]) max_turn_speed = max_turn_speed_multiply - (fAbs(velocity.x) * 0.08); //0.08
    else max_turn_speed = max_turn_speed_multiply - (fAbs(velocity.x) * 0.05); //0.05
    
    if (acceleration.x * 0.1 > 0.0) max_turn_speed += acceleration.x * 0.1;
    if (turn_speed > max_turn_speed)
    {
      body_turn_speed = turn_speed + velocity.x * (turn_speed - max_turn_speed) * 0.025; //0.05
      turn_speed = max_turn_speed;
    }
    else if (turn_speed < -max_turn_speed)
    {
      body_turn_speed = turn_speed + velocity.x * (turn_speed + max_turn_speed) * 0.025; //0.05
      turn_speed = -max_turn_speed;
    }	
    if (velocity.y > 0.0)
    {
      Fside += -Fside_friction / 4.0; //4.0
      if (Fside < -Fside_friction) Fside = -Fside_friction;
    }
    else if (velocity.y < -0.0) 
    {
      Fside += Fside_friction / 4.0; //4.0
      if(Fside > Fside_friction) Fside = Fside_friction;
    }
    else Fside = 0.0;

    oldcar.x = car.x;
    oldcar.y = car.y;
    intare = 0;
    while are < 4)
    {
      oldtires[r].x = tires[r].x;
      oldtires[r].y = tires[r].y;
     are++;
    }
    
    drive_angle += turn_speed;
    body_angle = drive_angle + body_turn_speed;
    
    String debug = String.Format("drive angle:%1f graphic: %d", drive_angle, oCar.Graphic);
    lblHotspot.TextCheckLBL(debug);
    
    if (body_angle > 360.0) body_angle -= 360.0;
    else if (body_angle < 0.0) body_angle += 360.0;
    if (drive_angle > 360.0) drive_angle -= 360.0;
    else if (drive_angle < 0.0) drive_angle += 360.0;
    
    Fdrag.x = -Cdrag * velocity.x * velocity.x * velocity.x;
    Fdrag.y = -Cdrag * velocity.y * velocity.y * velocity.y;
    Frr.x = -Crr * velocity.x;
    Frr.y = -Crr * velocity.y;
    F.x = Ftraction + Fdrag.x + Frr.x;
    F.y = Fside;// + Fdrag.y + Frr.y;
    acceleration.x = F.x / mass;
    acceleration.y = F.y / mass;
    velocity.x += acceleration.x * delta_time;
    
    if(velocity.y > 0.0)
    {
      velocity.y += acceleration.y * delta_time;
      if (velocity.y < 0.0) velocity.y = 0.0;
    }	
    else 
    {
      velocity.y += acceleration.y * delta_time;
      if (velocity.y > 0.0) velocity.y = 0.0;
    }	
    float cos_drive = Maths.Cos(Maths.DegreesToRadians(drive_angle));
    float sin_drive = Maths.Sin(Maths.DegreesToRadians(drive_angle));
    float cos_body = Maths.Cos(Maths.DegreesToRadians(body_angle));
    float sin_body = Maths.Sin(Maths.DegreesToRadians(body_angle));
    velocity_world.x = cos_drive * velocity.x - sin_drive * velocity.y;
    velocity_world.y = sin_drive * velocity.x + cos_drive * velocity.y;
    Region *reg[4];
    int i = 0;
    
    // move car a time-slice at a time and check for collisions
    #define time_slice 50
    while (i < time_slice)
    {
      // move car
      car.x += velocity_world.x * delta_time / time_slice.0;
      car.y += velocity_world.y * delta_time / time_slice.0;
      
      // calculate tire coordinates
      tires[0].x = car.x - cos_body * half_wheel_base - sin_body * half_rail_width;
      tires[0].y = car.y - sin_body * half_wheel_base + cos_body * half_rail_width;
      tires[1].x = car.x - cos_body * half_wheel_base + sin_body * half_rail_width;
      tires[1].y = car.y - sin_body * half_wheel_base - cos_body * half_rail_width;
      tires[2].x = car.x + cos_body * half_wheel_base - sin_body * half_rail_width;
      tires[2].y = car.y + sin_body * half_wheel_base + cos_body * half_rail_width;
      tires[3].x = car.x + cos_body * half_wheel_base + sin_body * half_rail_width;
      tires[3].y = car.y + sin_body * half_wheel_base - cos_body * half_rail_width;

     are = 0;
      bool hitwall = false;
      while are < 4)
      {
        if(!IsWalkable(FloatToInt(tires[r].x * scale, eRoundNearest), FloatToInt(tires[r].y * scale, eRoundNearest))) hitwall = true;
       are++;
      }	
      if (hitwall)
      {
        // get the regions we are on hit
        int regionID;
       are = 0;
        while are < 4)
        {
          reg[r] = Region.GetAtRoomXY(FloatToInt(tires[r].x * scale, eRoundNearest), FloatToInt(tires[r].y * scale, eRoundNearest));
          if(reg[r] == region[2] || reg[r] == region[3] || reg[r] == region[6] || reg[r] == region[7]) regionID = reg[r].ID;
         are++;
        }	
      
        // go back to where we didn't hit the wall
        car.x -= velocity_world.x * delta_time / time_slice.0;
        car.y -= velocity_world.y * delta_time / time_slice.0;
        moveToWalkable();
        
        // reverse appropriate velocity component
        // vertical wall
        if (wall_angles[regionID] == 90)
        {
          velocity_world.x = -velocity_world.x * fMax(fAbs(sin_drive), 0.5); //0.5
          velocity_world.y = velocity_world.y * fMax(fAbs(sin_drive), 0.5);
        }
        // horizontal wall
        else
        {
          velocity_world.x = velocity_world.x * fMax(fAbs(cos_drive), 0.5);
          velocity_world.y = -velocity_world.y * fMax(fAbs(cos_drive), 0.5);
        }	
        // get back the velocity in car coordinates
        velocity.x = cos_drive * velocity_world.x + sin_drive * velocity_world.y;
        velocity.y = -sin_drive * velocity_world.x + cos_drive * velocity_world.y;
        
        // move car
        car.x += velocity_world.x * delta_time / time_slice.0;
        car.y += velocity_world.y * delta_time / time_slice.0;
        
        // calculate tire coordinates
        tires[0].x = car.x - cos_body * half_wheel_base - sin_body * half_rail_width;
        tires[0].y = car.y - sin_body * half_wheel_base + cos_body * half_rail_width;
        tires[1].x = car.x - cos_body * half_wheel_base + sin_body * half_rail_width;
        tires[1].y = car.y - sin_body * half_wheel_base - cos_body * half_rail_width;
        tires[2].x = car.x + cos_body * half_wheel_base - sin_body * half_rail_width;
        tires[2].y = car.y + sin_body * half_wheel_base + cos_body * half_rail_width;
        tires[3].x = car.x + cos_body * half_wheel_base + sin_body * half_rail_width;
        tires[3].y = car.y + sin_body * half_wheel_base - cos_body * half_rail_width;
      }
      i++;
    }	

    // move car to the walkable area
    moveToWalkable();
    
    // move car sprite
    oCar.X = FloatToInt(car.x * scale, eRoundNearest) - half_sprite_size;
    oCar.Y = FloatToInt(car.y * scale, eRoundNearest) + half_sprite_size;
    player.x = oCar.X + half_sprite_size;
    player.y = oCar.Y - half_sprite_size;
    
    updateCarSprite();   
    
    // set viewport scrolling
    wanted_screenoffset.x = cos_drive * (velocity.x * 1.5);
    wanted_screenoffset.y = sin_drive * (velocity.x * 1.5);
    
    if (wanted_screenoffset.x > screenoffset.x)
    {
      screenoffset.x += screenoffset_step;
      if (wanted_screenoffset.x < screenoffset.x) screenoffset.x = wanted_screenoffset.x;
    }
    else if (wanted_screenoffset.x < screenoffset.x)
    {
      screenoffset.x -= screenoffset_step;
      if (wanted_screenoffset.x > screenoffset.x) screenoffset.x = wanted_screenoffset.x;
    }
    if (wanted_screenoffset.y > screenoffset.y)
    {
      screenoffset.y += screenoffset_step;
      if(wanted_screenoffset.y < screenoffset.y) screenoffset.y = wanted_screenoffset.y;
    }
    else if (wanted_screenoffset.y < screenoffset.y)
    {
      screenoffset.y -= screenoffset_step;
      if(wanted_screenoffset.y > screenoffset.y) screenoffset.y = wanted_screenoffset.y;
    }
    SetViewport(oCar.X - half_screen_width + half_sprite_size + FloatToInt(screenoffset.x, eRoundNearest), oCar.Y - half_screen_height - half_sprite_size + FloatToInt(screenoffset.y, eRoundNearest));

    // calculate engine rpm
    int rpm = FloatToInt(fAbs(velocity.x) * 120.0);
    if (rpm > 5000) rpm = 5000;
    else if (rpm < 0) rpm = 0;
    rpm += 1000;

    //String infotext = String.Format("%dmph[%drpm", FloatToInt(velocity.x * 3600.0 / 1000.0), rpm);
    //lblHotspot.TextCheckLBL(infotext);
  }
}


Here is what I was hoping of achieving with the key presses...most of which Ive been able to achieve:

--LEFT/RIGHT ARROW:
a) While car is immobile, can orient the car's angle
b) While car is in forward movement and not in an intersection region, strafe the car left or right (blocking animation lane change)
c) While car is in reverse and not in an intersection region, these key presses do nothing
d) While car is in movement and over an intersection region, turn the car left or right (blocking animation to turn car on the proper street)

--UP ARROW:
a) While car is immobile, will start the car moving forward
b) While car is moving forward, can press the up arrow 3 more times to switch gears (4 speed modes)
c) While car is moving backwards, each press will decrease the car's reverse speed until full stop

--DOWN ARROW:
a) While car is immobile, will start the car moving backward
b) While car is moving backwards, press down again wont do anything
c) While car is moving forwards, each press will decrease the car's forward speed until full stop

Where I am stuck right now is Im having problems with these issues:

a) Currently when I press the down arrow while the car is moving forward, the car will immediatly go into reverse...it wont stop first. Id like it to come to a full stop if  the car is moving at the lowest speed mode. If the player then presses the down key once again while the car is fully stopped, THEN it will go into reverse.
b) I have no idea about the math involved to how to make the car "strafe" from left to right or right to left like if it was doing a lane change while it is moving forward.

Here is an example of how Id like the car to make a lane change:

#238
The best advice I can give is before posting a question, take an extra 10 minutes to search yourself...if after that your really really still cant find the solution, then ask away! Eventually you will have less questions as you gain experience and try problem solving yourself.

In the beginning I asked a gazillion questions, and luckily I found out farily early on that its sometimes better try yourself first...best way to learn imo. Sometimes I even had my post all written up, and before clicking the "post" button I just had an idea, tried it out and well, it worked...its tempting to ask for the solution instead of working a bit yourself on it first.

If that doesnt work, well you can always offer to pay Khris for his help...like I do hehee!
#239
Cool! Gonna test that out now :)


Pardon my ignorance, but what are some of the things one can do with "textures" within AGS?
#240
Awesome! Thnx Wyz!

Ok, Im going to try that thursday as soon as I can  :=

Ive gotten part of what I wanted, snapping at 30° intervals on the keyboard, I need to change the angle of my grid, it wasnt exactly 30° + tweeked the taxi module.

Ill post it all this weekend for sure...I hope the walkbehinds aren't too hard to do in an iso map :P
SMF spam blocked by CleanTalk