PDA

View Full Version : Screen Scrolling. (or more like proof of usability with Z1 engine)



Gleeok
03-27-2009, 02:59 PM
..To an extent anyway.

Video - http://www.youtube.com/watch?v=hL7BBtLcVFY

If you're too lazy to read the youtube caption:
It's something I threw together based on a fun little zc game I made that is yet to be released.

Basically the Idea behind this is that if you keep the "screens" no bigger than about 512 x 352 (combined size of 4 normal sized ZC screens) then you could use the built in enemies and other useful stuff without having to re-script everything from the ground up. Obviously LTTP styled dungeons come to mind here.


Things that need to be added:
*Enemy solidity checking.
*Algorithm for sorting and using flags.

Things I've half-assed:
*Link solidity checking
*Scrolling when you get to the edge of the screen



int DATA[704];
int CSET[704];
int SOLID[704];//should probably use this too
int CX[704];
int CY[704];
int Varea = 144;
int lx; int ly;//Link

void initArena(int screen)
{//I'd keep this function at global scope
int i=1; int j;
for(j=0;j<704;j++){
CX[j]=(j<<4)%512;
CY[j]=(j>>5)<<4;
} i=1;
for(j=0;j<352;j++){
DATA[j] = Game->GetComboData( Game->GetCurMap(), screen+((j>>4)%2), j%(16*i) );
CSET[j] = Game->GetComboCSet( Game->GetCurMap(), screen+((j>>4)%2), j%(16*i) );
if(j%32==0&&j>0)i++;
} i=1;
for(j=352;j<704;j++){
DATA[j] = Game->GetComboData( Game->GetCurMap(), screen+16+((j>>4)%2), j%(16*i) );
CSET[j] = Game->GetComboCSet( Game->GetCurMap(), screen+16+((j>>4)%2), j%(16*i) );
if(j%32==0&&j>352)i++;
}
}

bool move[4];int increment = 17;
global script scroll{
void run(){
int i; int j; int k; int l;int x; int y;int dx;int dy;

initArena(increment);
lx = 240;
ly = 160;

while(true){

Waitframe();

for(i=0;i<4;i++)move[i]=true;
for(i=0;i<704;i++)
if(Abs(CX[i]-lx) < Varea)
if(Abs(CY[i]-ly) < Varea)
{ //first we draw it
//Screen->DrawCombo(1, Link->X + (CX[i]-lx), Link->Y + (CY[i]-ly),
//DATA[i], 1, 1, CSET[i], 1, 0, 0, 0, 0, 0, false, 128);
//
//updated to use FastCombo. -Gleeok
Screen->FastCombo( 1, Link->X + (CX[i]-lx), Link->Y + (CY[i]-ly), DATA[i], CSET[i], 128 );
//next we check for a collision
if(DATA[i]>3){
dx = Abs(lx-CX[i]);dy = Abs(ly-CY[i]);
if(dx<17&&dy<17){
if(CX[i]==lx+16&&dy<16)move[3]=false;
if(CX[i]==lx-16&&dy<16)move[2]=false;
if(CY[i]==ly+16&&dx<16)move[1]=false;
if(CY[i]==ly-16&&dx<16)move[0]=false;
}
}
}
Wok();//don't run! not supported by the script :P
Stay();//gooood boy. woof! =)
}
}
void Wok()
{
if(Link->InputUp){Link->Dir=0;if(move[0])if(ly>0)Move(0,-1);}
else if(Link->InputDown){Link->Dir=1;if(move[1])if(ly<384)Move(0,1);}
if(Link->InputLeft){Link->Dir=2;if(move[2])if(lx>0)Move(-1,0);}
else if(Link->InputRight){Link->Dir=3;if(move[3])if(lx<512)Move(1,0);}
if(Link->InputStart){ increment++;initArena(increment); }
Link->InputStart=false;

if(!move[0])Link->InputUp=false;
if(!move[1])Link->InputDown=false;
if(!move[2])Link->InputLeft=false;
if(!move[3])Link->InputRight=false;
Link->X=120;Link->Y=80;
}
void Move(int x, int y)
{//we have to update our screen objects
int n = Screen->NumLWeapons();
lweapon lw;
eweapon ew;
npc enemy;
int e_num = Screen->NumNPCs();
int p =Screen->NumItems();

for(int i=n;i>0;i--){
lw = Screen->LoadLWeapon(i);
lw->X -= x;
lw->Y -= y;
}
n = Screen->NumEWeapons();
for(int i=n;i>0;i--){
ew = Screen->LoadEWeapon(i);
ew->X -= x;
ew->Y -= y;
}
item a;
for(int i=p;i>0;i--){
a = Screen->LoadItem(i);
a->X -= x;
a->Y -= y;
}
for(int i = e_num; i>0; i--){
enemy = Screen->LoadNPC(i);
enemy->X -= x;
enemy->Y -= y;
}
lx += x;
ly += y;
}
void Stay()
{
int e_num = Screen->NumNPCs();npc enemy;
for(int i = e_num; i>0; i--){
enemy = Screen->LoadNPC(i);
if(enemy->X<-80)enemy->X=-80;
if(enemy->X>320)enemy->X=320;
if(enemy->Y<-80)enemy->Y=-80;
if(enemy->Y>240)enemy->Y=240;
}
}
}

Disclaimer: This script is provided as is yada yada, I have no plans to finish it blah-dee-blah, I'll answer any questions you have durp-de-dee, Have fun!

lucas92
03-27-2009, 05:56 PM
Whoa thanks for releasing it. :)

Do you have the test quest showed in the youtube video?

lucas92
04-10-2009, 02:22 PM
Sorry for double posting, but the script doesn't seems to work for me...
:(

Gleeok
04-16-2009, 05:03 AM
Sorry for the late reply. I don't have my computer with me for another coouple of weeks and thus cannot upload the test quest for you. But it only took me about five minutes to put that screen together anyways, so open up Ex 1st quest and I'll walk you through the process...Got it loaded up yet? ..I'll wait.


...

OK, on screen 77 black out every combo on screen with blank combos...walkable ones at that. Now see this:

initArena(increment);
increment is a rather dumb name for this variable, you might want to use "current_virtual_screen" as it's name instead.

Notice that it's set to 17. That's screen 11 on the map. So goto that screen and delete it. And do the same to screens 12, 21, and 22. Those four screens are now going to be one single "arena" screen, so go ahead and draw here what will be actually appearing on the screen. Solid combos will work fine. (for Link anyways)

Now add some enemies to this screen.


...Ah ah aaaah! You went back to screen 77 for the enemies right? Gotcha. ;)

Alright now enable cheats and try it out. And after you test it out try holding the start button. :) Just for fun, hold it untill the game crashes, because it will!

Hope that helps. Cheers!

Hot Water Music
05-23-2010, 08:23 AM
I'm getting an error on line 49.

Christian
05-23-2010, 10:15 AM
Ok. Can you tell us what does it say?

Hot Water Music
05-23-2010, 07:27 PM
Woops I mean line 48.

Here's a screenshot of the error
http://img20.imageshack.us/img20/5508/errorha.png

Christian
05-24-2010, 12:07 AM
Replace line 48 with this:



Screen->DrawCombo(1, Link->X + (CX[i]-lx), Link->Y + (CY[i]-ly),
DATA[i], 1, 1, CSET[i],-1, -1, 0, 0, 0, 0, 0, false, 128);

Gleeok
05-24-2010, 01:16 AM
Even better would be to replace it with this:


Screen->FastCombo( 1, Link->X + (CX[i]-lx), Link->Y + (CY[i]-ly), DATA[i], CSET[i], 128 );

Since scripts like this are pretty much the whole reason I added those. ..Actually I just edited the script to use FastCombo.