Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your help!

We need 1 more developer from Canada and 12 more from Australia to help us complete a research survey.

Support our site by taking a quick sponsored survey and win a chance at a $50 Amazon gift card. Click here to get started!


Servant of the Lord

Member Since 24 Sep 2005
Offline Last Active Yesterday, 06:26 PM

Topics I've Started

Would this be misuse of aslScriptContext::Suspend()?

02 September 2015 - 01:32 PM

I'm currently thinking through how I want scripts to interact with my game logic.
Most of my logic is going to be implemented strait in C++, but some of it will be exposed to scripts.
 
Some of the exposed logic gets processed over time, with scripts firing off an action that may take several seconds before it completes.
 
Alot of this logic is higher-level, so I was thinking my scripts might look something like this:

//Sets this entity's movement goal, and the entity moves towards that location.
//This function just returns an ID for a 'trigger' that gets triggered when the entity reaches that location.
Trigger reachedNode = thisEntity.MoveTo("node placed on map");

//Other events can be operating simultaneously.
Camera.ShakeScreen(amount, duration);

//Some functions just operate immediately.
thisEntity.SetSomeValue(value);

//Here, the script gets suspended (likely using aslScriptContext::Suspend()).
//The entity continues doing whatever logic C++-side that was already triggered (i.e. shaking the screen for the desired length of time, and walking toward the node), until the entity reaches the node, at which time C++ will resume the script's execution. Other scripts for other entities would've still been running.
WaitForTrigger(reachedNode);

//Now that the entity reached the node, we show a dialog box.
Trigger doneReadingDialog = GUI.ShowDialog("human-readable name for dialog details (including facial portraits and rich text and etc...)");

//Wait for the player to read the dialog, before resuming.
WaitForTrigger(doneReadingDialog);

//...etc...

I'd probably have up to 50-ish of these scripts in execution and suspended, though usually it wouldn't be that high, and 
 
My questions are:
A) Does this seem like reasonable use of aslScriptContext::Suspend(), or would this be abuse of that feature?
B) Am I using too many contexts?
C) What function should I use to execute small blocks of "throwaway" scripts (i.e. scripts I want to run once and then discard)? Would the ExecuteString() add-on be able to run multi-line chunks of code like the above example? Would it be able to suspend and resume?
D) If one script calls another script, do I have to use a new context, or can I use aslScriptContext::PushState()/PopState() to execute that new script before resuming the original script?

 
Thank you for your help - I'm new to AngelCode.


RequestContext() / ReturnContext() question

02 September 2015 - 12:45 PM

On this page, the documentation says:
It is seldom necessary to maintain more than one script context at a time, with the only exceptions being when a script calls an application function that in turn calls another script before returning, and if multiple scripts are running in parallel.
 
Try to avoid associating a unique context with each object that may need to call scripts. Instead keep a shared pool of contexts that can be requested by the objects on a need-to basis.

 

 

It sounds like that's what aslScriptEngine::RequestContext() and aslScriptEngine::ReturnContext() do for me, as convenience functions?
So if I have several scripts I'm wanting to run in parallel (not multithreaded, but with their execution being suspended and resumed at different times with their states needing to be preserved), can I just let AngelScript handle the pool of contexts for me using the two above functions?

Extra ads?

13 August 2015 - 08:42 PM

I've been getting extra ads for the past few days. I'm definitely logged in.

 

If everyone is getting this, that's fine! They aren't much of a nuisance. But figured I'd mention it in case it was a bug.

 

 

7e29eb0662.png

 

 


Texturing occasionally off by a pixel

15 July 2015 - 02:41 PM

Sometimes when rendering an image in such a way that [one texture's pixel == one window screen pixel], my drawn image loses the top line of pixels.

 

It should look like this:

7ab38b24c0.png

 

(The orange square is two triangles with a texture applied - not line rendering)

 

But often looks like this:

4e868240dc.png

 

After some reading, I'm thinking it's caused by the floating point values getting rounded in a way I don't want during rasterization.

Subtracting 0.375 from the position of the polygon being rendered solves the problem (or at least appears to - it visually looks fine now).

  1. Should I be subtracting 0.375 or 0.5? Some people say one, some say the other - which is a better practice?
  2. Should I be adding it or subtracting it? I'd think subtracting it would accidentally shift all my objects over by one, wouldn't it? (i.e. if I want a pixel at 0.0, I should add to it, and get 0.375, not subtract and get -0.625, right?) Adding it also appears to give the correct visual results.
  3. Should my code do this automatically for every polygon getting rendered? (keeping in mind that it's a 2D game)
  4. Can I just do it in my vertex shaders? Or, better yet, can I make my ModelViewProjection matrix automatically apply this shift?

How do I fake windows looking outdoors?

19 June 2015 - 02:16 PM

Here's a basic scene mockup using art I made for my game. (note: the sketches in the frames were from an artist I know)

 

9bf8958a46.png

 

I'm thinking about how to fake the light coming in from the windows (and also dull the divide between the floor and wall), and came up with this:

 

b30482b977.png

 

 

I'm liking how it looks (though the sun rays from the window might need to be softer), but I'm not really sure what to do with the window glass itself. It's a 2D game, so there's nothing really actually "behind" it. I could draw something to put out there, but from this camera angle, you'd basically be looking at the ground.

 

I could have a small collection of "window background" art pieces (like garden pathways and some pottery or something) that I could mix and match when creating areas, to give uniqueness to each window without having to make entire scenes for every window in my game. Hmmm.

 

Do you have advice on how to make the windows' glass look better?


PARTNERS