Skip to content

Commit

Permalink
changed repeatedly_execute to repeatedly_execute_always to fix missch…
Browse files Browse the repository at this point in the history
…ecked timers
  • Loading branch information
ericoporto committed Jan 27, 2019
1 parent cd5ba63 commit fac26fc
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 28 deletions.
2 changes: 1 addition & 1 deletion AltKeyboardMovement.asc
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ void AdvanceFrame(int xa, int ya, int l) {
Animating = false;
if (free || AnimateAtEdge) {
Animating = true;
ViewFrame *vf = Game.GetViewFrame(player.View, player.Loop, pf);
ViewFrame *vf = Game.GetViewFrame(player.NormalView, player.Loop, pf);
if (vf.LinkedAudio != null) vf.LinkedAudio.Play();
player.Frame = pf;
}
Expand Down
11 changes: 10 additions & 1 deletion FakeScreen.asc
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,16 @@ function do_once()

else
{
ViewFrame *frame = Game.GetViewFrame(character[chrIndex].View, character[chrIndex].Loop, character[chrIndex].Frame);
ViewFrame *frame;
if(character[chrIndex].View == character[chrIndex].NormalView){
frame = Game.GetViewFrame(character[chrIndex].View, character[chrIndex].Loop, character[chrIndex].Frame);
} else if(character[chrIndex].View == character[chrIndex].IdleView){
frame = Game.GetViewFrame(character[chrIndex].View, character[chrIndex].Loop, character[chrIndex].Frame);
} else if(character[chrIndex].View == DOGTOOKHIT || character[chrIndex].View == ENEMY1HIT || character[chrIndex].View == ENEMY2HIT || character[chrIndex].View == ENEMY3HIT ) {
frame = Game.GetViewFrame(character[chrIndex].View, character[chrIndex].Loop, 0);
} else {
frame = Game.GetViewFrame(character[chrIndex].View, character[chrIndex].Loop, character[chrIndex].Frame);
}
DynamicSprite *sprite;
int graphic = frame.Graphic;
if (frame.Flipped)
Expand Down
43 changes: 42 additions & 1 deletion Game.agf
Original file line number Diff line number Diff line change
Expand Up @@ -1998,7 +1998,48 @@
</CharacterFolder>
<CharacterFolder Name="Enemy3">
<SubFolders />
<Characters />
<Characters>
<Character>
<ID>26</ID>
<ScriptName>cChar1</ScriptName>
<RealName xml:space="preserve">New character</RealName>
<NormalView>1</NormalView>
<SpeechView>0</SpeechView>
<IdleView>0</IdleView>
<ThinkingView>0</ThinkingView>
<BlinkingView>0</BlinkingView>
<StartingRoom>-1</StartingRoom>
<StartX>160</StartX>
<StartY>120</StartY>
<UniformMovementSpeed>True</UniformMovementSpeed>
<MovementSpeed>3</MovementSpeed>
<MovementSpeedX>0</MovementSpeedX>
<MovementSpeedY>0</MovementSpeedY>
<AnimationDelay>4</AnimationDelay>
<SpeechAnimationDelay>5</SpeechAnimationDelay>
<SpeechColor>12</SpeechColor>
<Solid>True</Solid>
<Clickable>True</Clickable>
<UseRoomAreaScaling>True</UseRoomAreaScaling>
<UseRoomAreaLighting>True</UseRoomAreaLighting>
<TurnBeforeWalking>True</TurnBeforeWalking>
<DiagonalLoops>True</DiagonalLoops>
<AdjustSpeedWithScaling>False</AdjustSpeedWithScaling>
<AdjustVolumeWithScaling>False</AdjustVolumeWithScaling>
<MovementLinkedToAnimation>True</MovementLinkedToAnimation>
<Properties />
<Interactions>
<Event Index="0" />
<Event Index="1" />
<Event Index="2" />
<Event Index="3" />
<Event Index="4" />
<Event Index="5" />
<Event Index="6" />
<Event Index="7" />
</Interactions>
</Character>
</Characters>
</CharacterFolder>
</SubFolders>
<Characters>
Expand Down
63 changes: 38 additions & 25 deletions Gameatic.asc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Timer * t_killMember;
Timer * t_enemy2[APROXCHAR]; //time throwing
Timer * t_enemy2_whenToStartThrow[APROXCHAR]; //this number is only big enough to not crash
bool enemy2_didthrow[APROXCHAR]; //time throwing
Timer * t_afterTookHit;

int destination_left;
int destination_right;
Expand Down Expand Up @@ -34,7 +35,7 @@ void checkWinCondition(){
}

bool isDogWithBonne(){
return cDog.View == DOGIDDLE2 || cDog.View == DOGWALK2 ;
return (player.View == DOGIDDLE2 || player.View == DOGWALK2 || player.NormalView == DOGWALK2) ;
}

bool isCharEnemy1(Character * enemy){
Expand All @@ -56,16 +57,16 @@ bool isCharEnemy2(Character * enemy){

void dogGainsBone(){
if(!isDogWithBonne()){
cDog.ChangeView(DOGWALK2);
cDog.SetIdleView(DOGIDDLE2, 1);
player.ChangeView(DOGWALK2);
player.SetIdleView(DOGIDDLE2, 1);
KeyboardMovement.SetIdleView(DOGIDDLE2, 1);
}
}

void dogLooseBone(){
if(isDogWithBonne()){
cDog.ChangeView(DOGWALK1);
cDog.SetIdleView(DOGIDDLE1, 1);
player.ChangeView(DOGWALK1);
player.SetIdleView(DOGIDDLE1, 1);
KeyboardMovement.SetIdleView(DOGIDDLE1, 1);
}
}
Expand Down Expand Up @@ -100,18 +101,26 @@ void dogHitBonePile(){
}
}

void rightAfterTookHit(){
player.UnlockView();
player.ChangeView(DOGWALK1);
player.SetIdleView(DOGIDDLE1, 1);
KeyboardMovement.SetIdleView(DOGIDDLE1, 1);
}

void dogTookEnemyHit(){
if(player.View == DOGTOOKHIT){
return;
}

bool waswithbone = isDogWithBonne();

cDog.LockView(DOGTOOKHIT, eStopMoving);
player.LockView(DOGTOOKHIT, eStopMoving);
if(waswithbone){
SpawnBone(cDog.x+20, cDog.y+20);
SpawnBone(player.x+20, player.y+20);
}
cDog.TweenY(0.6, 284, eEaseInElasticTween, eBlockTween);
cDog.UnlockView();
cDog.ChangeView(DOGWALK1);
cDog.SetIdleView(DOGIDDLE1, 1);
KeyboardMovement.SetIdleView(DOGIDDLE1, 1);
player.TweenY(0.6, 284, eEaseInElasticTween, eNoBlockTween);
t_afterTookHit = Timer.StartRT(0.6, eOnce);
}

void testDogBoneCollision(){
Expand All @@ -120,7 +129,7 @@ void testDogBoneCollision(){
return;
}

if(cDog.View == DOGTOOKHIT || cDog.View == DOGWALK2 || cDog.View == DOGIDDLE2){
if(player.View == DOGTOOKHIT || player.View == DOGWALK2 || player.View == DOGIDDLE2){
//a hitted dog, or a dog that already has a bone, can't collect a new bone
return;
}
Expand Down Expand Up @@ -185,7 +194,7 @@ void splashArmsLegs(Character * enemy){


void ChompEnemy(Character * enemy){
if(cDog.NormalView == DOGWALK2){
if(player.NormalView == DOGWALK2){
return;
}

Expand All @@ -199,15 +208,15 @@ void ChompEnemy(Character * enemy){
enemy.LockView(ENEMY2HIT, eStopMoving);
}

gBlood.SetPosition(cDog.x - x_off, cDog.y - y_off);
gBlood.SetPosition(player.x - x_off, player.y - y_off);

gBlood.Visible = true;
gBlood.BackgroundGraphic = 66;
gBlood.LockView(VIEWBLOOD);
gBlood.Animate(0, 1, eOnce, eNoBlock, eForwards);

gFakeOverlay.BackgroundGraphic = 1;
gFakeOverlay.SetPosition(cDog.x - x_off, cDog.y - y_off);
gFakeOverlay.SetPosition(player.x - x_off, player.y - y_off);
gFakeOverlay.Visible = true;
Wait(chomp_delay);

Expand Down Expand Up @@ -237,26 +246,26 @@ void DoChompOrHit(Character * enemy){
return;
}

if((cDog.Loop == 1 && (cDog.Moving == false && !KeyboardMovement.Moving() )) &&
if((player.Loop == 1 && (player.Moving == false && !KeyboardMovement.Moving() )) &&
(enemy.DestinationX == destination_left && enemy.Moving)){
// dog is stopped looking left &
// enemy is going left

dogTookEnemyHit();
return;

} else if((cDog.Loop != 1 && (cDog.Moving == false && !KeyboardMovement.Moving() )) &&
} else if((player.Loop != 1 && (player.Moving == false && !KeyboardMovement.Moving() )) &&
(enemy.DestinationX == destination_right && enemy.Moving)){
// dog is stopped looking right &
// enemy is going right

dogTookEnemyHit();
return;
} else if((cDog.Loop == 1 && (cDog.Moving == false || KeyboardMovement.Moving() ))){
} else if((player.Loop == 1 && (player.Moving == false || KeyboardMovement.Moving() ))){

ChompEnemy(enemy);
return;
} else if((cDog.Loop != 1 && (cDog.Moving == false || KeyboardMovement.Moving() ))){
} else if((player.Loop != 1 && (player.Moving == false || KeyboardMovement.Moving() ))){

ChompEnemy(enemy);
return;
Expand All @@ -278,7 +287,7 @@ void dealWithEnemy1(Character * enemy1){
enemy1.AddWaypoint(destination_left , enemy1.y);
}

if(enemy1.IsCollidingWithChar(cDog)){
if(enemy1.IsCollidingWithChar(player)){
DoChompOrHit(enemy1);
}
}
Expand Down Expand Up @@ -355,13 +364,13 @@ void dealWithEnemy2(Character * enemy2){
}


if(enemy2.IsCollidingWithChar(cDog)){
if(enemy2.IsCollidingWithChar(player)){
DoChompOrHit(enemy2);
}
}

void checkBonePileRepExe(){
if(cBonePile.IsCollidingWithChar(cDog)){
if(cBonePile.IsCollidingWithChar(player)){
dogHitBonePile();
}
}
Expand All @@ -375,14 +384,18 @@ void init_enemy2(Character * enemy2){
enemy2.AddWaypoint(destination_left, enemy2.y);
}

void repeatedly_execute(){
void repeatedly_execute_always(){
Character * aLetter = whichLetterCollided();
if(aLetter!=null){
dogTookEnemyHit();
}

testDogBoneCollision();


if(t_afterTookHit != null && t_afterTookHit.EvtExpired){
rightAfterTookHit();
}

if(t_killMember!=null && t_killMember.EvtExpired){
gLegs1.UnlockView();
gLegs2.UnlockView();
Expand Down

0 comments on commit fac26fc

Please sign in to comment.