QfG dialogs / SnowRain without plugin

Started by Superman95, Wed 07/09/2005 04:26:47

Previous topic - Next topic

Superman95

(Not directly related to the Beta, so split from the thread.)

1.) Is it possible to have the dialog engine run like the VGA version of Hero's quest vs. the options listed at the bottom of the screen?  Or even better, is it possible to assign a GUI to the engine?

2.) And on an unrelated note.  The snow/rain plugin is really cool, but with it being a plugin it ties the game to windows.  Does anyone know the algothm used?  maybe the logic could be done in the new scripting engine...or if it's too slow maybe CJ could integrate the functionality into AGS (hint, hint).

Thanks.

strazer

#1
1.) Yes, both.
Check out the "Speech style", "Dialog options go upwards on GUI" and "Dialog options on GUI" settings in the General settings.

2.) I've played around with it, but it's pretty slow since RawDraw functions have to be used. The plugin is able to draw on the screen directly every game cycle. So it's possible, but very slow. The speed issues have been discussed here.

Here's an excerpt from a private discussion I had with the plugin's author, Scorpiorus, more than a year ago:

Quote from: Scorpiorus
QuoteI was wondering if it is possible to code rain without using a plugin?
Yes, the only limitation is that you can draw only onto background. :P

QuoteI don't know anything about how the plugin system works. Do you use AGS built-in function to draw the raindrops on the screen?
The plugin uses Allegro library and draws ontop of the screen.

QuoteI've done a simple test moving a single raindrop with repeatedly_execute and RawDrawImage. Is it worth pursuing or shouldn't I bother?

Maybe you could give some hints on how you move all those raindrops?
Sure, here is  the basic script code. I used RawDrawLine() but it can be RawDrawImage() as well

// room script file

//the max number of drops:
#define DROPS_MAX 100

// Drop struct
struct TDrop {
  int x;   // x co-ordinate
  int y;   // y co-ordinate
  int speedX;   // x-speed
  int speedY;   // y-speed
  int baseline;   // drop baseline
};

// declaring an array of drops:
TDrop Drops[DROPS_MAX];

//initialization:
function Drops_Initializate() {
  int i=0;
  while (i<DROPS_MAX) {
    
    Drops.x =  Random(320);   // set them along the screen width and...
    Drops.y = -Random(500);   // ...off top of the screen
    Drops.speedX = 0;    // let it be 0
    Drops.speedY = Random(7); // falling speed 0-7
    Drops.baseline = 180+Random(20); // baseline 180-200
    
    i++;
  }
}


// for repeatedly execute
function Rain_RE() {
  
  //clear screen:
  RawRestoreScreen();
  
  int i=0;
  while (i<DROPS_MAX) {
    
    // move drop:
    Drops.y += Drops.speedY;
    // if drop has just landed reinit it's y-coordinate (off the screen)
    if (Drops.y > Drops.baseline) Drops.y = -Random(500);
        
    // set color
    RawSetColor(15);
    // draw drop
    RawDrawLine(Drops.x, Drops.y, Drops.x, Drops.y + 5);
        
    i++;
  }
    
}



function room_*() {
  // script for room: Repeatedly execute
    
  Rain_RE();
}

function room_*() {
  // script for room: Player enters screen (after fadein)
  
  RawSaveScreen();
  Drops_Initializate();
  
}



QuoteI suppose you've used a struct & an array too to store and retrieve each raindrops properties?
But I still haven't got the mechanics quite right. Which properties do I need and how do I incorporate wind and the like? Could you give me the formulas you've used or give me a link to a tutorial?
Yeah, basically you have a struct with all the properties you need. To add a wind effect you can adjust speedX variable. Snowflakes drifting is a bit harder as the plugin uses floating point numbers and appropriate sin() and cos() functions to handle that sort of thing.

For example the drifting formula is:

Drop.X = Drop.x0 + DriftRange * Sin(DriftSpeed * Drop.y);


Drop.x - result X coordinate
Drop.x0 - init x coordinate (should be set once and not modified later)
DriftRange - well, just an amplitude of drifting
DriftSpeed - frequency of drifting
Drop.y - current Y-coordinate (can be replace with some timer variable).

Just to get you started. :)

GarageGothic

But the main problem with using RawDraw is that the snow will always be behind the character. If you use that, you should add perhaps 5-10 characters/objects for foreground snow flakes.

strazer

I just hide characters and objects in the room and rawdraw their current frames behind or on top of the raindrops, according to their baselines. Yours is a nice idea, too.

GarageGothic

True, you could do that too of course :)

Superman95

#5
I haven't tried it, but how about a couple of overlays the size of the screen.Ã,  Then, at each frame draw them shifted.... you'd need more than one overlay though otherwise they would all move together.Ã,  Even with several overlays it may not look right.


Another thought would be to ask CJ to create another interaction at the room level, like repeatedly_execute, but after the frame has been drawn but before it's flipped to the screen.  Then, you could write scripts that run like plugins do.  Although this wouldn't help the speed issue.

Personally, I would love to see the functionality intergrated into the engine.  Then you get speed and platform independence. :)

Pumaman

Actually, speed is the reason I haven't done that. Adding yet another script function that gets run every game loop would have the potential to slow things down somewhat.

SMF spam blocked by CleanTalk