void main() {
//debug(getViewportZRotation()+":"+getViewportXRotation()+":"+getViewportYRotation());
//changeMap(1, 7);
int mouseX=getMouseScreenX();
int mouseY=getMouseScreenY();
int mouseWorldX=getMouseWorldX();
int mouseWorldY=getMouseWorldY();
int mouseWorldZ=getMouseWorldZ();
drawRectangle(125, 1, 50, 50, 255,255,255,255);
drawText("Move","Lucida Console", 10,140,20,255,0,0,255);
drawText("Forward","Lucida Console", 10,135,30,255,0,0,255);
drawText("SX:" +mouseX+" SY:"+mouseY+" MouseX:"+mouseWorldX+" Y:"+mouseWorldY+" Z:"+mouseWorldZ,"Lucida Console",12,10,50,255,0,0,255);
boolean isDown=getMouseDown();
boolean isClicked=getMouseClicked();
if (isDown) {
int xPos=getGlobal("xPos");
int yPos=getGlobal("yPos");
int zPos=getViewportZRotation();
float angle=90.0;
angle=angle-(zPos);
if (mouseX>120 && mouseX<175 && mouseY<50) {
//move forward
xPos=intValue((cos(angle)*3.0))+xPos;
yPos=intValue(((-1)*sin(angle)*3.0))+yPos;
setGlobal("xPos", xPos); setGlobal("yPos", yPos);
}
/* if (getGlobal("down")==1) {
xPos=xPos-intValue((cos(angle)*3.0));
yPos=yPos-intValue(((-1)*sin(angle)*3.0));
}*/
}
if (isClicked) {
setGlobal("downage", "");
}
//fillRectangle(mouseX,mouseY,8,8,255,255,255,255);
setGlobal("scriptExecute", "true");
int spriteTotal=getGlobal("data-spriteCount");
//int objectTotal=getGlobal("data-objectCount");
string spriteVarName[]={"script", "image", "frame", "passness", "Z3D", "xRot", "yRot", "height", "width", "depth", "offscreenProcessing", "X", "Y", "renderType", "autoCollide", "ZOffset", "object", "repeatTexture"};
int spriteVarSize[]={ 3, 2, 1, 1, 2, 3, 3, 4, 4, 4, 1, 4, 4, 1, 1, 4, 3, 1};
int spriteVarCount=18;
int hero=getGlobal("hero");
if (getGlobal("menu")=="true") {
drawText("Camera: WASD, E to move forward, Q to move backwards.","Lucida Console",10,0,10,0,255,0,255);
drawText("C: Create sprite, X: Destroy sprite","Lucida Console",10,0,20,0,255,0,255);
drawText("F: Change frame, I: Change image, H: Change script","Lucida Console",10,0,30,0,255,0,255);
drawText("L: Set repeatTexture(), P: Change Render Type",10,0,40,0,255,0,255);
drawText("Enter: saves selected sprite's data","Lucida Console",10,0,50,0,255,0,255);
drawText("Hold and use arrow keys for the following:","Lucida Console",10,0,60,0,255,0,255);
drawText("R: rotate selected sprite","Lucida Console",10,0,70,0,255,0,255);
drawText("Z: change Z Coordinate of selected sprite","Lucida Console",10,0,80,0,255,0,255);
drawText("O: change ZOffset of selected sprite","Lucida Console",10,0,90,0,255,0,255);
drawText("Shift: switch between saved sprites","Lucida Console",10,0,100,0,255,0,255);
drawText("T,Y, or U: change Height,Width, or Depth","Lucida Console",10,0,110,0,255,0,255);
}
while(getKeyUpCount()>0){
int key=getNextKeyUp();
debug(char(key)+":"+key);
if (key==getGlobal("buttonHoldKey")){ setGlobal("buttonHold", ""); setGlobal("buttonHoldKey", 0); }
setGlobal("addx",0);
setGlobal("addy",0);
setGlobal("xRotAdd", 0);
setGlobal("yRotAdd", 0);
setGlobal("zRotAdd", 0);
setGlobal("xPosAdd", 0);
setGlobal("yPosAdd", 0);
setGlobal("right", 0);
setGlobal("down", 0);
setGlobal("up", 0);
setGlobal("left", 0);
setGlobal("spriteRotateX", 0);
setGlobal("spriteRotateY", 0);
setGlobal("spriteHeight", 0);
setGlobal("spriteWidth", 0); setGlobal("spriteDepth", 0);
setGlobal("spriteZOffset", 0);
setGlobal("terrainHeight+", 0);
//setGlobal("spriteZ", 0);
}
while(getKeyDownCount()>0){
int key=getNextKeyDown();
if (key==92){// \
//create Object(loop through sprites)
}
if (key==67){//C
if (getGlobal("hero")==-1 || getGlobal("hero")==0) {
int s=createSprite(0,1,200,200,0);
//setGlobal("spriteIDs", getGlobal("spriteIDs")+appendDigits(s+"", 4));
//setWidth(s,24);
//setHeight(s,30);
setXRotation(s,90);
setAutoCollide(s,false);
setZOffset(s,0);
setRenderType(s, 0);
setHeight(s, 32);
setWidth(s, 32);
setDepth(s, 32);
setGlobal("hero",s);
setGlobal("walkFrame",0);
setGlobal("initialFrame",0);
setGlobal("addx",0);
setGlobal("addy",0);
setGlobal("heroL", getGlobal("data-spriteCount")+1);
setGlobal("sprite-ZOffset", 0);
setGlobal("sprite-script", 1);
setGlobal("sprite-image", 0);
setGlobal("sprite-frame", 0);
setGlobal("sprite-passness", 1);
setGlobal("sprite-Z3D", 0);
setGlobal("sprite-xRot", 90);
setGlobal("sprite-yRot", 0);
setGlobal("sprite-height", 32);
setGlobal("sprite-width", 32);
setGlobal("sprite-depth", 32);
setGlobal("sprite-offscreenProcessing", 0);
setGlobal("sprite-Y", 200);
setGlobal("sprite-X", 200);
setGlobal("sprite-renderType", 0);
setGlobal("sprite-autoCollide", 0);
setGlobal("sprite-repeatTexture", 0);
}
}
if (key==88){//X
if (getGlobal("hero")>-1 && getGlobal("loaded-"+getGlobal("hero"))=="true") {
int spriteN=getGlobal("hero");
int L=spriteL(spriteN);
debug("Delete sprite: "+spriteN+" L:"+L);
if (spriteN>0) {
for(int t=0;t<spriteVarCount;t++) {
debug("data-"+spriteVarName[t]+":"+getGlobal("data-"+spriteVarName[t]));
debug("Removed "+spriteN+":"+updateValue(getGlobal("data-"+spriteVarName[t]), "", L));
setGlobal("data-"+spriteVarName[t], updateValue(getGlobal("data-"+spriteVarName[t]), "", L));
setGlobal("sprite-"+spriteVarName[t], "");
}
setGlobal("data-spriteCount", intValue(getGlobal("data-spriteCount"))-1);
}
}
setGlobal("spriteIDs", replaceAll(getGlobal("spriteIDs"), appendDigits(spriteN+"", 4)+"", ""));
//destroySprite(getGlobal("hero"));
//killSprite(spriteN);
//destroySprite(spriteN);
//if (getGlobal("hero")==getGlobal("lastSprite")) setGlobal("lastSprite", getGlobal("lastSprite")-1);
setGlobal("addx",0);
setGlobal("addy",0);
setGlobal("hero",-1);
setGlobal("loadData", "false");
changeMap(0, 0);
}
if (key==16){//shift
setGlobal("buttonHold", "shift");
setGlobal("buttonHoldKey", 16);
}
if (key==192){//`~
string menu=getGlobal("menu");
if (menu!="true") setGlobal("menu", "true");
if (menu=="true") setGlobal("menu", "false");
}
if (key==10){//Save sprite data
string truth=getGlobal("loaded-"+getGlobal("hero"));
if (getGlobal("hero")>0) {
if (truth!="true") {
debug("Adding data for "+getGlobal("hero"));
for(int t=0;t<=spriteVarCount;t++) {
string adding=intValue(getGlobal("sprite-"+spriteVarName[t]))+"";
debug("Adding Data:"+spriteVarName[t]+":"+appendDigits(adding, spriteVarSize[t]));
setGlobal("data-"+spriteVarName[t], getGlobal("data-"+spriteVarName[t])+appendDigits(adding, spriteVarSize[t]));
}
setGlobal("data-spriteCount", getGlobal("data-spriteCount")+1);
spriteTotal++;
setGlobal("lastSprite", getGlobal("hero"));
setGlobal("spriteIDs", getGlobal("spriteIDs")+appendDigits(getGlobal("hero")+"", 4)+char(92));
setGlobal("loaded-"+getGlobal("hero"), "true");
}
if (truth=="true") {
int sN=getGlobal("hero");
int L=getGlobal("heroL");
for(int t=0;t<=spriteVarCount;t++) {
string adding=intValue(getGlobal("sprite-"+spriteVarName[t]))+"";
//debug("Updating Data:"+spriteVarName[t]+":"+appendDigits(adding, spriteVarSize[t]));
//debug(":"+getGlobal("data-"+spriteVarName[t]));
setGlobal("data-"+spriteVarName[t], updateValue(getGlobal("data-"+spriteVarName[t]), appendDigits(adding,spriteVarSize[t]), L));
}
}
}
setMask(getGlobal("hero"), 255, 255, 255, 255);
setGlobal("hero", -1);
save("spriteCount", getGlobal("data-spriteCount"), "script", getGlobal("data-script"), "image",getGlobal("data-image"), "frame", getGlobal("data-frame"), "passness", getGlobal("data-passness"), "Z3D", getGlobal("data-Z3D")+"", "xRot", getGlobal("data-xRot"), "yRot", getGlobal("data-yRot"), "height", getGlobal("data-height"), "width",getGlobal("data-width"), "depth", getGlobal("data-depth"), "offscreenProcessing",getGlobal("data-offscreenProcessing"), "X", getGlobal("data-X"), "Y", getGlobal("data-Y"), "renderType", getGlobal("data-renderType"), "autoCollide", getGlobal("data-autoCollide"), "ZOffset", getGlobal("data-ZOffset"), "object", getGlobal("data-object"), "repeatTexture", getGlobal("data-repeatTexture"));
}
//RIGHT
if(key==39){
if (getGlobal("buttonHold")=="") {
setGlobal("addx",1);
setGlobal("initialFrame",3);
}
else { setGlobal(getGlobal("buttonHold")+"Y", 1); }
}
//UP
if(key==38){
if (getGlobal("buttonHold")=="") {
setGlobal("addy",-1);
setGlobal("initialFrame",0);
}
else {
if (getGlobal("buttonHold")=="spriteRotate") setGlobal(getGlobal("buttonHold")+"X", 1);
if (getGlobal("buttonHold")=="spriteZ") setGlobal("spriteZ", 1);
if (getGlobal("buttonHold")=="spriteHeight") setGlobal("spriteHeight", 1);
if (getGlobal("buttonHold")=="spriteWidth") setGlobal("spriteWidth", 1);
if (getGlobal("buttonHold")=="spriteDepth") setGlobal("spriteDepth", 1);
if (getGlobal("buttonHold")=="spriteZOffset") setGlobal("spriteZOffset", 1);
if (getGlobal("buttonHold")=="terrainHeight") { setGlobal("terrainHeight+", 1); }
if (getGlobal("buttonHold")=="spriteObject") {
setGlobal("sprite-object", getGlobal("sprite-object")+1);
int object=getGlobal("sprite-object");
int objectN=getGlobal("Object-spriteCount:"+object)+1;
setGlobal("Object-spriteCount:"+object, objectN);
setGlobal("Object:"+object+":"+objectN, hero);
}
if (getGlobal("buttonHold")=="shift") {
int heroNumber=getGlobal("hero");
int totalSpriteNs=parseInt(substr(getGlobal("spriteIDs"),strlen(getGlobal("spriteIDs"))-5, strlen(getGlobal("spriteIDs"))-1));
if (getGlobal("data-spriteCount")>0 && heroNumber<=totalSpriteNs) {
setMask(heroNumber, 255, 255, 255, 255);
int ID=getGlobal("hero")+1;
int check=indexOf(getGlobal("spriteIDs"), appendDigits(ID+"", 4)+char(92), 0);
while(check==-1) { ID++; check=indexOf(getGlobal("spriteIDs"), appendDigits(ID+"", 4)+char(92), 0); }
setGlobal("hero", ID);
setMask(getGlobal("hero"), 255, 255, 255, 200);
int sN=getGlobal("hero");
setGlobal("addx",0);
setGlobal("addy",0);
int L=(check)/5; L++;
setGlobal("heroL", L);
for(int t=0;t<=spriteVarCount;t++) {
debug("Loading sprite data:"+spriteVarName[t]+":"+mapIntValue(getGlobal("data-"+spriteVarName[t]), L));
setGlobal("sprite-"+spriteVarName[t], mapIntValue(getGlobal("data-"+spriteVarName[t]), L));
}
debug(L+":"+check);
debug("total:"+totalSpriteNs);
}
}
}
}
//LEFT
if(key==37){
if (getGlobal("buttonHold")=="") {
setGlobal("addx",-1);
setGlobal("initialFrame",3);
}
else { setGlobal(getGlobal("buttonHold")+"Y", -1); }
}
//DOWN.
if(key==40){
if (getGlobal("buttonHold")=="") {
setGlobal("addy",1);
setGlobal("initialFrame",0);
}
else {
if (getGlobal("buttonHold")=="spriteRotate") setGlobal(getGlobal("buttonHold")+"X", -1);
if (getGlobal("buttonHold")=="spriteZ") setGlobal("spriteZ", -1);
if (getGlobal("buttonHold")=="spriteHeight") setGlobal("spriteHeight", -1);
if (getGlobal("buttonHold")=="spriteWidth") setGlobal("spriteWidth", -1);
if (getGlobal("buttonHold")=="spriteDepth") setGlobal("spriteDepth", -1);
if (getGlobal("buttonHold")=="spriteZOffset") setGlobal("spriteZOffset", -1);
if (getGlobal("buttonHold")=="terrainHeight") { setGlobal("terrainHeight+", -1); }
if (getGlobal("buttonHold")=="spriteObject" && getGlobal("sprite-object")>0) {
setGlobal("sprite-object", getGlobal("sprite-object")-1);
int object=getGlobal("sprite-object");
int objectN=getGlobal("Object-spriteCount:"+object)+1;
setGlobal("Object-spriteCount:"+object, objectN);
setGlobal("Object:"+object+":"+objectN, hero);
setGlobal("ObjectX:"+hero, getX(hero));
setGlobal("ObjectY:"+hero, getY(hero));
}
if (getGlobal("buttonHold")=="shift") {
if (getGlobal("lastSprite")>0 && getGlobal("hero")>0) {
setMask(getGlobal("hero"), 255, 255, 255, 255);
int ID=getGlobal("hero")-1;
int check=indexOf(getGlobal("spriteIDs"), appendDigits(ID+"", 4)+char(92), 0);
while (check==-1) { ID--; check=indexOf(getGlobal("spriteIDs"), appendDigits(ID+"", 4)+char(92), 0); }
setGlobal("hero", ID);
setMask(getGlobal("hero"), 255, 255, 255, 200);
int sN=getGlobal("hero");
setGlobal("addx",0);
setGlobal("addy",0);
int L=(check)/5; L++;
setGlobal("heroL", L);
for(int t=0;t<=spriteVarCount;t++) {
debug("Loading sprite data:"+spriteVarName[t]+":"+mapIntValue(getGlobal("data-"+spriteVarName[t]), L));
setGlobal("sprite-"+spriteVarName[t], mapIntValue(getGlobal("data-"+spriteVarName[t]), L));
}
debug(L+":"+check);
}
}
}
}
//W
if(key==87){
setGlobal("xRotAdd", -1);
}
//S
if(key==83){
setGlobal("xRotAdd", 1);
}
//A
if(key==65){
setGlobal("zRotAdd", -1);
}
//D
if(key==68){
setGlobal("zRotAdd", 1);
}
//Q
if(key==81){
//setGlobal("yRotAdd", 1);
setGlobal("down", 1);
}
//E
if(key==69){
//setGlobal("yRotAdd", -1);
setGlobal("up", 1);
}
if (key==82){//R
setGlobal("buttonHold", "spriteRotate");
setGlobal("buttonHoldKey", 82);
//setGlobal("spriteRotateX", 1);
}
if (key==70){//F
if (getFrame(hero)<7) { setFrame(hero,getFrame(hero)+1); setGlobal("sprite-frame", getFrame(hero)); }
else { setFrame(hero, 0); setGlobal("sprite-frame", 0); }
}
if (key==84){//T
setGlobal("buttonHold", "spriteHeight");
setGlobal("buttonHoldKey", 84);
//setGlobal("spriteHeight", 1);
}
if (key==90){//Z
setGlobal("buttonHold", "spriteZ");
setGlobal("buttonHoldKey", 90);
}
if (key==89){//Y
setGlobal("buttonHold", "spriteWidth");
setGlobal("buttonHoldKey", 89);
}
if (key==85){//U
setGlobal("buttonHold", "spriteDepth");
setGlobal("buttonHoldKey", 85);
}
if (key==73){//I
if (getImage(hero)<getGlobal("imageMax")) { setImage(hero,getImage(hero)+1); setGlobal("sprite-image", getImage(hero)); }
else { setImage(hero, 0); setGlobal("sprite-image", 0); }
}
if (key==79){//O
setGlobal("buttonHold", "spriteZOffset");
setGlobal("buttonHoldKey", 79);
}
if (key==80){//P
if (getGlobal("sprite-renderType")<2) { setRenderType(hero,getGlobal("sprite-renderType")+1); setGlobal("sprite-renderType", getGlobal("sprite-renderType")+1); }
else { setRenderType(hero, 0); setGlobal("sprite-renderType", 0); }
}
if (key==91){//[
setGlobal("buttonHold", "spriteObject");
setGlobal("buttonHoldKey", 91);
}
if (key==76) { //L
string texture=getGlobal("sprite-repeatTexture");
if (texture==0 || texture=="") { setRepeatTexture(hero, true); setGlobal("sprite-repeatTexture", 1); }
if (texture==1) { setRepeatTexture(hero, false); setGlobal("sprite-repeatTexture", 0); }
//if (getScript(hero)<2) { setScript(hero,getScript(hero)+1); setGlobal("sprite-script", getScript(hero)); }
//else { setScript(hero, 1); setGlobal("sprite-script", 1); }
}
if (key==72){//H
if (getScript(hero)!=8) { setScript(hero, 8); setGlobal("sprite-script", 8); }
else { setScript(hero, 1); setGlobal("sprite-script", 1); }
}
}
if (getGlobal("terrainHeight+")!=0) {
setGlobal("terrainHeight", getGlobal("terrainHeight")+(getGlobal("terrainHeight+"))); setTerrain(getGlobal("terrainHeight"), 10, 32);
}
if (getGlobal("spriteRotateX")!=0) {
setXRotation(hero, getXRotation(hero)+getGlobal("spriteRotateX"));
if (getXRotation(hero)<0) setXRotation(hero, getXRotation(hero)+360);
if (getXRotation(hero)>=360) setXRotation(hero, getXRotation(hero)-360);
setGlobal("sprite-xRot", getXRotation(hero));
}
if (getGlobal("spriteRotateY")!=0) {
setYRotation(hero, getYRotation(hero)+getGlobal("spriteRotateY"));
if (getYRotation(hero)<0) setYRotation(hero, getYRotation(hero)+360);
if (getYRotation(hero)>=360) setYRotation(hero, getYRotation(hero)-360);
setGlobal("sprite-yRot", getYRotation(hero));
}
if (getGlobal("spriteZ")!=0) {
setZ(hero, getZ(hero)+getGlobal("spriteZ"));
setGlobal("sprite-Z3D", getZ(hero));
/*if (hero>0) {
setGlobal("data-Z3D", updateValue(getGlobal("data-Z3D"), intValue(appendDigits(intValue(getZ(hero))+"",2)), hero));
if (getGlobal("sprite-object")>0) {
for(int t=1;t<=getGlobal("Object-spriteCount:"+getGlobal("sprite-object"));t++) {
int sN=getGlobal("Object:"+getGlobal("sprite-object")+":"+t);
if (sN!=hero) {
//int value=mapIntValue(getGlobal("data-Z3D"), sN);
setZ(sN, getZ(sN)+getGlobal("spriteZ"));
setGlobal("data-Z3D", updateValue(getGlobal("data-Z3D"), appendDigits(intValue(getZ(sN))+"",2), sN));
}
}
}
}*/
setGlobal("spriteZ", 0);
}
if (getGlobal("spriteHeight")!=0) {
int z=getGlobal("sprite-height");
int zz=getGlobal("spriteHeight");
setHeight(hero, z+zz);
setGlobal("sprite-height", z+zz);
}
if (getGlobal("spriteWidth")!=0) {
int z=getGlobal("sprite-width");
int zz=getGlobal("spriteWidth");
setWidth(hero, z+zz);
setGlobal("sprite-width", z+zz);
}
if (getGlobal("spriteDepth")!=0) {
int z=getGlobal("sprite-depth");
int zz=getGlobal("spriteDepth");
setDepth(hero, z+zz);
setGlobal("sprite-depth", z+zz);
}
if (getGlobal("spriteZOffset")!=0) {
int z=getGlobal("sprite-ZOffset");
int zz=getGlobal("spriteZOffset");
setZOffset(hero, z+zz);
setGlobal("sprite-ZOffset", z+zz);
}
if (getGlobal("xRotAdd")!=0) {
int Rotation=getViewportXRotation();
int RotAdd=getGlobal("xRotAdd");
setGlobal("xRotation", Rotation+RotAdd);
setViewportXRotation(Rotation+RotAdd);
}
if (getGlobal("yRotAdd")!=0) {
int Rotation=getViewportYRotation();
int RotAdd=getGlobal("yRotAdd");
setGlobal("yRotation", Rotation+RotAdd);
setViewportYRotation(Rotation+RotAdd);
}
if (getGlobal("zRotAdd")!=0) {
int Rotation=getViewportZRotation();
int RotAdd=getGlobal("zRotAdd");
int newR=Rotation+RotAdd;
if (newR > 360) newR=newR-360;
if (newR <= 0) newR=newR+360;
setGlobal("zRotation", newR);
setViewportZRotation(newR); //<--- Turning left and right
//setViewportZ(Rotation+RotAdd); <--- Moves camera up and down
}
int xPos=getGlobal("xPos");
int yPos=getGlobal("yPos");
int zPos=getViewportZRotation();
float angle=90.0;
angle=angle-(zPos);
xPos=getGlobal("xPos");
yPos=getGlobal("yPos");
if (getGlobal("up")==1) {
xPos=intValue((cos(angle)*3.0))+xPos;
yPos=intValue(((-1)*sin(angle)*3.0))+yPos;
}
if (getGlobal("down")==1) {
xPos=xPos-intValue((cos(angle)*3.0));
yPos=yPos-intValue(((-1)*sin(angle)*3.0));
}
int addx=getGlobal("addx");
int addy=getGlobal("addy");
setGlobal("xPos", xPos);
setGlobal("yPos", yPos);
setX(hero,getX(hero)+addx);
setY(hero,getY(hero)+addy);
setGlobal("sprite-X", getX(hero));
setGlobal("sprite-Y", getY(hero));
/*if ((addx!=0 || addy!=0) && hero>0) {
setGlobal("data-X", updateValue(getGlobal("data-X"), appendDigits(intValue(getX(hero))+"",4), hero));
setGlobal("data-Y", updateValue(getGlobal("data-Y"), appendDigits(intValue(getY(hero))+"",4), hero));
if (getGlobal("sprite-object")>0) {
for(int t=1;t<=getGlobal("Object-spriteCount:"+getGlobal("sprite-object"));t++) {
int sN=getGlobal("Object:"+getGlobal("sprite-object")+":"+t);
if (sN!=hero) {
//int value=mapIntValue(getGlobal("data-X"), sN);
//int value2=mapIntValue(getGlobal("data-Y"), sN);
setX(sN, getX(sN)+addx);
setY(sN, getY(sN)+addy);
setGlobal("data-X", updateValue(getGlobal("data-X"), appendDigits(intValue(getX(sN))+"",4), sN));
setGlobal("data-Y", updateValue(getGlobal("data-Y"), appendDigits(intValue(getY(sN))+"",4), sN));
}
}
}
}*/
setViewportX(getX(hero)+xPos);
setViewportY(getY(hero)+200+yPos);
drawText("spriteN:"+hero+" script:"+getGlobal("sprite-script")+" image:"+getGlobal("sprite-image")+" frame:"+getGlobal("sprite-frame")+" X:"+getGlobal("sprite-X")+" Y:"+getGlobal("sprite-Y")+" Z3D:"+getGlobal("sprite-Z3D")+ " tHeight:" +getGlobal("terrainHeight"),"Lucida Console",10,0,230,255,0,0,255);
drawText("renderType:"+getGlobal("sprite-renderType")+" xRot:"+getGlobal("sprite-xRot")+" yRot:"+getGlobal("sprite-yRot")+" height:"+getGlobal("sprite-height")+" width:"+getGlobal("sprite-width")+" depth:"+getGlobal("sprite-depth"),"Lucida Console",10,0,240,255,0,0,255);
drawText("passness:"+getGlobal("sprite-passness")+" offscreenProc:"+getGlobal("sprite-offscreenProcessing")+" autoCollide:"+getGlobal("sprite-autoCollide")+" ZOffset:"+getGlobal("sprite-ZOffset")+" Object:"+getGlobal("sprite-object"),"Lucida Console",10,0,250,255,0,0,255);
}
string appendDigits(string str, int n) {
string nn="0";
int len=strlen(str);
while(len<n) { str=nn+str; len++; }
return str;
}
string deleteValue(string str, int n) {
int len=strlen(str);
int count=intValue(getGlobal("data-spriteCount"));
int size=0;
string bla="";
size=intValue(len/count);
n--;
int start=n*size;
int end=(n*size)+size;
if (n>0) bla=substr(str, 0, start);
if (n<count && end<len) bla=bla+substr(str, end, len);
return bla;
}
string updateValue(string Str, string add, int N) {
int Len=strlen(Str);
int Count=intValue(getGlobal("data-spriteCount"));
int Size=0;
string Bla="";
if (Count>0) {
Size=intValue(Len/Count);
N--;
int Start=N*Size;
int End=(N*Size)+Size;
if (N>0) Bla=substr(Str, 0, Start);
Bla+=add;
if (N<Count && End<Len) Bla=Bla+substr(Str, End, Len);
}
return Bla;
}
int mapIntValue(string str, int n) {
int len=strlen(str);
int count=intValue(getGlobal("data-spriteCount"));
int size=0;
string bla="";
int ret=0;
if (count>0) {
size=intValue(len/count);
n--;
bla=substr(str, n*size, (n*size)+size);
if (indexOf(bla, "-", 0)>0) bla=substr(bla, indexOf(bla, "-", 0), strlen(bla));
if (bla!="") ret=parseInt(bla);
}
return ret;
}
void destroyAllSprites() {
for(int b=0;b<intValue(getGlobal("data-spriteCount"));b++){
destroySprite(spriteL(b));
setGlobal("loaded-"+b, "false");
}
}
void recreateSprites() {
string spriteIDs="";
for(int b=1;b<=spriteCount;b++){
//debug(b+"-X:"+mapIntValue(spriteX, b)+" Y:"+mapIntValue(spriteY, b)+" Z:"+mapIntValue(spriteZHeight, b)+" height:"+mapIntValue(spriteHeight, b)+" width:"+mapIntValue(spriteWidth, b)+" depth:"+mapIntValue(spriteDepth, b));
//debug(b+"-Frame:"+mapIntValue(spriteFrame,b)+" rType:"+mapIntValue(spriteRenderType,b)+" autoCollide:"+mapIntValue(spriteAutoCollide,b)+" passable:"+mapIntValue(spritePassness,b)+" offscreen:"+mapIntValue(spriteOffscreenProcessing,b)+" xRot:"+mapIntValue(spriteXRotation,b)+" yRot:"+mapIntValue(spriteYRotation,b));
int s=createSprite(mapIntValue(getGlobal("data-image"), b),mapIntValue(getGlobal("data-script"), b),mapIntValue(getGlobal("data-X"), b),mapIntValue(getGlobal("data-Y"), b),0);
spriteIDs+=appendDigits(s+"", 4)+char(92);
setFrame(s,mapIntValue(getGlobal("data-frame"),b));
setRenderType(s,mapIntValue(getGlobal("data-renderType"),b));
setZ(s,mapIntValue(getGlobal("data-Z3D"),b));
setAutoCollide(s,mapBoolValue(getGlobal("data-autoCollide"),b));
setPassable(mapIntValue(getGlobal("data-X"),b),mapIntValue(getGlobal("data-Y"),b),mapBoolValue(getGlobal("data-passness"),b));
setX(s, mapIntValue(getGlobal("data-X"),b));
setY(s, mapIntValue(getGlobal("data-Y"),b));
setDepth(s, mapIntValue(getGlobal("data-depth"),b));
setWidth(s, mapIntValue(getGlobal("data-width"),b));
setHeight(s, mapIntValue(getGlobal("data-height"),b));
setOffscreenProcessing(s, mapBoolValue(getGlobal("data-offscreenProcessing"),b));
setXRotation(s, mapIntValue(getGlobal("data-xRot"),b));
setYRotation(s, mapIntValue(getGlobal("data-yRot"),b));
setZOffset(s, mapIntValue(getGlobal("data-ZOffset"), b));
setRepeatTexture(s, mapBoolValue(getGlobal("data-repeatTexture"), b));
//setGlobal("sprite-object", mapIntValue(spriteObject,b));
int object=mapIntValue(getGlobal("data-object"),b);
int objectN=getGlobal("Object-spriteCount:"+object)+1;
setGlobal("Object-spriteCount:"+object, objectN);
setGlobal("Object:"+object+":"+objectN, s);
setGlobal("sprite:"+s, b);
setGlobal("loaded-"+s, "true");
}
setGlobal("spriteIDs", spriteIDs);
}
int spriteL(int n) {
n--;
int check=indexOf(getGlobal("spriteIDs"), appendDigits(n+"", 4)+char(92), 0);
while (check==-1) { n++; check=indexOf(getGlobal("spriteIDs"), appendDigits(n+"", 4)+char(92), 0); }
int L=(check)/5; L++;
return L;
}