[APPLICATION] RPG Demo

217 views
Skip to first unread message

Symbroson Development

unread,
Sep 3, 2016, 3:51:48 AM9/3/16
to DroidScript
Hey guys :)
I made a cool RPG demo!!
The images I got from pokémon sw because it is only a demonstration how you could add textures.
It should be very easy to modify the code and add new worlds.
I hope you enjoy it and give a feedback when you tested it.
I will upload a commented version here:
https://www.dropbox.com/sh/vuoa4304esffetn/AAAnJxS9Hs6OjUBRz6ReMxpZa

Best regards,
Symbroson
by Alex
RPGdemo.spk

Symbroson Development

unread,
Sep 3, 2016, 4:39:44 AM9/3/16
to DroidScript
Heres a little app makes it easyer to make maps ;)
MapMaker.spk

Manuel Lopes

unread,
Sep 3, 2016, 8:42:01 AM9/3/16
to DroidScript
wow you are great;how you make this idea?very cool;one question the mapmaker is to add anything? thanks

Symbroson Development

unread,
Sep 3, 2016, 11:16:36 AM9/3/16
to DroidScript
With the mapmaker you can set the mapsize, set the numbers to generate the world and copy it to paste it un the RP code.
Note: the player can only walk on fields in the array when n<=0.
Trees has the number 1 so the player can't walk into them. Grass has no 0.

cheers :)

Manuel Lopes

unread,
Sep 3, 2016, 5:24:32 PM9/3/16
to DroidScript
thanks , one question what the number of the player in the array?

Symbroson Development

unread,
Sep 3, 2016, 6:09:18 PM9/3/16
to DroidScript
The player wasn't shown in the array. His position is player.X and player.Y

Symbroson Development

unread,
Sep 4, 2016, 11:07:20 AM9/4/16
to DroidScript
Hello again ;)
based on the RPG demo I made a labyrinth demo. I added dialogs while talking to smth. Please try it out and give a feedback ;)

Best regards,
Alex from Symbroson

LabDemo.spk

Netpower8

unread,
Sep 4, 2016, 8:02:13 PM9/4/16
to DroidScript
Last 2 days was busy manning a bazaar booth. Just saw this. And this is increadible. I was wonding. On my galaxy tab the virtual button stayed on screen and the below part was covered. But the animation of thr walking guy in interesting. Did not thought it was possible to do that in DS.

Symbroson Development

unread,
Sep 5, 2016, 12:27:24 AM9/5/16
to DroidScript
Thank you! Thats why I make and share those example apps! :)
It could be faster if GLV was transparent but it is just the idea I want to realize. So if you have an idea how to improve please tell me - to make it presentable and for experience ;)
Regards,
Alex

Netpower8

unread,
Sep 5, 2016, 1:45:46 AM9/5/16
to DroidScript
Been busy might not have much time. But i could try to make some of your functions generic so that you can re-use the code and use different sprites. Trying it out on a tank sprite.

Symbroson Development

unread,
Sep 5, 2016, 2:21:35 AM9/5/16
to DroidScript
Of course you can make a tank sprite with it. You have only to add bullets ^^

Manuel Lopes

unread,
Sep 5, 2016, 9:09:24 AM9/5/16
to DroidScript
alex grear job you are prepare to make a great game ;congratulations

Rodrigo Faustino

unread,
Sep 6, 2016, 8:01:30 AM9/6/16
to DroidScript
sorry my english, from the google translator, just want to give you the congratulations for your contribution you really are fantastic

Symbroson Development

unread,
Sep 6, 2016, 8:18:12 AM9/6/16
to DroidScript
Hahah thanks :D
I'll try to make a tank game with it
Should be not that dufficult... ^^

Dave Smart

unread,
Sep 6, 2016, 1:26:35 PM9/6/16
to DroidScript
Nice work Alex :)

Netpower8

unread,
Sep 6, 2016, 1:57:01 PM9/6/16
to DroidScript
Hey i gave the tank sprites. Want it?

Netpower8

unread,
Sep 6, 2016, 1:59:23 PM9/6/16
to DroidScript
Its a 30 x30 pixel. 8 images. Made a sample app that animates it when moving. And when it rotates. Was trying to make joystick (trying to make reusable generic code) not yet complete code but you can see the tank sprite move and rotate.

Symbroson Development

unread,
Sep 6, 2016, 4:29:46 PM9/6/16
to DroidScript
I have already a tank sprite (without animation, but looks also ok ^^) but you can send it to my mail and I can look they're better then mine :p
Thanks :)

Symbroson Development

unread,
Sep 7, 2016, 4:29:50 AM9/7/16
to DroidScript
It's done! :D
Heres my cool Tanks demo
I think it could be a playstore-app ^^

Best regards,
Alex

Tanks.spk

Symbroson Development

unread,
Sep 7, 2016, 6:50:14 AM9/7/16
to DroidScript
I tried to get the fps -
My result : ca 10fps...
Anyone has an idea how to improve 😅

JustAnotherDude

unread,
Sep 7, 2016, 7:08:40 AM9/7/16
to DroidScript
Kaufe ein neues handy oder versuche den code anzupassen wenn du es schneller haben möchtest ^^

und wie JuliensBlog sagen würde als lösung: Bring dich um (würde er wirklich sagen.. deutscher youtuber mit extrem schwarzen humor ^^)

Netpower8

unread,
Sep 7, 2016, 8:18:50 AM9/7/16
to DroidScript
your tank looks good... will send what i have so far a bit later. i dont have much time so my tank game is not like yours. still studying how to do graphics...

Symbroson Development

unread,
Sep 8, 2016, 4:15:11 AM9/8/16
to DroidScript
I will try to use a single GLView to draw the game - hope it will be faster ^^
Message has been deleted

Netpower8

unread,
Sep 16, 2016, 6:57:22 AM9/16/16
to DroidScript
here's what i dont so far... sorry it took so long.. been busy... also i need a pc to do this transfer of files... the mobile device cant handle file upload. wish it can. anyway... here's what i done so far
Tank.spk

Symbroson Development

unread,
Sep 16, 2016, 9:48:02 AM9/16/16
to DroidScript
Looks good. You forgot SetAutoupdate :p
It can be used to auto move, and i think it was better to give the move difference, but it is working well ☺

Netpower8

unread,
Sep 16, 2016, 10:06:15 AM9/16/16
to DroidScript
Still learning doing graphics. But its hard... Time is limited. Taking care of the kids. Occasional bazaar here and there and a few other stuff that needs done. The app for my online store got on hold. Our stock items arrive last week need to do inventory. Finished doing counting but need to match with the orders since there are some new items waiting for the code of those items from the supplier so i know which is which. Quite a lot of things. Thats why i used a tablet to do coding... Portable. Laptop a bit bulky.

Symbroson Development

unread,
Sep 17, 2016, 5:16:35 AM9/17/16
to DroidScript
Can anyone tell me please why there was the error "cannot read property 'width' of undefined" on the 16. line after the splash screen disappears? Nowhere I used 'width' im my code neither in tanks2.js nor in special.js
Thanks for help 😕
Tanks2.spk

Manuel Lopes

unread,
Sep 17, 2016, 8:28:34 AM9/17/16
to DroidScript
i know what is the error but why level 3 title show when start your logo?i think is related to the error but not know sorry

Netpower8

unread,
Sep 17, 2016, 8:36:37 AM9/17/16
to DroidScript
Tried. Can't find the error.

Symbroson Development

unread,
Sep 17, 2016, 9:23:12 AM9/17/16
to DroidScript
It is the 'glv.DrawImage' in the Render function. But it won't work anyways. I'll begin again with the current version and try again.

Symbroson Development

unread,
Sep 17, 2016, 10:05:11 AM9/17/16
to DroidScript
I forgot to move the glv.Images.push after creating the world images because I dont redraw them if they already exists in the Priv.Folder
Message has been deleted

Symbroson Development

unread,
Sep 17, 2016, 10:15:10 AM9/17/16
to DroidScript
Wow now my tank is SUPERFAST !! :D
Tanks2.spk

Netpower8

unread,
Sep 17, 2016, 4:31:57 PM9/17/16
to DroidScript
Tank moves fast. What did ypu change to make it move that fast... Too fast. Hard to control

Symbroson Development

unread,
Sep 17, 2016, 4:48:46 PM9/17/16
to DroidScript
1. It uodates only if the tank finished with walking
2. GL-View

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

Ben Harris

unread,
Sep 18, 2016, 8:27:58 PM9/18/16
to DroidScript
Hi I've been messing around with the lab demo. I've created extra world's but it has trouble with world 11. Is there a limit on how many can be loaded in a script.

Symbroson Development

unread,
Sep 19, 2016, 12:10:31 AM9/19/16
to DroidScript
No there should be no limit. Could you please send me the code? Maybe I find the mistake (I or you made ^^)

Ben Harris

unread,
Sep 19, 2016, 6:38:45 AM9/19/16
to DroidScript
//globals
var curWorld, text, itv
sizX=1; sizY=1
app.LoadScript( "Special.js" );


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,-12,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,0,0,0,0,0,0,0,1],
[1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,1]] );
lay.AddChild( world1 );

world2= newWorld( "Labyrinth 2", null,
[[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,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,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0,1,1],
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,1,1],
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,1,1],
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,1,1],
[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,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0],
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,1,1],
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,1,1]] );
lay.AddChild( world12 );

world13= newWorld( "Labyrinth 13", null,
[[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,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;
}

Ben Harris

unread,
Sep 19, 2016, 6:38:46 AM9/19/16
to DroidScript

Symbroson Development

unread,
Sep 19, 2016, 8:59:02 AM9/19/16
to DroidScript
You just forget two commas in 2 world.out:

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]]]
]

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

Ben Harris

unread,
Sep 19, 2016, 11:01:25 AM9/19/16
to DroidScript
Thanks for your help. I thought it might have been to do with that. But I couldn't see it.

Symbroson Development

unread,
Sep 19, 2016, 3:05:17 PM9/19/16
to DroidScript
I will think about adding the glv to this sample too - but it will be not easy (I stopped working on the tankerous demo a week because I couldn't find my mistake and I was a bit sad because the fade animation wasnt working on glViews...) but the fps will be much better than now.
And the world images are only drawn if they didn't exists in a given folder. So you mustnt wait every time until all worlds are drawn.

Ben Harris

unread,
Sep 20, 2016, 4:04:11 PM9/20/16
to DroidScript
I've added more world's. After going through a few, it starts slowing down.

Ben Harris

unread,
Sep 20, 2016, 4:13:49 PM9/20/16
to DroidScript
Is there a way to only load world's that are next to the screen currently being viewed.

Symbroson Development

unread,
Sep 20, 2016, 4:27:04 PM9/20/16
to DroidScript
I know about this but I dont know what is causing this bug. Sorry
I will try to find it 😞

Ben Harris

unread,
Sep 21, 2016, 9:58:25 AM9/21/16
to DroidScript
I think it is to do with loading so many world's into the main.

Symbroson Development

unread,
Sep 21, 2016, 10:02:59 AM9/21/16
to DroidScript
Yes this can be the reason.
As I said if you use a glView as in Tankerous this won't happen because it saves the world images on sdcard and just redraws them if they didn't exists - but not save them in the app, just load them again with img=glv.CreateImage() and make them global

Ben Harris

unread,
Sep 25, 2016, 8:11:55 PM9/25/16
to DroidScript
Hi, I have a few questions about the tank demo. why did you change the way it calls the init's?

Symbroson Development

unread,
Sep 26, 2016, 10:06:27 AM9/26/16
to DroidScript
I havent worked on the old version the last time. I worked on the new version - Tankerous - and there I put thebinits in an extra js file.
Can you explain me what do you mean with 'changed' - what was previous what current

Ben Harris

unread,
Sep 26, 2016, 5:59:17 PM9/26/16
to DroidScript
In the first tank and lab demo you call the init's one after another in a block. In the 2nd you call textures which calls player and so forth?

Lee Tarry

unread,
Jul 6, 2017, 9:32:35 AM7/6/17
to DroidScript
Alex,

Where does the code state what textures the character can and cant walk over?

i have made a few textures and added them into the game but they are all (like the tree in your example) immovable.

for example id would like to have;
Grass for a forest,
Road for a city,
Mud for a pathway.

i know it will be something obvious but cant find it, thanks!

Lee

Symbroson

unread,
Jul 6, 2017, 2:16:00 PM7/6/17
to DroidScript
you know the position of the player and you have the array with your map right?
now just check every tile on the map wether the player collides with it. Case yes, and if the tile is a tree - reset the player to the previous position or move him to the nearest empty field
most effective way is to check all tiles from
x in range [floor(p.x), ceil(p.x)]
y in range [floor(p.y), ceil(p.y)]
Reply all
Reply to author
Forward
0 new messages