Category : C Source Code
Archive   : YICONS24.ZIP
Filename : AMAPDEMO.CPP

 
Output of file : AMAPDEMO.CPP contained in archive : YICONS24.ZIP

#include "xlib.h"
#include "xtext.h"
#include "xrect.h"
#include
#include
#include
#include
#include "animap.h"
#include "actor.h"
#include "event.h"
#include "factor.h"
#include "fevent.h"
#include "yakPal.h"
#include "yakkeys.h"


#define FLOORHEIGHT 40
void getKeys(factor & thisFactor)
{
int xMom =0, yMom=0;
if (keyboard.keys[yakKeyboard::upArrow])
yMom -= 4;
if (keyboard.keys[yakKeyboard::downArrow])
yMom +=4;
if (keyboard.keys[yakKeyboard::leftArrow])
xMom -=4;
if (keyboard.keys[yakKeyboard::rightArrow])
xMom +=4;
if (xMom || yMom)
thisFactor.addCommand(scriptNode::fineMoveRel, 0,0,xMom,yMom);
else
thisFactor.addCommand(scriptNode::doNothing, 0,0,0,0);
}

void amapDemo(void)
{
keyboard.install();
yakLib myYakLib("yakdemo");
randomize();
x_set_mode(0, 380);
x_set_splitscreen(125);
x_set_doublebuffer(260);
yakPalette myYakPalette("standard.ypl", &myYakLib);
myYakPalette.put();
animap backgroundMap(4, 24, 25, 25);
backgroundMap.loadIcon(0, "grass", &myYakLib);
backgroundMap.loadIcon(1, "valley", &myYakLib);
backgroundMap.loadIcon(2, "water", &myYakLib);
backgroundMap.loadIcon(3, "mountain", &myYakLib);
backgroundMap.randomize();
factor myActor;
factor::loadFactor(0,"", "", "", "", "lgrumjug", "cgrumjug", "grumjug", "", "", "", &myYakLib);
myActor.assignIcon(0, factor::twoFace);
myActor.mapX = myActor.mapY = myActor.squareX = myActor.squareY = 10;
myActor.mymap = &backgroundMap;
myActor.put(myActor.mapX, myActor.mapY);
backgroundMap.showXY(myActor.mapX-4,myActor.mapY-2, 48, 48, 15,7, HiddenPageOffs);
x_page_flip(24 + myActor.squareX, 24+myActor.squareY);
backgroundMap.showXY(myActor.mapX-4,myActor.mapY-2, 48, 48, 15,7, HiddenPageOffs);
while (!keyboard.keys[yakKeyboard::escape])
{
backgroundMap.drawXY(myActor.mapX-6,myActor.mapY-3, 48, 48, 15,7, HiddenPageOffs);
x_page_flip(24 + myActor.squareX, 24+myActor.squareY);
x_bgprintf(10,10,SplitScrnOffs,15,20,"MapX %d***Mapy %d ", myActor.mapX, myActor.mapY);
x_bgprintf(10,30,SplitScrnOffs,15,20,"SquX %d***Squy %d ", myActor.squareX, myActor.squareY);
x_bgprintf(10,50,SplitScrnOffs,15,20,"lasX %d***lasy %d ", myActor.lastMapX, myActor.lastMapY);
backgroundMap.advance();
getKeys(myActor);
}
keyboard.remove();
factor::clearFactor(0);
}