Untitled

 avatar
unknown
plain_text
a month ago
2.1 kB
3
Indexable
HarnessMovingStart

direction = 1;				// set direction to 'right'
oldDirection = direction;
moveStartP.move(direction).send();


*****Enemy Alive Selfloop

if (atBottom()){
	logP.log("[E(%d)]\t reached bottom ", id);
	endGameP.playerLoses().send();
}

if (dead) {
	logP.log("[E(%d)]\t dead enemy received moveEndP ", id);
};


direction = *rtdata; // Use received direction instead of old direction
//logP.log("[E(%d)]\t enemy is receiving movePrevP with direction %d", id, direction);

if (!dead){
Shape shape;
shape = createInvisibleShape(x,y,w,h);
renderP.render(shape).send();

updateLocation();

shape = createVisibleShape(x,y,w,h,r,g,b);
renderP.render(shape).send();



if (direction != 0) {
    if ((direction > 0 && atRightBorder()) || (direction < 0 && atLeftBorder())) {
    logP.log("[E(%d)]\t enemy has reached right %d or left  %d", id,  atRightBorder(),atLeftBorder()  );
        // Only trigger if this enemy is at the extreme (optionally, check for a designated enemy, e.g., id==54 for right or id==0 for left)
        harnessP.changeDirection(0).send();

    }
}
}
timingP.informIn(RTTimespec(0, PROPAGATION_DELAY));


****harness Change direction
newDirection = *rtdata;
logP.log("=======[eHarness(1)]\t  received newDirection %d==========  ", newDirection);

oldDirection = direction;

**** Harness moveEndP
//newDirection = *rtdata;
int lastEnemyDirection = *rtdata;
logP.log("[====eHarness(1)]\t  received movenext with lastEnemyDirection %d , old direction %d and newDirection set in CD is %d", lastEnemyDirection, oldDirection, newDirection);


if (newDirection == 0 && lastEnemyDirection != 0) {
		direction = 0;
		newDirection = -oldDirection;
	}
else if (newDirection != 0 && lastEnemyDirection == 0) {
    direction = -oldDirection;
    //oldDirection = direction;
    //moveStartP.move(direction).send();


}

moveStartP.move(direction).send();


//logP.log("[eHarness(1)]\t  received movenext with newdirection %d and old direction %d", newDirection, oldDirection);
//timingP.informIn(RTTimespec(1, 0));  // Continue movement cycle


Editor is loading...
Leave a Comment