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

#141
Quote from: geork on Wed 24/04/2013 11:41:23
You can reference a font through it's enumerated index. Something like:
Code: AGS
int f = eFontFont0;
Overlay *v = Overlay.CreateTextual(40, 40, 40, f, 6, "hi!");//where f stands in for the FontType parameter


I don't know if the wording I've used is correct, but the code works :-D

Thanks, that seems to work perfectly.

Anyway, I'm just going to post the code here, as it's easier for me to keep it updated.

V1.2

Script Header:
Code: ags
//Expressed as MAXIMUM_DISPLAY_TIME * (delay * 4)
//Therefore, a delay setting of 3 and a maximum time of 5
//will wait 60 game loops before removing the text
#define TYPEWRITER_MAXIMUM_DISPLAY_TIME 5

enum TypewriterStyle {
  eTypewriter_LongSpace,
  eTypewriter_Constant,
  eTypewriter_ShortSpace,
  eTypeWriter_Mixed,
};

enum TypewriterFlash {
  eTypewriter_Flash = true, 
  eTypewriter_DontFlash = false, 
};

struct Typewriter {
  import static void Type (int x, int y, int delay, int color, int font, 
                           String text, TypewriterStyle style, 
                           AudioClip *sound = 0, TypewriterFlash flash = true);
};


Main Script:
Code: ags
Overlay *olTypedText;

static void Typewriter::Type (int x, int y, int delay, int color, int font,
                              String text, TypewriterStyle style,
                              AudioClip *sound, TypewriterFlash flash) {
  
  String displayedLine = "";
  
  olTypedText = Overlay.CreateTextual (x, y, System.ViewportWidth - x, 
                                       font, color, displayedLine);
  
  Wait (delay);
  
  int i = 0;
  while (i < text.Length) {
    
    displayedLine = String.Format ("%s%c", displayedLine, text.Chars[i]);
    olTypedText.SetText (System.ViewportWidth - x, font, color, displayedLine);
    
    if (style == eTypewriter_LongSpace) {
      if (text.Chars[i] == ' ')
        Wait(delay*2);
      else if (text.Chars[i] == '[')
        Wait(delay*4);
      else {
        if (sound)
          sound.Play ();
        Wait(delay);
      }
    }
    
    else if (style == eTypewriter_Constant) {
      if (text.Chars[i] == ' ')
        Wait(delay);
      else if (text.Chars[i] == '[')
        Wait(delay*2);
      else {
        if (sound)
          sound.Play ();
        Wait(delay);
      }
    }
    
    else if (style == eTypewriter_ShortSpace) {
      if (text.Chars[i] == ' ')
        Wait(delay/2);
      else if (text.Chars[i] == '[')
        Wait(delay*2);
      else {
        if (sound)
          sound.Play ();
        Wait(delay);
      }
    }
    
    else if (style == eTypeWriter_Mixed) {
      int r = Random(2);
      if (text.Chars[i] == ' ') {
        if (r == 0)
          Wait (delay*2);
        else if (r == 1)
          Wait (delay/2);
        else
          Wait (delay);
      }
      else if (text.Chars[i] == '[') {
        if (r == 0)
          Wait (delay*2);
        else
          Wait (delay*4);
      }
      else {
        if (sound)
          sound.Play ();
        Wait (delay);
      }
    }
    
    i++;
 
  }
  
  if (flash == eTypewriter_Flash) {
     i = 0;
    while (i < TYPEWRITER_MAXIMUM_DISPLAY_TIME) { 
      olTypedText.SetText (System.ViewportWidth - x, font, color,
                           displayedLine.Truncate (displayedLine.Length - 1));
      Wait (delay*2);
      displayedLine = String.Format ("%s%c", displayedLine, text.Chars[displayedLine.Length]);
      olTypedText.SetText (System.ViewportWidth - x, font, color, displayedLine);
      Wait (delay*2);
      i++;
    }
  }
  
  else if (flash == eTypewriter_DontFlash) {
    Wait (TYPEWRITER_MAXIMUM_DISPLAY_TIME * (delay * 4));
  }
  
  if (olTypedText.Valid)
    olTypedText.Remove ();
  
}
#142
Thanks! The code works perfectly so far, I haven't found any bugs. The only annoyance I've found is that I can't create a pointer to a font in the function's arguments.
So if you need to use different fonts throughout your usage of Typewriter, you're either gonna have to copy paste the code for each font or just not use it :/

Does anyone know if there's a way to do this?
#143
See a few posts down for the code.

Code: ags
Typewriter.Type (int x, int y, int delay, int color, int font,
                 String text, style, display, optional AudioClip sound,
                 optional TypewriterFlash flash);

           
Displays 'text' as typwriter text at 'x' and 'y', in color 'color',
with a delay of 'delay' (in game loops) between characters, using
font 'font'

Style specifies which style you want to use.

Code: ags
eTypewriter_LongSpace

 
Spaces are delayed twice as long as other characters.
 
Code: ags
eTypewriter_Constant

 
All increments are delayed equally.

Code: ags
eTypewriter_ShortSpace

 
Spaces are delayed half the length of other characters.

Code: ags
eTypeWriter_Mixed

 
Spaces are randomized to be either half, double or the same as other
characters.

Pass an audio clip name as sound to play a sound with each letter.
Leave it out (or pass as '0') for no sound.

Set TypewriterFlash to eTypewriter_Flash to have the last character flash
in and out, and to eTypewriter_DontFlash to keep the last character
steady.

Display can either be displaying the effect on an Overlay or on a GUI element (either a button or a label)

eg.

Code: ags
Typewriter.Type (5, 185, 3, 65535, eFontNormal, "Write your text here[[AND WATCH IT TYPE ITSELF", eTypewriter_ShortSpace, eTypewriterDisplay_Overlay, aPop);


EDIT BY DUALNAMES: You simply import the module after downloading it from here.

http://duals.agser.me/Modules/Typewriter.zip

I've added some extra functionality. Check the header of the module for information and examples.

EDIT BY PHEMAR:

Dualnames' link seems to be broken. Original can be found here:

https://www.dropbox.com/s/vyeujxo7gbr06hk/Typewriter.zip?dl=0
#144
I've added a whole bunch of new functions, features and improvements.

An example of the code:

Code: ags
  BgSpeech.Add (cJoe, "Hi there!");
  BgSpeech.Add (cJoe, "How's the weather today?");
  BgSpeech.Pause (80);  //Adds a two second pause between these lines.
  BgSpeech.Add (cFarmer, "???", eBgSpeech_NotAnimating); //Farmer's talking animation won't play.
  BgSpeech.Add (cFarmer, "What did you say?");
  BgSpeech.Add (cBird, "SQUAWK!!!", 160, 40); // will display the speech at coordinates
  BgSpeech.Add (cJoe, "What was that!?");
  BgSpeech.Start (eBgSpeech_Loop); //optional param looping or not looping
                                   // and optional parameter which point of the queue to start in


Will queue up a bunch of speech to be looped in the background.

Download here.

Code: ags
BgSpeech.Add (Character *ID, String text, optional int x, optional int y, optional animating);


Will add 'text' to the queue, to displayed as speech for 'character'.

EG:
Code: ags
BgSpeech.Add (cEgo, "This is in the background!");


Will queue up "This is in the background!" to be displayed as speech for cEgo.

Code: ags
BgSpeech.Add (cEgo, "This is also in the background!", 120, 80, eBgSpeechNotAnimating);


Will add "This is also in the background!" to the queue to be displayed after the first message.
This time, it won't play the character's talking animation.

Optional x and y coordinates specify where the text should be displayed. Leave these
out for it to be displayed above the character's head.

Put these commands one after another to queue up speech.

---------------------------------------------------

Code: ags
BgSpeech.GetCurrentPlayingIndex ();


Gets the queue position of the currently displayed text. Returns an integer.

---------------------------------------------------

Code: ags
BgSpeech.GetCurrentText ();


Returns the text currently on the screen in the background.

---------------------------------------------------

Code: ags
BgSpeech.GetIndexLength ();

   
Gets the amount of messages currently queued up.

---------------------------------------------------

Code: ags
BgSpeech.GetQueueText (int index);


Returns the text at queue index 'index'.

---------------------------------------------------

Code: ags
BgSpeech.Looping ();


Returns true if the current conversation is looping.

---------------------------------------------------

Code: ags
BgSpeech.Pause (int loops);

 
Will add a pause between to lines of text for 'loops' amount of
game loops.
Basically a non-blocking form of Wait(int waitLoops);

---------------------------------------------------

Code: ags
BgSpeech.Playing ();


Returns true of the speech is currently playing.

---------------------------------------------------

Code: ags
BgSpeech.Reset ();


Resets the queue to its intial position, allowing you to overwrite it.

---------------------------------------------------

Code: ags
BgSpeech.Resume ();


Resumes the speech from the last line it left off.

---------------------------------------------------

Code: ags
BgSpeech.Start (optional looping, optional int QueueIndexToStartFrom);


This will start the speech going in the background.
Default is non-looping and from index 0 (the first message).

Pass eBgSpeech_Loop (or true) to loop the text or eBgSpeech_NoLoop (false or
leave it blank) to display the text only once.

QueueIndexToStartFrom is the position in the queue you wish to start playing from.

---------------------------------------------------

Code: ags
BgSpeech.Stop (optional ResetPlayQueue);


Will stop the backgound speech from playing.

Pass eBgSpeech_ResetPlayQueue to reset the queue or eBgSpeech_DontResetQueue
to leave the queue where it is.
Set to ResetPlayQueue by default.

---------------------------------------------------

KNOWN GLITCHES: Using BgSpeech.Add while the speech is playing causes the speech to jump to the next line. You can see why if you look at the code. I'm not sure how to fix this - If I don't stop the speech before adding to the queue the game seems to bug out.
#145
Quote from: Khris on Sun 21/04/2013 11:14:27
Yeah, since AGS is open source now, in theory anybody can look up the algorithms and open the data files.
I remember Crimson Wizard "offering this service" for people who lost their sources; why don't you write him a PM?

Do you mean recover the source code or just the graphics and sounds etc.?
#146
I think the only way to get graphics from an AGS executable is to screenshot each individual frame and paste it all together.

Also, I may be wrong, but I remember many moons ago someone wrote a player for music in AGS games. I can't remember if it actually ripped the sound, I think it might have just been a player for .vox files.

But as far as I know it's otherwise impossible to deconstruct a compiled game.
#147
So I got interested in designing an iMuse type dynamic music system for a project. So far I've got the timing correct but there's just a few things I'm worried about.

Here's my code so far (still early testing):

Global Header:
Code: ags
struct iMuse {
  AudioChannel *room;
  import static function Jump (int dest);
};

iMuse room1;


Global Script:
Code: ags
static function iMuse::Jump (int dest) {
  if (room1.room == null) {       //audio is null, so don't continue
    Display("Audio is null");
    return;
  }
  else {
    while (((dest + 170) - room1.room.PositionMs) > 0) Wait(1); //wait until audio reaches it's switch point (plus 170 for timing)
    room1.room.Stop ();
    room1.room = a2.Play ();          //play new sound
  }
}

function game_start() {          //  Play the first sound
  room1.room = a1.Play(eOnce);
}


Room Script:
Code: AGS
function oObject_AnyClick() {
  iMuse.Jump (5000);
}


There's two audio files, each 5 seconds (5000 ms) long. When the game begins, a1 is played, and when the character interacts with an object, the script waits till a1 has reached 5000ms (plus 170, I found that's the delay AGS needs to time things up correctly), then stops a1 and plays a2.

Now, the first problem I have is that this script is blocking - I just don't know how to use it without the Wait(1); command. I tried Timers, but they never time out correctly.

The second problem is that in iMuse.Jump, I've specified that a2 is the next audio file it needs to play. However, I wish the audio file to be specified within one of the arguments to iMuse.Jump. I'm not entirely sure how to do that.

Thirdly, the other problem I have is that a1 needs to played from the global script otherwise iMuse.Jump returns "Audio is Null." I currently have a1 being played in game_start, however I would like to play it from a room script.

Any help? Is what I'm attempting to do even possible? This is just the beginning test. Once I get the kinks sorted out I can create multiple bookmarks on audio files (at the end of phrases etc) so that they can switch anywhere at those bookmarks, and hopefully non-blocking as well.

Thanks for any help!
#148
I don't think the Instagame packs are very successful/useful to be honest. They're normally geared to one specific theme and don't contain things like objects and animations. I mean, in the past ten years there must have been like two games made with Instagame? I think Joseph's template might be more helpful to newbies looking for instant game material.

Scripting resources should definitely be compiled somewhere. The only problem I've recently had with scripting resources is that quite a bit of stuff still uses old-style code and hasn't been updated to the latest version of AGS. Also, most modules that have been released are not very good at commenting things making it quite hard to understand exactly what the author is doing with each function/block of code. This also makes it hard to use the modules as a learning tool.

Another point on scripting refers to the manual - while the manual provides you with everything you need to know in order to make a game, it is still missing a section explaining some of the more advanced scripting techniques - eg, there's no mention in the manual of #define, ifndef, endif etc. The only way to learn about these things is to examine existing code.

Also, certain utilities have gone missing from the face of the internet. I can't find a copy of LucasRipper anywhere, nor ScummRevisited etc.

So these are the main reasons I started this thread (and the fact it took me about three hours on google to find a copy of the LucasArts speech font, among other things :D ).

Oh yes, one more point - Some GUI modules tend to use the .GUE file extension which I understand belongs to AGS (or used to), but the latest version of AGS only seems to accept .GUF for GUI imports.
#149
So I've been gone quite a while now (my last game was made in 2006 o_O) and I've recently started a new project with a few friends.

Well I was very sad to find out that a lot of resources that were available back in the day are now lost in the dark depths of time and broken links.

So I was thinking of starting a Dropbox to host a whole bunch of cool stuff (fonts/templates/modules/plugins/tutorials/nifty pieces of software etc). Anyone keen to help out? Anyone got some cool stuff lying around that they'd like to share?
#150
I will be rejoining you guys on the server under the name "PIneapple_Spike" (leave it to me to put a typo in my name :/ )

Let's do this thing.
#151
General Discussion / Transgender 7 year old.
Sun 22/01/2012 09:13:08
Seriously, wtf? What are your thoughts in this?

http://www.youtube.com/watch?v=7S5usRgY720&feature=player_embedded
#152
"We are all citizens of the same nation, and our king rides a pale horse."

"They'll tear you apart, bone by bone
and build from you a human throne
Their buck-toothed king will sit upon
What once was you, but now is gone
This key unlocks the gates of Hell
Steady traveller, use it well"

- Grim Fandango
#153
Quote from: Snarky on Tue 13/12/2011 09:23:11
Since The Hitch Hiker's Guide started out as a radio play (which is arguably better than the book), it is perhaps not the best argument for the superiority of text.

True, but there was no visual component in a radio play, so it essentially was just still "text", if you nomsaying...

Also, I read a hell of a lot faster than I type than I type, so I always play with text and speech if available. I often only hear the first couple of words being spoken before I've read the line and can skip to the next one. Also I like seeing the different colors the designer has chosen for each character's speech :D
#154
There are some jokes that are only really funny through text. Monkey Island 1 & 2 are prime examples of this - Just through the way the text was used, moving around the placement, the use of capitals etc.
It's also the reason Hitchhikers guide to the galaxy worked better as a book than a movie.
#155
Movember ftfw.

#156
General Discussion / Re: Test Your Morality.
Sat 26/11/2011 09:01:25
Quote from: Intense Degree on Fri 25/11/2011 18:02:47
Logically that is an argument of course, unless you believe in an outside defining moral force of some kind. However, practically it is plainly wrong and utterly revolting. I suspect that if anyone you love is ever raped or murdered (and I seriously hope that will not happen) you will change that view.

I'm sorry, what's that go to do with anything? I said morals are arbitrary and subjective - that doesn't mean I don't have any of my own. They are subjective, so of course I have my own opinions as to what's moral, - I'm anti-rape and anti-murder - I'm just saying that a universal standard of morals cannot be established.

Go ask a serial killer or religious terrorist if what they're doing is wrong. They believe there is nothing wrong with what they're doing, so their morals are different to ours. The Mayans were notorious muderers (or sacrificers) and they believe what they were doing was right.

Therefore, morals are not universal. Other people's morals are different to your and my definition of morals.
#157
Quote from: Ryan Timothy on Tue 22/11/2011 01:21:45
My favorite forum is one that isn't offline. lol

This. :D
#158
General Discussion / Re: Test Your Morality.
Tue 22/11/2011 22:12:13
I scored low on everything.

The again, I don't really believe in morals. Morals are completely aribitrary and subjective, and can therefore not be used as a basis for behaviour as a universal set cannot be established. Morals can only come from one place, and that is from what you believe is right. Act as you will, but do not judge another man for doing what he believes is right, however insane and absurd you may deem him to be.
As for me, I will stick to my unique set of morals, which are uniquely expedient to myself.
To each their own, I say.

Edit:
Quote from: Atelier on Tue 22/11/2011 20:22:40A woman burns her country's flag. If her country is not my country I couldn't care less. The polar opposite if it is my country.

Really? May I ask why you feel so strongly about abritrary shapes and colors meant to symbolize an arbitrarily defined piece of land?
#159
General Discussion / Organ Trail
Fri 11/11/2011 05:00:28
http://hatsproductions.com/organtrail.html

Original Oregon trail game remade for the zombie apocalypse where you head west in a station wagon trying to find safe haven. Everything you loved as a child about the Oregon trail but better, with zombies! Even the hunting mini-game is in here but instead of hunting for food you scavenge for groceries while shooting/avoiding the zombie hordes.

Spent 2 hours straight playing this when I first found out about it, and yes, people will die of dysentery.

Screenshots:

http://www.eatsleepwork.com/wp-content/uploads/2010/11/Organ-Trail-Zombie-Version-1.jpg

http://3.bp.blogspot.com/_S1MTpCImz1o/TNrMT1gLZxI/AAAAAAAAA5c/N3XFrnzd8sU/s1600/organ+trail+elliot.JPG
#160
General Discussion / Re: Something For Sale!
Mon 31/10/2011 21:23:46
Wow, a body? Does this mean I won't have to lift weights anymore?
SMF spam blocked by CleanTalk