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 - suicidal pencil

#81
Quote from: rocko775 on Thu 11/02/2010 21:16:38
...can you get him to do more spots than two, like a square...?

Anything is possible :P

Code: ags

function room_RepExec()
{
  if(!cGuard.Moving)
  {
    if((cGuard.x == 100) && (cGuard.y == 100)) cGuard.Walk(100, 400);
    if((cGuard.x == 100) && (cGuard.y == 400)) cGuard.Walk(400, 400);
    if((cGuard.x == 400) && (cGuard.y == 400)) cGuard.Walk(400, 100);
    if((cGuard.x == 400) && (cGuard.y == 100)) cGuard.Walk(100, 100);
  }
}


a brief little code snippet on your guard walking in a counter-clockwise rotation in a square with 300-pixel sides
#82
Quote from: Ponch on Mon 05/01/2009 19:48:07
Quote from: dkh on Mon 05/01/2009 19:09:42
when it's done!

Hey now! Watch it with that Duke Nukem Forever talk, buddy. I was starting to get my hopes up about this plugin. ;)

- Ponch

I was too (especially the look at the source :P), but then the topic started to get ignored...

I hope you're still working on it, this is an epic plugin, definitely one to keep around :D
#83
Quote from: Khris on Wed 27/01/2010 18:16:27
Well, my guess is that you've declared the arrays in the header, thus creating a separate array for every script.
Is the game_start function containing the line the module's or the global script's?

The arrays are defined in the script as well with game_start(), not header. I may be wrong, but doesn't ags get annoyed by that? nvm, forgot about export :P
#84
Quote from: Khris on Tue 26/01/2010 14:04:36
Where are you defining the arrays?
Are the other lines in game_start() called?

Everything is in a separate module, with only one function being called from the global script, everything else is handled by the module. There is only one other line in the game_start(), it's PlayMusic(). It works fine.

And it was only a quick fix :P
#85
Quote from: Khris on Tue 26/01/2010 13:15:15

Regarding the problem: I've never used .IsCollidingWithObject myself, but maybe the check requires both objects to be solid and/or clickable?

Use Display lines to find out whether
  if(object[object1].IsCollidingWithObject(object[object2]))
or
  if(ObjectSettings[object1] == 6)
doesn't return true for object1 == 0.

Both are solid/clickable, I've even tried messing with blocking heights and width.

I have used Display to figure out what the code is actually doing, and I've found that the collision script is working for the player (collision detected between object 0, and whatever the bullet was (in this case, 3))...but if(ObjectSettings[object1] == 6) //player is returning false. After more testing, it turns out that the player object as represented in the ObjectSettings array is not 6, but 0. In the function Game_Start(), I have this line: ObjectSettings[0] = 6;, but it did not work. Only putting that line in the repeatedly_execute_always() function did it start working again

Thanks for the help :)
#86
Quote from: ProgZmax on Tue 26/01/2010 02:52:24
Have you tried it without this line:

Code: ags
 object2 = object1+1; //so I'm not checking collisions twice


Because it's effectively making the second while loop go from 1-39 instead of 0-39 as the first loop does.

That's supposed to be there, and I have tried it without. When it's gone, the entire function stops working.

Basically, that's there so that I'm not checking if an object is colliding with itself, and to make sure I don't check collisions twice. I'm fairly certain that this is not the issue, seeing as object1 begins pointing at the player anyways when the function is first called

edit: Plus, it takes out a large amount of processing. If it was not there, the function would loop 1640 times, but with it, it only loops 840 :P (object1 increments 1 for every 40th increment of object2, and the second loop would run 1600 times without that one line, and only 800 times with. That's half the steps. (including the first loop, add 40))
#87
For one of my games, I needed to hack together an object collision system..and I did. It works, but with the exception of one case.

Working along side the normal object array, I have a second one, which tracks what type of object it is (player, turret, bullet, etc.). It works fine with the turrets and the bullets...but not the player. The element positions in both arrays are one in the same, (array1[element] == array2[element]), to make it easy to track objects. The player object is element 0 in the object array and the settings array, and the value in the settings array is 6, for the player. A setting of 1 is a turret, 3 is a bullet fired from the player, etc.). Any case involving the player object fails, and every other works.

Here's the code:
Code: ags

function ObjectCollisions()
{
  int object1 = 0;
  int object2 = 0;
  while(object1 <= 39)
  {
    object2 = object1+1; //so I'm not checking collisions twice
    while(object2 <= 39)
    {
      if(object[object1].IsCollidingWithObject(object[object2])) //collision detected
      {
        if(ObjectSettings[object1] == 6) //player
        {
          if(ObjectSettings[object2] == 4) //enemy bullet
          {
            DoDamage(object1, 1);
            ReleaseObject(object2);
          }
        }
        else if(ObjectSettings[object1] == 3) //player bullet
        {
          if(ObjectSettings[object2] == 1) //turret
          {
            DoDamage(object2, 1);
            ReleaseObject(object1);
          }
        }
        else if(ObjectSettings[object1] == 1) //turret
        {
          if(ObjectSettings[object2] == 3) //player bullet
          {
            DoDamage(object1, 1);
            ReleaseObject(object2);
          }
        }
        else if(ObjectSettings[object1] == 4) //enemy bullet
        {
          if(ObjectSettings[object2] == 6) //player
          {
            DoDamage(object2, 1);
            ReleaseObject(object1);
          }
        }
      }
      object2++;
    }
  object1++;
  }
  return 0;
}


The code for collisions for the player, the turrets, and the bullets are identical, yet it fails on one very specific case.

Any thoughts?
#88
Quote from: Khris on Thu 21/01/2010 09:01:32
(Character's are displayed centered at their x coordinate while the object sprite's width is 10.)

While not what was being looked for, you still helped me out. Characters aren't actually used in my game, everything is done with objects. In the code, I'm moving the bullet objects to the unused player character, instead of the object representing the player.

what the problem is:
Code: ags

object[FreeObject].X = player.x+51;
object[FreeObject].Y = player.y+173;


and the solution
Code: ags

object[FreeObject].X = object[0].X+51;
object[FreeObject].Y = object[0].Y+173;


Thanks for the help! ;D (oh, and as it turns out, the top-center of the object is (51, -173). Thanks Tim
#89
Quote from: monkey_05_06 on Thu 21/01/2010 00:17:07
When you say it's not doing anything...what exactly does that mean?

Have you tried displaying the value of FreeObject? Try displaying various different values of your variables and see what's happening. You know the function is being called...but maybe one or more of those values isn't what you're expecting it to be...?

I checked the values at run time (FreeObject and object[FreeObject].Graphic), and they both have values that are exactly what I expected. FreeObject starts at 1 (because object 0 is already in use), and every time the function is called, the number increases by one until it hits the limit (25). The graphic is changing to the correct sprite, but the sprite does not appear.

So, the function is working correctly, but the object is not being displayed properly.

oh, and here's the sprite being used:
#90
In one of my latest endeavors, I'm using objects as bullets. When a certain function is called, it should get a free object, set it's position to the top-center of the player, and change it's graphic. When the function is called, however, nothing happens. I put a 'Display()' just before the return statement at the end of the function, and it displayed, so it's running through the function, but it's not doing anything else other than that.

here's the offending function
Code: ags

function SetUpPlayerBullet()
{
  if(TotalBullets == 25) return 1; //need to see if the onscreen bullet cap was hit
  int FreeObject = GetUnusedObject();
  ObjectSettings[FreeObject] = 3;
  object[FreeObject].X = player.x+51;
  object[FreeObject].Y = player.y+173;
  object[FreeObject].Graphic = 11;
  BulletDirection[FreeObject] = 0;
  TotalBullets++;
  return 0;
}


and here's how I'm finding the next available object, the function being called on the 4th line.

Code: ags

function GetUnusedObject()
{
  int counter = 0;
  while(counter <= 39)
  {
    if(object[counter].Graphic == 0) return counter;
    else counter++;
  }
}


This has worked for me in the past for previous games...but not now for some odd reason  :-\
#91
here, try this. I did a little testing, and it should work

Code: ags

InventoryItem* Armor;
InventoryItem* Weapon;

function RemoveArmor()
{
  if(Inventory_Armor.Graphic != g_70x70_ButtonTran)//this obscure variable is just pointing to the sprite I used for transparency
  {
    Inventory_Armor.NormalGraphic = g_70x70_ButtonTran;
    Inventory_Armor.Text = String.Format("Armor");
    player.AddInventory(Armor);
    DefenseModifier = 0;
    Armor = null;
    return 0;
  }
}

function RemoveWeapon()
{
  if(Inventory_Weapon.Graphic != g_70x70_ButtonTran)
  {
    Inventory_Weapon.NormalGraphic = g_70x70_ButtonTran;
    Inventory_Weapon.Text = String.Format("Weapon");
    player.AddInventory(Weapon);
    AttackModifier = 0;
    Weapon = null;
    return 0;
  }
}

function SetArmor(int DefenseValue, InventoryItem* ItemName)
{
  if(Armor != null) RemoveArmor(); //if the slot is already taken, remove it! :)
  DefenseModifier = DefenseValue;
  Armor = ItemName; //Just so I have a reference to the inventory item
  Inventory_Armor.NormalGraphic = ItemName.Graphic;
  Inventory_Armor.Text = String.Format(""); //remove the label text
  player.LoseInventory(ItemName);
  return 0;
}

function SetWeapon(int AttackValue, InventoryItem* ItemName)
{
  if(Weapon != null) RemoveWeapon();
  AttackModifier = AttackValue;
  Weapon = ItemName;
  Inventory_Weapon.NormalGraphic = ItemName.Graphic;
  Inventory_Weapon.Text = String.Format("");
  player.LoseInventory(ItemName);
  return 0;
}

#92
The question I must ask is: NFA or DFA regex engine?

My only concern is that Regexes can be VERY hard to learn, and get used to. There is a reason why there are books written about the damn things  :-\
#93
I wasn't aware that the object array was global. That actually makes everything much easier now. Thanks!

#94
I think that the new version of AGS should have no limit cap on the number of objects allowed in a room  :P
#95
Is there a way to mess around with objects outside their room? Some of the games I currently have on the burner have an extreme amount of use and abuse of objects, and I'd like to make a module for the plethora of functions that have been made for these games, but I'm not completely sure this is possible.
#96
try downloading and reinstalling AGS.

...could the install be corrupted?
#97
*smacks head*

I never knew that the arcsine was the inverse sine >_<

thanks!
#98
make a GUI label, name it accordingly, and every cycle, update it

Code: ags

function repeatedly_execute() 
{
  GuiLabel_Money.Text = String.Format("$%d", Cash);
}
#99
I need to calculate the inverse sine. For the formula sin(x) = a/b, I have a and b, but I need to figure out the angle, and I don't think that AGS has a built-in sin-1(x) function.
#100
Quote from: Calin Leafshade on Wed 16/12/2009 19:43:49
...since it pulses in and out in a regular fashion.. it should be more like slowly closing and opening your eyes whilst finding it more and more difficult to keep them open each time.

sounds like you need to program in a virtual version of a Bridge Rectifier

It would look something like this:
Code: ags

if(Maths.Sin(factor*x) < 0) result = (Maths.Sin(factor*x)-Maths.Sin(factor*x))+Maths.Sin(factor*x);
else result = Maths.Sin(factor*x);
factor -= 0.05;


Basically, if the result is negative, then flip it. Else, leave it alone. It would give you a graph that looks like a landscape of steep hills, rather than a hill, then valley, then another hill, the another valley, and etc.
SMF spam blocked by CleanTalk