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

#1
Hi all -

I'm working on a simple particle system for my game, and I'm curious about the efficiency of bitwise operators in AGS.

In principle I could store the coordinates of several particles in a single int, which could be more efficient (this is also a fun way to learn bitwise operations).

However, some older forum posts say that bitwise operations in AGS aren't faster (or might be a little slower) than standard logic. Does anyone know if this is still the case?

Thanks.
#2
Hi -

Can regular structs contain dynamic arrays?

I'm trying to make an array of integers inside of each room, with the size of the array proportional to the size of the room. I've tried declaring a struct containing a dynamic array int rsize[], but when I try to initialize the struct the game crashes.

In the manual it states explicitly that managed structs can't contain dynamic arrays, but the documentation on regular structs is a little more vague. I see older technical threads saying that dynamic arrays don't work in regular structs, but I just want to be sure that I'm not missing anything in the newer versions of AGS.

Thanks as always.
#3
Hi all -

I'm working on an effect where characters appear to "wade" through water.

Right now it works by (1) making a DynamicSprite* dyWade from the character's currently displayed ViewFrame*, vwCurrent, (2) drawing a transparent rectangle over the bottom of dyWade, (3) assigning vwCurrent.Graphic = dyWade.Graphic, and (4) restoring vwCurrent.Graphic to its default value when the next animation frame is displayed.

This works well at low res with one issue: there's a "flicker" effect. I assume this is from the default sprite being drawn, and then the modified sprite being drawn an instant later. It's just a little distracting.

Is this something that I can work around (ie, is it possible to modify a character's current ViewFrame before it's drawn onto the screen)?

Here's the relevant code (dyWade, vwCurrent, vwLast, and lastgraphic are arrays declared elsewhere):

Code: ags

void RestoreLastViewFrame(this Character*) {
  //restores the previously displayed ViewFrame for "this" to "lastgraphic," its default sprite
  //must be called after lastgraphic is stored
  
  vwLast[this.ID].Graphic = lastgraphic[this.ID]; 
  vwLast[this.ID] = null; 
}

void MakeWadingSprite(this Character*, int depth) {
  //makes a wading sprite out of "this"'s current viewframe
  //  and stores it to dyWade[this.ID]
  //also saves the default graphic for "this"'s current ViewFrame to lastgraphic[this.ID]
  
  //must have stored vwCurrent[this.ID] before calling
  dyWade[this.ID] = DynamicSprite.CreateFromExistingSprite(vwCurrent[this.ID].Graphic, true); 
  DrawingSurface* dwWade = dyWade[this.ID].GetDrawingSurface(); 
  dwWade.DrawingColor = COLOR_TRANSPARENT; 
  int x1 = 0; 
  int x2 = dyWade[this.ID].Width; 
  int y2 = dyWade[this.ID].Height; 
  int y1 = y2 - depth; 
  dwWade.DrawRectangle(x1, y1, x2, y2); 
  dwWade.Release(); 
  
  lastgraphic[this.ID] = vwCurrent[this.ID].Graphic;   
}

void Wade(this Character*) { //CALLED IN REPEATEDLY_EXECUTE
  
  vwCurrent[this.ID] = this.GetCharacterFrame(); //GetCharacterFrame(this Character*) returns ViewFrame for this.View, this.Loop, this.Sprite
  
  if (vwLast[this.ID] == null) {
    vwLast[this.ID] = vwCurrent[this.ID]; 
    this.MakeWadingSprite(15); 
    vwCurrent[this.ID].Graphic = dyWade[this.ID].Graphic; 
  }
  else if (vwLast[this.ID] != vwCurrent[this.ID]) {
    this.RestoreLastViewFrame(); 
  }
}
#4
Hi all -

I'm working with managed structs for the first time, and I'm running into a syntax issue. I've reviewed the manual and some other forum entries but can't figure what I'm doing wrong.

I made a managed struct "Particle" to do some particle effects (floating dust, things like that). I'm having trouble initiating it. Here's the relevant code

Code: ags

Particle* pRaindrops

void LoadParticleArrays() {
    pRaindrops = new Particle[1000]; 
    int i; 
    while (i < 1000 {
        pRaindrops[i] = new Particle;
        i++; 
    }
}

function game_start() {
    LoadParticleArrays(); 
}


When I launch the game I get an error "Type mismatch: Cannot convert 'Particle' to 'Particle,'" which is a little baffling.

What am I doing wrong here?

Thanks.
#5
Hi all -

Short version: If the game crashes, is there a way to view the last series of functions that were called before the crash? I've tried using the AbortGame command, but it just directs to the last function called, not the calling function. 

More detailed: My game has a reference list of "families" that used to live in the post-apocalyptic game world.  I have a command GetName(int f) that returns the name of family "f." This command is called by many other functions, for example to give the player information about the inhabitants of an abandoned house.

Occasionally the game crashes because a calling function passes GetName(-1). Is there a way to see which function called GetName(-1)? It would save me some time.

Thanks.
#6
Hi all -

I'm making a custom speech system so that I have more control over the location of the speech GUI. 

Essentially I'd like the player's speech to appear in one part of the screen when they're simply talking and to appear in a different part of the screen when they're in dialog with someone.

It's easy enough to change the location of my speech GUI and launch a dialog in the same command.

However, I'm not sure how to change the location of the speech GUI when the dialog ends.  I'd really prefer not to enter a "ChangeSpeechGUIPosition" command at the end of every dialog.

Is there a game event that's triggered whenever a dialog stops?  Or is there a game variable that becomes true (for example) when a dialog is running?

Thanks
#7
Hi all -

When I pass the command player.Say(string message), does "message" get stored in a way that's retrievable? For example, if I wanted another character to repeat whatever the player was saying, could I retrieve "message"  from the engine and then pass it to Parrot.Say(message)?

I know this could be done by declaring the player's dialog in local strings first, but I'm wondering about a more general approach.

Thanks.
#8
Using Sierra-style speech with an opaque background, I noticed a little quirk: If I use the default text window GUI, the characters' speech is printed to the GUI in their speech color.  If I use a custom text window GUI, their speech is printed in that GUI's "text color."  Is there a way to print speech to a custom text window GUI using a character's speech color (the way it does with the default window)?

Reading the forums I'm pretty sure the answer is "no," but I'm being cautiously optimistic. 
#9
UPDATE - my apologies, after posting I reread the manual entry again, and it answered my question.

PLEASE DISREGARD. 

Hi all -

I've been looking at the manual and forums, but I can't find an answer to this question that makes sense at my (very basic) level. 

I'm writing a function that would generate a list containing multiple items (strings). 

Can I declare a dynamic array and then declare a new size for that array each time the function is called? 

This is what I'm thinking of:
Code: ags

String rstring[]; 

String MakeList(int howmanyitems) {
    rstring = new String[howmanyitems]; 
    String output = ""; 
    char i;  
    while (i<howmanyitems) {
        rstring[i] = ##SELECT FROM A PREEXISTING ARRAY#; 
        output = output.Append(rstring[i]); 
        i++; 
    }
    return output; 
}


I'd like to know if this is going to compile, or if I'm misusing dynamic arrays.

Thanks
#10
AGS Games in Production / The Bestiary
Fri 16/02/2018 21:09:38


You are a Student of the Observers, making your first descent into the Fallen World. Your Teacher is with you, but you know your duty: Observe the fallen Creatures and return to the Observers with your field notes. But once you enter the fallen world you duty, your faith, and your life will be in constant peril.

Explore the Fallen World, an open map of streets and homes, an atmosphere of danger and loss. Its denizens have long since departed, but they've left secrets: a history of love and loss that changes with every play-through.

Observe the Creatures - alive or dead. Fortify yourself for brutal combat, or relinquish your weapons - the Creatures will know. Each Creature's description and location is set dynamically; find all of them and fill your notebook with observations of their decline.

Stay alive. Not even your Teacher can protect you in a world of floods, disease, and dark corners. But even if you make it back, the Observers may not like what you have to say.

Features:
- An open map to explore at your own pace, in your own way!
- Hundreds of in-game texts generated dynamically on every play-through!
- Fluid keyboard-and-mouse controls!
- Ultra-high-resolution 320x240 graphics!
- Original chiptune-style score!
- An NPC companion that may actively dislike you!

Progress:
Graphics: 50%
Sound: 40%
Scripting: 75%

These stairs appear to climb, but make no mistake: We are descending.
















This game has been my hobby since around Christmas 2016. It's been my introduction to scripting and low-resolution graphic design, so there's been a steep (but very fun) learning curve. I'm cautiously optimistic that a playable version will be done by Labor Day 2018. (Fingers crossed)
#11
Hi all -

This is a very simple but annoying issue.  I'm trying to remove the default "button" graphics from the buttons on a GUI and replace them with a transparent sprite that has the button's description on it.  Here is the code I'm using:

Code: ags

            DynamicSprite *bfast = DynamicSprite.Create(btnFast.Width, btnFast.Height); 
            DrawingSurface *dfast = bfast.GetDrawingSurface(); 
            dfast.Clear(); 
            dfast.DrawingColor = player.SpeechColor; 
            dfast.DrawString(0, 0, Game.NormalFont, "Fast"); 
            dfast.Release();
            btnFast.NormalGraphic = bfast.Graphic;


That code is repeated for each of the buttons, however it doesn't work.  The button either retains its original default graphic or (if I delete the button text) it is completely invisible (the GUI and buttons are still enabled correctly, just invisible).  This seems like a problem with a simple solution, but I'm not sure why my code isn't working.

Thanks.
#12
Hi all -

My game has started crashing with a fatal exception error whenever I call the "game restart" function.  Here is the crashdump report:

Code: ags

---------------------------
Adventure Game Studio
---------------------------
An error occurred whilst trying to load your game. The error was: 



Data at the root level is invalid. Line 1, position 1.

Error details: System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1.

   at System.Xml.XmlTextReaderImpl.Throw(Exception e)

   at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)

   at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()

   at System.Xml.XmlTextReaderImpl.ParseDocumentContent()

   at System.Xml.XmlTextReaderImpl.Read()

   at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)

   at System.Xml.XmlDocument.Load(XmlReader reader)

   at System.Xml.XmlDocument.Load(String filename)

   at AGS.Editor.AGSEditor.LoadGameFile(String fileName)

   at AGS.Editor.Tasks.LoadGameFromDisk(String gameToLoad, Boolean interactive)

   at AGS.Editor.InteractiveTasks.LoadGameFromDisk(String gameToLoad)
---------------------------


I've seen that these exceptions can be triggered by problems with sprite handling, and just before this issue occurred the game crashed while running an animation (which had previously run without issue).  I suppose I can start by reimporting some of my sprites and see if that helps.

Any other thoughts?

Thanks.
#13
Sorry for a such a basic question, but I'm clearly missing something.  I have an array of the struct Cstat, which contains some character stats for my game.  For simplicity's sake, I'll focus on "int aggression." 

I have a command to return aggression, which works fine:

Code: ags

int Aggression(this Character*) {
return Cstat[this.ID].aggression;
}

if (this.Aggression() > 10) this.Attack(); 


If I want to increase the character's aggression level I know how to use the script o-name:

Code: ags

Cstat[this.ID].aggression ++; 


What I don't understand is how / if I can write a custom function allowing me to do this:

Code: ags

this.Aggression ++; 


I assume I have to use a method within the struct, but I'm a novice coder and the wiki/manual aren't 100% clear on implementing methods within structs. 

I'm using AGS v 3.3, BTW.

Thanks.
#14
I realize this is a silly question, but I'm new at this and trying to get a better handle on the AGS engine:

I'm making a game that randomly selects descriptions of Hotspots/Characters from arrays of Strings.  On game start I have a series of commands that populate the arrays, and the game will probably need at least 1,000 descriptor Strings to play the way I want it to.

I know Strings are "large" relative to other data types, but I assume that they're still tiny relative to the memory pool in a modern PC.  Is it possible to get performance issues with all of those strings sitting in the memory? 

In my day job I work with some statistical software that has serious issues with file bloating and memory use when it tries to load text, which put this question in my mind. 
#15
Hopefully this is the right board...
In one of my rooms, I have a graphical overlay that I'm using as a piece of the foreground.  I've run into an issue where this overlay disappears whenever I open my Inventory GUI.  The other GUIs do not cause this issue, so I'm trying to pin it down. 

1) The user presses "Mouse Middle" or "I" to open the Inventory - the issue occurs regardless of which button is pressed
2) The GUI becomes visible using this code:

Code: ags
function OpenInventory() {
    if (!IsGamePaused() && gMap.Visible == false) { //Only open the inventory if the game is not paused and the map is not open
    if (gInv.Visible == false) { //Open the Inventory if it's closed
    gInv.Visible = true;
    boxIDesc.Text = "";
    lblIName.Text = "";
         }
    else { //Close the inventory it's open
    gInv.Visible = false;
    boxIDesc.Text = "";
    }}}


3) While the GUI is open, this script runs under "repeatedly_execute" - to label each inventory item when you hover over it, and also control the visibility of the arrow buttons:

Code: ags
if (gInv.Visible == true) {
  InventoryItem *iscreen = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
  if (iscreen != null && iscreen != iToken) { //The iToken cannot be activated by the mouse
  i = iscreen;
[b]lblIName.Text = String.Format(i.Name);[/b]
  if (i != i2) { //Clears the description if you hover on a new item
    boxIDesc.Text = "";
  }  }
  else {
    lblIName.Text = "";
    boxIDesc.Text = "";
  } 
  if (boxInv.TopItem > 0) { //Activates the Scroll Up arrow if the list is scrolled down
    btnInvUp.Enabled = true;
    btnInvUp.Visible = true;
  }
  if (boxInv.ItemCount > 9) { //Activates the Scroll Down arrow if the list contains >9 items
      btnInvDn.Visible = true;
      btnInvDn.Enabled = true;
    }  }


EDIT: I went through the "repeatedly_execute" section, and it appears that any lines of code that set the "lblIName" or "boxIDesc" text will also remove the overlay.  Any thoughts on why (and how to fix it)?
#16
this is an awfully simple question, and i'm actually a little embarrassed that i can't solve it. 

i made a gui that follows the mouse, displaying the name of the object under the cursor.  it works fine, but i only want this function to work in certain rooms.  so i set gFloatText.Visible=false; in the game_start function of Global.asc.

right now i'm just doing a single room to experiment with the program, and i want said gui to be visible in this room.  so at the top of the room script i added  a function that includes gFloatText.Visible = true; . 

when i test my game however, the gui is not visible.  i assume i'm missing some fundamental detail here, but i have no idea what. 

#17
hello -

i'm very new with ags, and i've run into a problem with what seems like a simple task.

after running any interaction i'd like the mouse cursor to automatically set itself to "walk."  is there a way to do this without manually adding "mouse.Mode=eModeWalkTo;" at the end of every interaction in the game?

i tried editing the on_mouse_click function to change the cursor after processing the mouse click, but doing so cancels the intended interaction. 

any suggestions?
SMF spam blocked by CleanTalk