cheers :)
3. It is not the final version because there are lots of other bugs and I fixed most of them now. But there left some and I'll fix them tomorrow
function OnStart() {
app.SetOrientation( "Landscape" );
app.SetScreenMode( "Game" );
app.SetDebugEnabled( true );
//create main layout with scroller
layMain= app.CreateLayout("Absolute" );
scr= app.CreateScroller( 1,1 );
//map layout
lay= app.CreateLayout( "absolute" );
app.LoadScript( "map.js" );
initTexture();
initWorlds();
initPlayer();
initControls();
initSBubble();
scr.AddChild( lay );
layMain.AddChild( scr );
}
//handle control keys
function onKeys(ev) {
player.Dir=this.Action;
if( ev.action=="Down" && !sb.IsVisible() ) { this.SetBackColor( "#33ffffff" ); itv=setInterval(move,20) }
if( ev.action=="Up" ) { this.SetBackColor( "#00ffffff" ); if(itv) clearInterval(itv) }
}
//walk if possible
function move() {
if( canMove(player.Dir) ) walk(player.Dir)
else clearInterval(itv)
}
//move the player
function walk(dir) {
var n=1, s=1/8, t=2
for( var i=0; i<8*t; i++ ) {
switch (dir) {
case "Up": player.Y-=s/t; break;
case "Down": player.Y+=s/t; break;
case "Left": player.X-=s/t; break;
case "Right": player.X+=s/t; break;
}
//walk animation
if(i>t) n=0;
if(i>3*t) n=2;
if(i>5*t) n=0;
drawPlayer(n)
}
}
//set a text shown on an speech bubble on the bottom
function talk(n) {
text=[];
switch( n ) {
case 1: text=["This is a tree","Awesome!"]; break;
case 2: text.push("You found a letter. You open it and read :");
text.push("Congratulations!\nyou found the key to leave this place.")
text.push("<Dlg>;exit;Do you want to leave the game?;Yes,No")
text.push("Well, then come back later to leave.");
break;
default: if( !ranInt(3) ) text.push("A gentle breeze blowing you around your hair...")
}
if(text && text.length) Tell()
}
//check the player walks to an other map
function ckeckBorders() {
for(var w in curW.out) {
var arr=curW.out[w]
for( var i in arr[2] )
if( player.X==arr[2][i][0] && player.Y==arr[2][i][1] ) {
player.X=arr[2][i][2];
player.Y=arr[2][i][3];
change(curW,curW.out[w][0],curW.out[w][1]);
return;
}
}
}
//change maps
function change(oldW,newW,type,option) {
layControls.SetTouchable( false );
if(itv) clearInterval(itv)
layMain.ChildToFront( sb );
layMain.ChildToFront( layControls );
nameText.SetText( newW.Name );
nameBar.Animate( "SlideFromLeft",null,2000 );
curW=newW;
newW.SetPosition( -1,0 );
newW.SetVisibility( "Show" );
var t=5
switch(type) {
case "Fade":
//fade animation
newW.Image.SetAlpha( 255 );
newW.SetPosition(0,0);
if(oldW) for( var i=0; i<256; i+=t ) oldW.Image.SetAlpha( i );
drawPlayer();
//scr.ScrollTo( player.X/curW.W+0.5,player.Y/curW.H+0.5 );
for( var i=255; i>0; i-=t ) newW.Image.SetAlpha( i );
break;
default:
newW.SetPosition(0,0);
newW.SetVisibility( "Show" );
if(oldW) oldW.SetVisibility( "Hide" );
}
setTimeout(hideBar,1500);
layControls.SetTouchable( true );
}
function hideBar() {
nameBar.Animate( "SlideToLeft",null,2000 );
}
function OnDlg() {
txt=text[sb.n].split(';')
dlg= app.CreateListDialog( txt[2],txt[3] );
dlg.Type=txt[1]
dlg.SetOnTouch( dlgTouch );
}
function dlgTouch(reply) {
switch(dlg.Type) {
case "exit":
if(reply=="Yes") app.Exit();
break;
}
showsb();
}
/******************************************************************\
\******************************************************************/
//check the player can move in a given direction
function canMove(dir) {
var x=player.X, y=player.Y;
switch( dir ) {
case "Up": y--; break;
case "Down": y++; break;
case "Left": x--; break;
case "Right": x++; break;
}
x=Math.round(x); y=Math.round(y)
player.X=Math.round(player.X); player.Y=Math.round(player.Y)
drawPlayer();
if( x<0 || x>=curW.W || y<0 || y>=curW.H ) {ckeckBorders();return false}
return (curW.Area[y][x]<=0);
}
//talk if player dont talk to smth outside the map (array)
function canTalk() {
kEnter=this;
var x=player.X, y=player.Y;
switch( player.Dir ) {
case "Up": y--; break;
case "Down": y++; break;
case "Left": x--; break;
case "Right": x++; break;
}
x=Math.round(x); y=Math.round(y)
if( x>=0 && x<curW.W && y>=0 && y<curW.H ) talk(curW.Area[y][x])
}
//draw the player, n for walk animation
function drawPlayer(n) {
var px,py,w,h,x,y
py=["Up","Down","Left","Right"].indexOf(player.Dir)
n?px=n:px=0;
//w=player.W/3; h=player.H/4
x=player.X; y=player.Y;
player.Clear();
player.DrawImage( player.Image[py+''+px], player.X/curW.W,player.Y/curW.H,1/curW.W, 1/curW.H);
player.Update();
}
//get textures
function initTexture() {
dirt = app.CreateImage( "Img/dirt1.png" );
GrassCentre = app.CreateImage( "Img/grass centre.png" );
GrassNw1 = app.CreateImage( "Img/grass nw 1.png" );
GrassNw2 = app.CreateImage( "Img/grass nw 2.png" );
GrassNw3 = app.CreateImage( "Img/grass nw 3.png" );
GrassNe1 = app.CreateImage( "Img/grass ne 1.png" );
GrassNe2 = app.CreateImage( "Img/grass ne 2.png" );
GrassNe3 = app.CreateImage( "Img/grass ne 3.png" );
GrassSe1 = app.CreateImage( "Img/grass se 1.png" );
GrassSe2 = app.CreateImage( "Img/grass se 2.png" );
GrassSe3 = app.CreateImage( "Img/grass se 3.png" );
GrassSw1 = app.CreateImage( "Img/grass sw 1.png" );
GrassSw2 = app.CreateImage( "Img/grass sw 2.png" );
GrassSw3 = app.CreateImage( "Img/grass sw 3.png" );
tree = app.CreateImage( "Img/Tree.png" );
}
//set player object
function initPlayer() {
player= app.CreateImage( null,sizX,sizY );
player.Image=[];
player.SetAutoUpdate( false );
for( i=0; i<3; i++ ) for( j=0; j<4; j++ )
player.Image[j+''+i] = app.CreateImage( "Img/P"+j+''+i+"-1.png" );
player.Name= "Steve";
player.X=1;
player.Y=0;
player.Dir="Down";
lay.AddChild( player );
}
//inutialisize maps
function initWorlds() {
world1= newWorld( "Labyrinth 1", null,
[[1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[1,0,-12,1,1,1,-1,-1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[1,0,0,-12,-1,-1,-1,-1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[1,-6,0,0,0,0,0,-12,-1,1,1,1,1,1,1,1,1,1,1,1,1],
[1,-1,-6,0,0,0,0,0,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,1],
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0],
[1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,1],
[1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,1]] );
lay.AddChild( world13 );
//positions where player can leave the map
world1.out= [
[world6,"Fade",[[15,10,15,0],[16,10,16,0],[17,10,17,0],[18,10,18,0],[19,10,19,0]]]
]
world2.out= [
[world3,"Fade",[[20,6,0,6],[20,7,0,7],[20,8,0,8],[20,9,0,9],[20,10,0,10]]],
[world7,"Fade",[[4,10,4,0],[5,10,5,0],[6,10,6,0],[7,10,7,0],[8,10,8,0]]],
]
world3.out= [
[world2,"Fade",[[0,6,20,6],[0,7,20,7],[0,8,20,8],[0,9,20,9],[0,10,20,10]]],
[world8,"Fade",[[3,10,3,0],[4,10,4,0],[5,10,5,0],[6,10,6,0],[7,10,7,0],[13,10,13,0],[14,10,14,0],[15,10,15,0],[16,10,16,0],[17,10,17,0]]],
]
world4.out= [
[world5,"Fade",[[20,5,0,5],[20,6,0,6],[20,7,0,7],[20,8,0,8],[20,9,0,9]]],
[world9,"Fade",[[2,10,2,0],[3,10,3,0],[4,10,4,0],[5,10,5,0],[6,10,6,0]]]
]
world5.out= [
[world4,"Fade",[[0,5,20,5],[0,6,20,6],[0,7,20,7],[0,8,20,8],[0,9,20,9]]],
[world10,"Fade",[[10,10,10,0],[11,10,11,0],[12,10,12,0],[13,10,13,0],[14,10,14,0]]]
]
world6.out= [
[world1,"Fade",[[15,0,15,10],[16,0,16,10],[17,0,17,10],[18,0,18,10],[19,0,19,10]]],
[world7,"Fade",[[20,4,0,4],[20,5,0,5],[20,6,0,6],[20,7,0,7],[20,8,0,8]]],
[world11,"Fade",[[6,10,6,0],[7,10,7,0],[8,10,8,0],[9,10,9,0][10,0,10,10],[15,10,15,0],[16,10,16,0],[17,10,17,0],[18,10,18,0],[19,10,19,0]]]
]
world7.out= [
[world2,"Fade",[[4,0,4,10],[5,0,5,10],[6,0,6,10],[7,0,7,10],[8,0,8,10]]],
[world6,"Fade",[[0,4,20,4],[0,5,20,5],[0,6,20,6],[0,7,20,7],[0,8,20,8]]]
]
world8.out= [
[world3,"Fade",[[3,0,3,10],[4,0,4,10],[5,0,5,10],[6,0,6,10],[7,0,7,10],[13,0,13,10],[14,0,14,10],[15,0,15,10],[16,0,16,10],[17,0,17,10]]],
[world9,"Fade",[[20,4,0,4],[20,5,0,5],[20,6,0,6],[20,7,0,7],[20,8,0,8]]]
]
world9.out= [
[world4,"Fade",[[2,0,2,10],[3,0,3,10],[4,0,4,10],[5,0,5,10],[6,0,6,10],[17,0,17,10],[18,018,10],[19,0,19,10],[20,0,20,10]]],
[world8,"Fade",[[0,4,20,4],[0,5,20,5],[0,6,20,6],[0,7,20,7],[0,8,20,8]]],
[world10,"Fade",[[20,4,0,4],[20,5,0,5],[20,6,0,6],[20,7,0,7],[20,8,0,8]]]
]
world10.out= [
[world5,"Fade",[[10,0,10,10],[11,0,11,10],[12,0,12,10],[13,0,13,10],[14,0,14,10]]],
[world9,"Fade",[[0,4,20,4],[0,5,20,5],[0,6,20,6],[0,7,20,7],[0,8,20,8]]]
]
world11.out= [
[world6,"Fade",[[6,0,6,10],[7,0,7,10],[8,0,8,10],[9,0,9,10][10,0,10,10],[15,0,15,10],[16,0,16,10],[17,017,10],[18,0,18,10],[19,019,10]]],
[world12,"Fade",[[20,4,0,4],[20,5,0,5],[20,6,0,6],[20,7,0,7],[20,8,0,8]]]
]
//bar shown when player arrives at an nw map
nameBar= app.CreateLayout( "Linear", "Horizontal" );
nameBar.SetVisibility( "Hide" );
nameText= app.CreateText( "",0.7,0.1 );
nameText.SetTextSize( 25 );
nameBar.AddChild( nameText );
nameBar.SetBackGradientRadial(0, 0, 0.7,"blue", "#00000000" );
lay.AddChild( nameBar );
}
//set speech bubble object
function initSBubble() {
sb= app.CreateLayout( "Linear","FillXY,VCenter" );
sb.SetPosition( 0,0.7 );
sb.SetVisibility( "Hide" );
sb.txt=app.CreateText( "",1,0.3,"multiline");
sb.txt.SetTextColor( "black" );
sb.txt.SetBackColor( "white" );
sb.txt.SetTextSize( 20 );
sb.AddChild( sb.txt );
layMain.AddChild( sb );
}
//set control keys
function initControls() {
layControls= app.CreateLayout( "linear","FillXY,HCenter" );
layControls.SetTouchable( false );
layControls.SetPosition( 0.6,0.4 );
btnLeft= control("Left");
btnRight= control("Right");
btnUp= control("Up");
btnDown= control("Down");
btnEnter= control("[fa-dot-circle-o]");
var layH= app.CreateLayout( "Linear", "Horizontal" );
layH.AddChild( btnLeft );
layH.AddChild( btnEnter );
layH.AddChild( btnRight );
layControls.AddChild( btnUp );
layControls.AddChild( layH );
layControls.AddChild( btnDown );
layMain.AddChild( layControls );
}
//set world object
function newWorld(name,img,arr) {
//make world object
var world= app.CreateLayout( "Absolute" );
world.Area=arr;
world.Name=name;
world.H= arr.length
world.W= arr[0].length
world.Image= app.CreateImage( img, sizX,sizY);
world.AddChild( world.Image );
//draw objects with worlds array
if(!img)
var w=1/world.W, h=1/world.H;
for( i in arr ) {
for( j in arr[i] ) {
world.Image.DrawImage( dirt, j*w, i*h, w, h );
switch(arr[i][j]) {
case -1: world.Image.DrawImage( GrassCentre, j*w, i*h, w, h ); break;
case -2: world.Image.DrawImage( GrassNw1, j*w, i*h, w, h ); break;
case -3: world.Image.DrawImage( GrassNw2, j*w, i*h, w, h ); break;
case -4: world.Image.DrawImage( GrassNw3, j*w, i*h, w, h ); break;
case -5: world.Image.DrawImage( GrassNe1, j*w, i*h, w, h ); break;
case -6: world.Image.DrawImage( GrassNe2, j*w, i*h, w, h ); break;
case -7: world.Image.DrawImage( GrassNe3, j*w, i*h, w, h ); break;
case -8: world.Image.DrawImage( GrassSe1, j*w, i*h, w, h ); break;
case -9: world.Image.DrawImage( GrassSe2, j*w, i*h, w, h ); break;
case -10: world.Image.DrawImage( GrassSe3, j*w, i*h, w, h ); break;
case -11: world.Image.DrawImage( GrassSw1, j*w, i*h, w, h ); break;
case -12: world.Image.DrawImage( GrassSw2, j*w, i*h, w, h ); break;
case -13: world.Image.DrawImage( GrassSw3, j*w, i*h, w, h ); break;
case 1: world.Image.DrawImage( tree, j*w, i*h, w, h ); break;
}
}
}
world.SetVisibility( "Hide" );
return world;
}
world11.out= [
[world6,"Fade",[[6,0,6,10],[7,0,7,10],[8,0,8,10],[9,0,9,10] , [10,0,10,10],[15,0,15,10],[16,0,16,10],[17,017,10],[18,0,18,10],[19,019,10]]],
[world12,"Fade",[[20,4,0,4],[20,5,0,5],[20,6,0,6],[20,7,0,7],[20,8,0,8]]]
]
I marked them with spaces before and after it
And i want to say its a great example :)
It wasnt easy to find mistakes in huge codes
I found it this way:
The error happens when you LEAVE world6 to world11 - so the mistake must be in world6.out=...[world11...]
and I had errors like this before when I use arrays - experience ^^
Finally I looked for other mistakes like that and I found the second
it should work now
Just copy the new functions into your code
Best regards ;)
Symbroson