Need to workaround Screen coords, need Room coords instead. [SOLVED]

Started by Trent R, Tue 11/11/2008 07:58:34

Previous topic - Next topic

Trent R

GAAHHH!! I've been working for the last few hours on my overhead battle system. To make movement cleaner, and to be able to detect objects and characters, I wrote the following function. It's not finished, but I'm just worrying about the movement part (ie. Hspot parameter is not used yet)

Code: ags

function ChangeHex (Character* Char, FacingEnum param, Hotspot* Hspot){
  int CFx, CFy;
  if (param==eFaceDL)       {CFx=Char.x-88; CFy=Char.y+50; } //These distances are specific to the grid
  else if (param==eFaceDown){CFx=Char.x;    CFy=Char.y+100;} //High-res coords are used in scripts
  else if (param==eFaceDR)  {CFx=Char.x+88; CFy=Char.y+50; }
  else if (param==eFaceUL)  {CFx=Char.x-88; CFy=Char.y-50; }
  else if (param==eFaceUp)  {CFx=Char.x;    CFy=Char.y-100;}
  else if (param==eFaceUR)  {CFx=Char.x+88; CFy=Char.y-50; }

  //Char.Walk(CFx, CFy, eBlock); //Works fine, but wouldn't allow the checking I wish to implement

  if (Char==player) BattleHot=Hotspot.GetAtScreenXY(player.x, player.y); //BattleHot is to be the hotspot where the player is
  Char.Walk(BattleHot.WalkToX, BattleHot.WalkToY, eBlock, eAnywhere);    //Obviously doesn't work 
}



This image is my map, and each colored hex has a hotspot associated with it. I had hoped that I could find which hotspot is directly in the direction of FacingEnum, and then check whether or not an enemy or object was at that hotspot.

But since this is a vertical scrolling room, GetAtScreenXY screws up if the player is down at all..... Can anyone of you help me to find a workaround to fix this? Or even to scrap my hotspot idea?


~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

Gilbert

if (Char==player) BattleHot=Hotspot.GetAtScreenXY(player.x-GetViewportX(), player.y-GetViewportY()); //BattleHot is to be the hotspot where the player is

Of course, if the room won't scroll horizontally you can leave out the GetViewportX() part, but it doesn't hurt having it.

Trent R

This is happenining more and more to me. I work on something for hours, and get driven to the point where I have no idea what to do, and post it on the forums. And then it's something extremely simple.

Thank you Gilbot!


~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune

SMF spam blocked by CleanTalk