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

Topics - Knox

#21
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?)

#22
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

#23
Hi,

I am slowly starting to put a driving module into my game. I was wondering how to solve this certain problem.

Right now, when I click my cursor (walk) to drive the player around (car sprite), even if I have the sprite setup OK (up, down, left, right, diagonal down-left, diagonal down-right, diagonal up-right, diagonal up-left)...if I click, for example, up-left of the car to move it diagonal up-left. it will move up-left but it will display the "left" sprite...its not locked to the "diagonal up-left" sprite, know what I mean?

Also, how could one go about scripting this: say the mouse hovers over an intersection and you can go left or right...the mouse will change cursors when it is over that certain area where you can turn, then when you click on the mouse, the car will turn at the right spot. If you dont click anywhere, the car will just continue its present course.

(For example, say I click at a 4-way intersection and the car can continue up, turn left or right...if your mouse is over the intersection but hovering more to the left, the cursor changes to a left turn-arrow, if its more to the right, turn-right arrow, and if your mouse hovers above the intersection, just display up arrow.)

I looked at the Taxi Demo source, and its pretty cool, I  got it to work and everything, but I feel for this kind of game I dont want the car to be "free" to drive at any angle, nor do I need an physics other than hit-detection on other cars, like in Police Quest 1 ega (check out the youtube video). I just want the car movements  to be locked to the 8 directions only, and the player can use the keyboard or the mouse to move it around.
http://www.youtube.com/watch?v=D7Mcdbg8LqI

As you know Im not particularly gifted in scripting, although I can hack my way through, so any help is really appreciated!!
#24
Hi,

Ive got a question on room backgrounds. I know we can have room background images larger than our game resolution, but has anyone tested the limits if this?

Say I want to use a room for a very large map that you can scroll...How big a map could one use for a 1024x768 game until it gets "laggy"...or does that not depend on background size but more on number of objects/characters.animations, etc...

Would it be "better/faster" to use 1 room and 1 large background, or break it up into smaller backgrounds and use multiple rooms?
#25
How can I simplify this code? I remember (I think) someone posting a simple way of expressing "if something is A, than make it B, if its B, make it A".

Code: ags
  if (btnCitation_Magnifier.NormalGraphic == 3289) btnCitation_Magnifier.NormalGraphic = 3291;
  else btnCitation_Magnifier.NormalGraphic = 3289;
#26
Is there a way to increase the sprite cache limit? Right now the max is 100mb...it would be nice to put a higher value!

What do you guys think? Can it be done?
#27
I looked in the manual and I didnt seem to find anything that could permit me to open a folder on the user's system.

In melScript, there is a command "system ("explorer "...blah)  where from within maya you can open folders with explorer by scripting.

Would there be a way to do this with AGS? It would be so that when a screenshot is saved, the savegame folder gets opened.      
#28
Hi,

I wrote a script where I can set different mouse bounderies depending on if certain gui's/menus are visible. It works, only I believe there is a nicer way to do it so that its compact, and non-redundant.

Also, everytime I add a new enum "eType" (because Im still not sure how many I need since Im still designing), I have to manually add new lines each time into the script, and create new global variables. Is there a way  to do this so that the script scans the enum list (which is going to grow with time as I work on the game), creates a global variable for each new addition, and then runs the script so everything works? (If not, atleast, how to do it so the script isnt redundant and shortest possible.)

Code: ags

//.ash
enum eGameBoundsType 
{
  eGamePlayBounds, 
  eMenuBounds, 
  eMagnifierBounds,
};



Code: ags

//.asc
bool bGamePlayBoundsSet = false;
bool bMenuBoundsSet = false;
bool bMagnifierBoundsSet = false;

void setMouseBounds(eGameBoundsType eType)
{
    if (eType == eGamePlayBounds)
    {
      if (!bGamePlayBoundsSet)
      {
        Display("eType == eGamePlayBounds...");
        mouse.SetBounds(7, 53, 1000, 700); //Lft Top Rght Btm
        bGamePlayBoundsSet = true;
        //set all other bools to false...
        bMenuBoundsSet = false;
        bMagnifierBoundsSet = false; 
      }
    }
    else if (eType == eMenuBounds)
    {
      if (!bMenuBoundsSet)
      {
        Display("eType == eMenuBounds...");
        mouse.SetBounds(7, 53, 990, 700); //Lft Top Rght Btm
        bMenuBoundsSet = true;
        //set all other bools to false...
        bGamePlayBoundsSet = false; 
        bMagnifierBoundsSet = false; 
      }
    }
    else if (eType == eMagnifierBounds)
    {
      if (!bMagnifierBoundsSet)
      {
        Display("eType == eMenuBounds...");
        mouse.SetBounds(99, 99, 1000, 700); //Lft Top Rght Btm 
        bMagnifierBoundsSet = true;
        //set all other bools to false...
        bGamePlayBoundsSet = false; 
        bMenuBoundsSet = false;
      }
    }
}


Thanks!  :)
#29
Hi,

I based this script on what Khris suggested in this thread: http://www.adventuregamestudio.co.uk/yabb/index.php?topic=43755.0

Code: ags

function repeatedly_execute_always() 
{
  GUIControl*gc = GUIControl.GetAtScreenXY(mouse.x, mouse.y);
  if (gc == bTest) 
  {
    if (!bRollOverBtnAnim) 
    {
      bTest.Animate(VCRL_ROLLOVERS, 0, 1, eOnce);
      bRollOverBtnAnim = true;
    }
  }
  else if (gc != bTest)
  {
    bTest.Animate(VCRL_ROLLOVERS, 1, 1, eOnce);  // this animation doesnt play at all when the mouse leaves the button
    if (bTest.NormalGraphic != 2752) bTest.NormalGraphic = 2752;
    bRollOverBtnAnim = false; 
  }  
}


What Im trying to do is when the mouse is over a certain button, it plays an animation once. As soon as it leaves the button (no longer over it), it plays another animation, then returns to its normal graphic.

The 1st animation plays OK, but when my mouse is no longer on the button, that 2nd animation doesnt play at all.

What did I do wrong?
#30
I found a relatively old thread about pre-loading sprites into memory: http://www.adventuregamestudio.co.uk/yabb/index.php?topic=39487.0

I was wondering, how can I pre-load all the game sprites efficiently the moment the player presses either the "start new game" or "continue game" button from the main menu?

GarageGothic suggests in the thread posted above:
QuoteYou could play the animation on an invisible object first, then the sprites should be preloaded in memory for when you actually need them.  

Is this a good way to do it? Or is there a better way? I have some very heavy animations for some full-screen effects (1024x768) and the firt time around, those animations lag...but once they've been played once + loaded, they run quite smoothly.

I'd add a  "loading bar" aswell to show the progress of each sprite/animation views being loaded into memory...so that way the player only needs to load everything once, at the beginning.

Im sure its doable, only Im not too sure how, or the best way to load them without the player seeing anything. I think* I can figure out the loading bar myself though...we'll see!
:P
#31
I started this thread a while ago but pretty much got my answers myself screwing around and what not: http://www.adventuregamestudio.co.uk/yabb/index.php?PHPSESSID=6ve262cd3e75q7svke88rgrs74&topic=43454.0

However, I ran into a problem:

Im not sure why but it seems that when I draw onto a gui with my "pen", the line is totally opaque (I cant see the semi-transparent "edge" of the "pen-dot" sprite to make the line look anti-aliased).

I tried a 2nd way by using a different script that I modified a bit (still contains bugs/errors), but its much closer to the effect Im searching for.

Here are the videos...how can I get Mode 1 (using a sprite + Wyz's BrushLine code) to match the second's anti-aliased look (Kweepa's DrawAntialiased v1.1: http://www.adventuregamestudio.co.uk/yabb/index.php?topic=39846.0)

Mode 1: http://www.youtube.com/watch?v=Wo0HpJN9f78

Mode 2: http://www.youtube.com/watch?v=IklxVuY06gg



SCRIPT:
Code: ags

DynamicSprite *dsWriteOnSurface;
DrawingSurface *DrawSurface;
Overlay *ovPen;
int iPenColor;
int iTrans = 0;

function BrushLine(this DrawingSurface*, int x1, int y1, int x2, int y2, int slot, float spread)
{
  x1 -= Game.SpriteWidth[slot] / 2;
  y1 -= Game.SpriteHeight[slot];
  x2 -= Game.SpriteWidth[slot] / 2;
  y2 -= Game.SpriteHeight[slot];
  
  float dx = IntToFloat(x2 - x1);
  float dy = IntToFloat(y2 - y1);
  
  float interval = Maths.Sqrt(dx*dx + dy*dy);
  interval = interval / (IntToFloat(Game.SpriteWidth[slot] + Game.SpriteHeight[slot]) / (spread * 2.0));
  
  if (interval < 1.0)
    interval = 1.0;
  
  float i = 0.0;
  float xoffset = dx / interval;
  float yoffset = dy / interval;
  float xx = IntToFloat(x1);
  float yy = IntToFloat(y1);
  
  while (i < interval)
  {
    this.DrawImage(FloatToInt(xx), FloatToInt(yy), slot, iTrans);
    xx += xoffset;
    yy += yoffset;
    i++;
  }
}

void DynamicDraw(this Button*, int iMode)
{
  if (iMode == 1) //Draw BrushLine with Sprite ON GUI
  {
    if (bIsDrawing == true) 
    {
      if (Mouse.IsButtonDown(eMouseLeft) == true) 
      {
        iPenColor = 2720; //Black pen Small

        dsWriteOnSurface = DynamicSprite.CreateFromExistingSprite(this.NormalGraphic);
        DrawSurface = dsWriteOnSurface.GetDrawingSurface();			
        DrawSurface.BrushLine(mouse.x-iGuiX, mouse.y-iGuiY, iPrevX-iGuiX, iPrevY-  iGuiY, iPenColor, 20.0);
					
        //Anti-Aliased:	
        //int iX = mouse.x-iGuiX;
        //float fX = IntToFloat(iX);
        //int iY = mouse.y-iGuiY;
        //float fY = IntToFloat(iY);
        //int iX2 = iPrevX-iGuiX;
        //fPrevX = IntToFloat(iX2);
        //int iY2 = iPrevY-iGuiY;
        //fPrevY = IntToFloat(iY2);
        //DrawAntialiasedLine(DrawSurface, fX, fY, fPrevX, fPrevY, 0);
							
        this.NormalGraphic = dsWriteOnSurface.Graphic;
        iPrevX = mouse.x;
        iPrevY = mouse.y;
        //fPrevX = IntToFloat(iPrevX);
        //fPrevY = IntToFloat(iPrevY);			
      }
      else bIsDrawing = false;
    }
  }  
}

void on_event (EventType event, int data)
{
 if (oTg == gTicketBook_Cit)
 {
  bIsDrawing = true;
  iPrevX = mouse.x;
  iPrevY = mouse.y;  
  //fPrevX = IntToFloat(iPrevX);
  //fPrevY = IntToFloat(iPrevY);    
  return;
 }
 else 
 {
  if (bIsDrawing == true) bIsDrawing = false;
 }	
}

function repeatedly_execute() 
{ 
  if (gTicketBook_Cit.Visible && mouse.GetModeGraphic(eModePointer) == 3901)
  {
    iGuiX=484;
    iGuiY=152;
    btnCitation.DynamicDraw(1);
  }
}
#32
Im just trying to do a basic pencil function for free-hand drawing with AGS. I looked here for code snippets:

http://www.adventuregamestudio.co.uk/yabb/index.php?topic=41620.0
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=39846.0


Code: ags

  if (bIsDrawing == true) 
  {
    if (Mouse.IsButtonDown(eMouseLeft) == true) 
    {
      DrawingSurface *DrawSurface = Room.GetDrawingSurfaceForBackground();
  
      float fMouseX = IntToFloat(mouse.x);
      float fMouseY = IntToFloat(mouse.y);
      DrawAntialiasedLine(DrawSurface, fMouseX, fMouseY, fMouseX*1.2, fMouseY*1.2, 0); <--what do I put here for smooth lines?

      DrawSurface.Release();
    }
    else bIsDrawing = false;
  }



To make the mouse draw a nice anti-aliased line smoothly with hand gestures to simulate a pencil is what Im going for. Im almost there, but I think Im getting the math wrong for the second "x" and "y" values...(I tried varations without luck because I dont understand what Im doing there...just pluggin arbitrary operators to see what happens.)
#33
I was wondering if it is possible to "merge" these 2 funtions into one so that the same function can treat gui's, buttons, labels, lists, textboxes, etc...something like:

pseudo code:
Quotevoid Chk_Hide(this GUI* || this Button* || this Label*, etc...)

Quote
//instead of using a separate function for each type (button, gui, etc), it would be cool that a list of possible types can be treated with 1 function.
void ChkGui_Hide(this GUI*)
{
 if (this.Visible) this.Visible = false;
}

void ChkBtn_Hide(this Button*)
{
 if (this.Visible) this.Visible = false;
}

*ps: The inside of the brackets above after the function name are called parameters, right? What's an extender again? :P
#34
If I click on a menu button, the button's sprite changes to the "pressed" sprite, like normal. However, I wrote a script that wont let the user hold down a button forever; after 20 game loops, Id like to "release" the button press, even if the mouse button is physically still held down by the player.

At the end of the while loop (when 20 loops are up), how can I manually release the mouse button (even if the player's finger is still holding down on it)...Im trying to force "mouse.IsButtonDown(eMouseLeft)"  to false myself, but I'm guessing its read-only?

If not, I guess at the end of the loop I could manually change the pressed button's graphic back to the normal graphic, but Id rather avoid that if possible...
#35
Code: ags

function btnQuickGuide_PrevPg_OnClick(GUIControl *control, MouseButton button, int iMode)
{
  if (iMode == 0)...stuff;
  else ...stuff;
}


There's no problem using the above code when I call the _OnClick manually (via a key press, for example), but when I click the actual button that has this code, how do I set iMode? Where should it be placed?

Code: ags

Called from inside a key press: btnQuickGuide_PrevPg_OnClick(btnQuickGuideVC_PrevPg, eMouseLeft, 1);


When a key is pressed, that function will always be mode 1, if the button of the gui is clicked on, it will always be mode 0.

(*I guess I could make 2 separate functions, one for the key press, one for the click, but Id rather not duplicate code).
#36
Hi,

Ive gotten this far, but its not very elegant, nor compact...plus I think I made a mistake in my logic somewhere because it doesnt work 100% like Im envisioning.

Basically what Im doing is I have 3 guide booklets that are gui's. The zorders are initialized as:
QuickGuide_VC.ZOrder = 10;
QuickGuide_PC.ZOrder = 9;
QuickGuide_SS.ZOrder = 8;

I dont want the ZOrders to ever be anything different than 8, 9 or 10. The highest is always 10, the lowest, always 8.

When you click on any of the gui's, that gui's zorder will become 10, the others, depending on their order amongst themselves, will get their zorder knocked down so that its logical.

Here is what I have, where could my error be (Ive attempted debugging without luck so far) and more important, how to make this shorter/more elegant?
Code: ags

  if (mouse.IsButtonDown(eMouseLeft) && gQuickGuidesGUI.Visible)
  {
    if (overGUI == gQuickGuidePC)
    {
      iPCz = gQuickGuidePC.ZOrder;
      if (iPCz != 10)
      {
        gQuickGuidePC.ZOrder = 10;
        iVCz = gQuickGuideVC.ZOrder;  
        iSSz = gQuickGuideSS.ZOrder;
        if (iVCz == 10) gQuickGuideVC.ZOrder = 9;
        else if (iVCz == 9) gQuickGuideVC.ZOrder = 8;
        else if (iSSz == 10) gQuickGuideSS.ZOrder = 9;
        else if (iSSz == 9) gQuickGuideSS.ZOrder = 8;       
      }
    }
    else if (overGUI == gQuickGuideVC)
    {
      iVCz = gQuickGuideVC.ZOrder;
      if (iVCz != 10)
      {
        gQuickGuideVC.ZOrder = 10;
        iPCz = gQuickGuidePC.ZOrder;  
        iSSz = gQuickGuideSS.ZOrder;
        if (iPCz == 10) gQuickGuidePC.ZOrder = 9;
        else if (iPCz == 9) gQuickGuidePC.ZOrder = 8;
        else if (iSSz == 10) gQuickGuideSS.ZOrder = 9;
        else if (iSSz == 9) gQuickGuideSS.ZOrder = 8;       
      }       
    }
    else if (overGUI == gQuickGuideSS)
    {
      iSSz = gQuickGuideSS.ZOrder;
      if (iSSz != 10)
      {
        gQuickGuideSS.ZOrder = 10;
        iVCz = gQuickGuideVC.ZOrder;  
        iPCz = gQuickGuidePC.ZOrder;
        if (iVCz == 10) gQuickGuideVC.ZOrder = 9;
        else if (iVCz == 9) gQuickGuideVC.ZOrder = 8;
        else if (iPCz == 10) gQuickGuidePC.ZOrder = 9;
        else if (iPCz == 9) gQuickGuidePC.ZOrder = 8;       
      }       
    }
  }
#37
Hi,

Im running into a problem mostly due to my newbie-ness: Ive got a while loop using the number of inventory items in a certain "myInventoryWindow" window. Inside this loop, I run a script that does stuff + and eventually decides (depending on various factors) if that item "i" should be deleted from myInventoryWindow.

The problem is, if I delete an item in that window from inside the while loop, how in the crap am I supposed to update "iMyItemCount" so that it diminishes its amount?

Im guessing I have to use a dynamic array?

Code: ags

//Pseudo code:

  iMyItemCount = myInventoryWindow.ItemCount;
  int i = 0;
  while (i < iMyItemCount) 
  {
        functionThatDeletesItemFromInvWindow(); //processes 1 item at a time, to see if it must be deleted
        i++;
  } 
#38
Hi,

I was wondering if this is possible in AGS...and what can I do to get there?

Instead of giving the option of having the game fullscreen (resize/stretch), Id rather "fullscreen" mode means (for my game) that  the screensize of the game stays at 100% of its resolution, but that the background behind the game gets filled completly in black...

So basically it looks exactly like windowed mode, only you no longer see your desktop.

(The main reason I ask this is because I find fullscreen the mouse doesnt work very well and no solution seems to be in the works, and Im not a fan of the black borders nor blowing up pixels...)
#39
If you look at the third block of code,  Ive got a line "if (aVariableArray[j].GetProperty("CustomPropertyA") == false)".

Im always getting an error with the "aVariableArray[j]" line in the 3rd block...mainly because I dont understand how to
use an certain array depending on another value (does that make sense?);

Im trying to get "aVariableArray" to be set to either aArrayA[] or aArrayB[], depending on which of these is called: iUseItemA or iUseItemsB.

Code: ags

//(in .ash):
#define SL_A_ITEMS 6
import InventoryItem* aArrayA[SL_A_ITEMS];

#define SL_B_ITEMS 6
import InventoryItem* aArrayB[SL_B_ITEMS];


Code: ags

//(in .asc):
InventoryItem* aArrayA[SL_A_ITEMS];
InventoryItem* aArrayB[SL_B_ITEMS];

void ItemLists()
{
  aArrayA[0] = iMic; aArrayA[1] = iRadio; aArrayA[2] = iBattery; aArrayA[3] = iKeysA; aArrayA[4] = iGun; aArrayA[5] = iPatrolClip;
  aArrayB[0] = iSpray; aArrayB[1] = iMints; aArrayB[2] = iMeds; aArrayB[3] = iShield; aArrayB[4] = iMask; aArrayB[5] = iSanitizer;
}


Code: ags
 
//in some function:
{
  if (this == iUseItemsA) aVariableArray[j] = aArrayA[];
  else if (this == iUseItemsB) aVariableArray[j] = aArrayB[];
  
  if (bEx == false)
  {  
    j = 0;
    while (j < iConstantNum)
    {
      if (aVariableArray[j].GetProperty("CustomPropertyA") == false)
      {
      ...blah etc...


If I did it "straight-up" without that variable, I would just do this and it works (but its not what I want cause I dont want to write all that code twice, or more, depending on how many arrays I might create in the future):

Code: ags

//pseudo code **EDIT**
    while (j < iConstantNum)
    {
      if (blah)
      {
        if (aArrayA[j].GetProperty("CustomPropertyA") == false)
        {
          ...stuff
        }
      }
    }
      
      
    OR:
      
    while (j < iConstantNum)
    {
       if (blah)
       {
         if (aArrayB[j].GetProperty("CustomPropertyB") == false)
         {
           ...stuff
         }
       }
    }
#40
Ive tested this multiple times on my computer to be sure it wasn't a fluke...if its isnt, well I hope it can be fixed for the next release :)

My game (up until I accidently discovered this possible bug) has been running at about 60 fps. I started Windows Media Player with an audio cd, pressed "stop" and minimized it. I then pressed F5 to run my game. The FPS is now 100 fps!! A gain of 40 fps, incredible...
I then closed Windows Media Player and the game. I pressed F5 again, and this time the FPS has returned to 60. So if the WMP is opened, my game runs 40 fps faster...


-Windows 7, x64
-Windows Media Player (version 12.0.7600.16415)
-Direct3D9 mode
-No graphics filter
-Side Borders On
-Smooth Scaled Sprites On
-Run the game windowed

Can anyone else reproduce this?

**EDIT: I tested this with VLC Media player aswell (version 1.1.7 x32) and I got the same results...
ps: (oh, and of course, if this bug could be fixed so that even without a player running the game still runs at 100fps :P)
SMF spam blocked by CleanTalk