stats:
640x400
16bit hi colou?r
sprite sizeÃ, 320x240
It's a cutscene I'm doing where I'm movie objects around, fading them in and out (transparency) and displaying the occasional gui with text.Ã, The majority of the work is being done in rep_exe_always because there are several things I'm coordinating together and this was the easiest solution I found to do.Ã, The rep_exe_always function is not really heavy.Ã, I just keep track of various ints to know when to perform something or not.
For example, the sprite above I am moving 1 pixel to the right every 5 cycles (gamespeed = 100)
The object is moving to the right at the same rate, it fades in, stays solid a bit, then fades out.
Sadly, this sprite flickers very noticably when it moves.Ã, I've tried various things like changing the game speed.Ã, I normally directly change the .X property, but I tried using the Move command without success.
Anyway, what can I do to reduce flicker?
Can you post the related part of codes here?
ok fair enough
code of importance....
"header" stuff
String _NarateText;
int _NarateTime = 0;
enum StillState
{
Ã, unstarted,
Ã, start,
Ã, fadein,
Ã, solid,
Ã, fadeout
};
int NUM_OBJS = 2;
struct ObjectMove
{
Ã, int deltaX;
Ã, int changeXevery;
Ã, int deltaY;
Ã, int changeYevery;
Ã, int startX;
Ã, int startY;
Ã, int solidTime;
Ã, int deltaIn;
Ã, int changeInevery;
Ã, int deltaOut;
Ã, int changeOutevery;
Ã,Â
Ã, int _trans;
Ã, int _x;
Ã, int _y;
Ã, int _solid;
Ã, int _in;
Ã, int _out;
Ã,Â
Ã, Object* o;
Ã, StillState state;
};Ã,Â
ObjectMove stills[2];
#sectionstart room_bÃ, // DO NOT EDIT OR REMOVE THIS LINE
function room_b() {
Ã, // script for Room: Player enters room (before fadein)
Ã, SetSkipSpeech(2);
Ã, Mouse.Mode = eModeBlank;
Ã, Mouse.UseModeGraphic(eModeBlank);
Ã, Mouse.ChangeModeGraphic(eModeWait, 6);
Ã, stills[0].o = oStill1;
Ã, stills[1].o = oStill2;
Ã, Ã,Â
Ã, int loop = NUM_OBJS;
Ã, while (loop > 0)
Ã, {
Ã, Ã, loop--;
Ã, Ã, stills[loop].state = unstarted;
Ã, Ã, stills[loop].o.Transparency = 100;
Ã, }
}
#sectionend room_bÃ, // DO NOT EDIT OR REMOVE THIS LINE
here is after fade in code that triggers the events to happen (but does not actually do them:
#sectionstart room_aÃ, // DO NOT EDIT OR REMOVE THIS LINE
function room_a() {
Ã, // script for Room: Player enters room (after fadein)
Ã,Â
Ã, StartCutscene(eSkipESCOnly);
Ã,Â
Ã, _NarateText = "blablabla";
Ã, _NarateTime = 400;
Ã, Wait(400);
Ã, Wait(200);
Ã,Â
Ã, _NarateText = "blablabla";
Ã, _NarateTime = 400;
Ã, Wait(400);
Ã,Â
Ã, _NarateText = "blablabla";
Ã, _NarateTime = 400;
Ã, Wait(400);
Ã, // 10 s = 1,000 cycles
Ã, stills[0].startX = -50;
Ã, stills[0].deltaX = 1;
Ã, stills[0].changeXevery = 10;
Ã, stills[0].deltaY = 0;
Ã, stills[0].changeYevery = 0;
Ã, stills[0].startY = 175;
Ã, stills[0].deltaIn = 1;
Ã, stills[0].changeInevery = 9;Ã, Ã, // 900 = inÃ, cycle
Ã, stills[0].solidTime = 900;Ã, Ã, Ã, // 900 = solid
Ã, stills[0].deltaOut = 1;
Ã, stills[0].changeOutevery = 9;Ã, // 900 = out cycle
Ã, stills[0].state = start;Ã, Ã, Ã,Â
Ã, Wait(200);
Ã, _NarateText = "blablabla";
Ã, _NarateTime = 400;
Ã, Wait(400);
Ã, _NarateText = "blablabla";
Ã, _NarateTime = 400;
Ã, Wait(400);
Ã, _NarateText = "blablabla";
Ã, _NarateTime = 400;
Ã, Wait(400);
Ã, Wait(200);
Ã, stills[1].startX = 200;
Ã, stills[1].deltaX = -1;
Ã, stills[1].changeXevery = 10;
Ã, stills[1].deltaY = -1;
Ã, stills[1].changeYevery = 30;
Ã, stills[1].startY = 190;
Ã, stills[1].deltaIn = 1;
Ã, stills[1].changeInevery = 9;Ã, Ã, // 900 = inÃ, cycle
Ã, stills[1].solidTime = 900;Ã, Ã, Ã, // 900 = solid
Ã, stills[1].deltaOut = 1;
Ã, stills[1].changeOutevery = 9;Ã, // 900 = out cycle
Ã, stills[1].state = start;Ã, Ã, Ã, Ã,Â
Ã, Wait(500);
Ã,Â
Ã, _NarateText = "blablabla";
Ã, _NarateTime = 400;
Ã, Wait(400);
Ã, Wait(400);
Ã, Wait(200);
Ã, EndCutscene();Ã,Â
Ã, RestartGame();
}
#sectionend room_aÃ, // DO NOT EDIT OR REMOVE THIS LINE
naturally more than blabla is said, but I'm hiding the text for now
secret stuff ya know
now the good stuff....this is where the real work is done
function repeatedly_execute_always()
{
Ã, if (_NarateTime > 0)
Ã, {
Ã, Ã, int w = GetTextWidth(_NarateText, 0);Ã, Ã,Â
Ã, Ã, TimNarateText.Text = _NarateText;
Ã, Ã, int x = (320 - w) / 2;
Ã, Ã, TimNarateText.X = x;
Ã, Ã, _NarateTime--;
Ã, Ã, gIntronarate.Visible = true;
Ã, }
Ã, else
Ã, {
Ã, Ã, gIntronarate.Visible = false;
Ã, }Ã,Â
Ã, int loop = NUM_OBJS;
Ã, while (loop > 0)
Ã, {
Ã, Ã, loop--;
Ã, Ã, bool move = false;
Ã, Ã, if (stills[loop].state == start)
Ã, Ã, {
Ã, Ã, Ã, stills[loop]._x = stills[loop].changeXevery;
Ã, Ã, Ã, stills[loop]._y = stills[loop].changeYevery;
Ã, Ã, Ã, stills[loop]._solid = stills[loop].solidTime;
Ã, Ã, Ã, stills[loop]._in = stills[loop].changeInevery;
Ã, Ã, Ã, stills[loop]._out = stills[loop].changeOutevery;
Ã, Ã, Ã, stills[loop]._trans = 100;
Ã,Â
Ã, Ã, Ã, stills[loop].o.X = stills[loop].startX;
Ã, Ã, Ã, stills[loop].o.Y = stills[loop].startY;
Ã, Ã, Ã, stills[loop].o.Transparency = 100;
Ã, Ã, Ã, stills[loop].state = fadein;
Ã, Ã, }
Ã, Ã, else if (stills[loop].state == fadein)
Ã, Ã, {
Ã, Ã, Ã, move = true;
Ã, Ã, Ã, stills[loop]._in -= 1;
Ã, Ã, Ã, if (stills[loop]._in <= 0)
Ã, Ã, Ã, {
Ã, Ã, Ã, Ã, stills[loop]._in = stills[loop].changeInevery;
Ã, Ã, Ã, Ã, stills[loop]._trans -= stills[loop].deltaIn;
Ã, Ã, Ã, Ã, if (stills[loop]._trans < 0)
Ã, Ã, Ã, Ã, {
Ã, Ã, Ã, Ã, Ã, stills[loop]._trans = 0;
Ã, Ã, Ã, Ã, Ã, stills[loop].state = solid;
Ã, Ã, Ã, Ã, }
Ã, Ã, Ã, Ã, stills[loop].o.Transparency = stills[loop]._trans;Ã,Â
Ã, Ã, Ã, }
Ã, Ã, }
Ã, Ã, else if (stills[loop].state == solid)
Ã, Ã, {
Ã, Ã, Ã, move = true;
Ã, Ã, Ã, stills[loop]._solid -= 1;
Ã, Ã, Ã, if (stills[loop]._solid <= 0)
Ã, Ã, Ã, {
Ã, Ã, Ã, Ã, stills[loop].state = fadeout;
Ã, Ã, Ã, }
Ã, Ã, }
Ã, Ã, else if (stills[loop].state == fadeout)
Ã, Ã, {
Ã, Ã, Ã, move = true;
Ã, Ã, Ã, stills[loop]._out -= 1;
Ã, Ã, Ã, if (stills[loop]._out <= 0)
Ã, Ã, Ã, {
Ã, Ã, Ã, Ã, stills[loop]._out = stills[loop].changeOutevery;
Ã, Ã, Ã, Ã, int t = stills[loop].o.Transparency;
Ã, Ã, Ã, Ã, t += stills[loop].deltaOut;
Ã, Ã, Ã, Ã, if (t > 100)
Ã, Ã, Ã, Ã, {
Ã, Ã, Ã, Ã, Ã, t = 100;
Ã, Ã, Ã, Ã, Ã, stills[loop].state = unstarted;
Ã, Ã, Ã, Ã, }
Ã, Ã, Ã, Ã, stills[loop].o.Transparency = t;Ã, Ã, Ã,Â
Ã, Ã, Ã, }
Ã, Ã, }
Ã,Â
Ã, Ã, if (move)
Ã, Ã, {
Ã, Ã, Ã, stills[loop]._x -= 1;
Ã, Ã, Ã, stills[loop]._y -= 1;
Ã, Ã, Ã,Â
Ã, Ã, Ã,Â
Ã, Ã, Ã, if ((stills[loop]._x <= 0) && (stills[loop].deltaX != 0) && (stills[loop]._y <= 0) && (stills[loop].deltaY != 0))
Ã, Ã, Ã, {
Ã, Ã, Ã, Ã, stills[loop]._x = stills[loop].changeXevery;
Ã, Ã, Ã, Ã, stills[loop]._y = stills[loop].changeYevery;
Ã, Ã, Ã, Ã, stills[loop].o.X += stills[loop].deltaX;
Ã, Ã, Ã, Ã, stills[loop].o.Y += stills[loop].deltaY;
Ã, Ã, Ã, }
Ã, Ã, Ã, else if ((stills[loop]._x <= 0) && (stills[loop].deltaX != 0))
Ã, Ã, Ã, {
Ã, Ã, Ã, Ã, stills[loop]._x = stills[loop].changeXevery;
Ã, Ã, Ã, Ã, stills[loop].o.X += stills[loop].deltaX;
Ã, Ã, Ã, }
Ã, Ã, Ã, else if ((stills[loop]._y <= 0) && (stills[loop].deltaY != 0))
Ã, Ã, Ã, {
Ã, Ã, Ã, Ã, stills[loop]._y = stills[loop].changeYevery;
Ã, Ã, Ã, Ã, stills[loop].o.Y += stills[loop].deltaY;
Ã, Ã, Ã, }
Ã, Ã, }Ã,Â
Ã, }Ã,Â
}