Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Asteroids. (https://forums.graalonline.com/forums/showthread.php?t=18310)

adam 12-05-2001 03:05 AM

Asteroids.
 
Well... I made this asteroidsish game script a while ago.
It's hardly done, but i haven't had time to work on it for a long time. So I'll just see what ya think as it is.

NPC Code:

// NPC made by Rogue Shadow -TT-*C* (TCN)
if (playerenters&&isleader) {
lives=10;
playerx=0;
playery=0;
hideplayer 10000;
disabledefmovement;
setvars();
}
function setvars(){
rocks=0;
maxshots=50;
maxrocks=15;
setarray shots,4*maxshots;
setarray ship,5;
ship[0] = (screenwidth/16)/2;
ship[1] = (screenheight/16)/2;
ship[2] = 0;
ship[3] = 0;
showship();
timeout=.05;
}
if (timeout){
if (keydown(1))ship[4]+=.314;
if (keydown(3))ship[4]-=.314;
if (keydown(5)&&!warped==1)warpship();
if (keydown(4))shoot();
move();
showship();
drawshots();
timeout=.05;
}

function showship(){
this.tx=ship[0]+sin(ship[4])*2;
this.ty=ship[1]+cos(ship[4])*2;
this.dx=(this.tx-ship[0]);
this.dy=(this.ty-ship[1]);
this.dist = (this.dx^2+this.dy^2)^0.5;
addx=(this.dx/this.dist);
addy=(this.dy/this.dist);
for (this.b=0;this.b<npcscount;this.b++){
if (testnpc(ship[0],ship[1])==this.b){
putexplosion 0,ship[0],ship[1];
gamepoints-=50;
setvars();
if (lives<=0){
set gaveover;
}else lives--;
}
}
showimg 200,icemateria.gif,ship[0],ship[1];
showimg 201,watermateria.gif,ship[0]+addx,ship[1]+addy;
}
function warpship(){
this.warped=1;
ship[0]=random(0,screenwidth/16);
ship[1]=random(0,screenheight/16);
ship[2]=0;
ship[3]=0;
}
function move(){
if (keydown(0)){
if (!warped==0)warped=0;
ship[2]+=addx*.1;
ship[3]+=addy*.1;
}
ship[0]+=ship[2];
ship[1]+=ship[3];
if (ship[0]<0)ship[0]=screenwidth/16;
if (ship[0]>screenwidth/16)ship[0]=0;
if (ship[1]<0)ship[1]=screenheight/16;
if (ship[1]>screenheight/16)ship[1]=0;
}

function shoot(){
shots[bllt]=ship[0]+addx;
shots[bllt+1]=ship[1]+addy;
shots[bllt+2]=addx;
shots[bllt+3]=addy;
if (bllt<maxshots*4){bllt+=4}else{ bllt=0;}
}

function drawshots(){
for (this.i=0;this.i<maxshots*4;this.i+=4){
showimg this.i,kstar.gif,shots[this.i],shots[this.i+1];
shots[this.i]+=shots[this.i+2];
shots[this.i+1]+=shots[this.i+3];
if (shots[this.i]<0)shots[this.i]=screenwidth/16;
if (shots[this.i]>screenwidth/16)shots[this.i]=0;
if (shots[this.i+1]<0)shots[this.i+1]=screenheight/16;
if (shots[this.i+1]>screenheight/16)shots[this.i+1]=0;
for (this.b=0;this.b<npcscount;this.b++){
if (testnpc(shots[this.i],shots[this.i+1])==this.b){
putexplosion 0,shots[this.i]-.5,shots[this.i+1]-.5;
hideimg this.i;
}
}
}
}



If this is totally confusing to you. aw well.
If this looks too easy. aw well.
Fact is I scripted this a while ago and If I put some real work into it I could do it a lot better im sure.

btedji 12-05-2001 05:33 AM

very nice, i like it :D

nyghtGT 12-05-2001 05:35 AM

*cough* i think this is from http://zorgonline.cjb.net *cough*
*cough* could be wrong though *cough*

adam 12-05-2001 08:14 AM

Quote:

Originally posted by nyghtGT
*cough* i think this is from http://zorgonline.cjb.net *cough*
*cough* could be wrong though *cough*

:p
I assure you that you are totally wrong.
But I'll go check it out and see if I find it... if I do... I know how it got there. (posted this script somewhere a few days ago).

nyghtGT 12-05-2001 01:34 PM

sorry about my accusation i have just seen an asteroid script similar to that, that i found on a graal site but yours is far different from it ... yours is very neat though ...

adam 12-05-2001 01:36 PM

Yah it's ok.
Just remember. I don't post stuff that isn't mine ;)

Saga2001 12-05-2001 02:38 PM

:-)
 
yeah i always have known rogue to own at arrays.

adam 12-05-2001 10:05 PM

And they used to say Arrays aren't useful for hardly anything :cool:

btedji 12-05-2001 11:41 PM

just because zorg has it doesnt mean they made it

adam 12-06-2001 12:00 AM

zorg doesn't have it.

they do have a space-ship though

it's nothing like mine but it is really cool.

it says delphi inc made it.

adam 01-30-2002 04:21 AM

la la la la la la la!

hey hey ! woo

:spam:

I like my Asteroids script it's just not working perfectly

Gohan43331 01-31-2002 08:18 AM

one thing i noticed:
NPC Code:
if (keydown(5)&&!warped==1)warpship();


i've had problems before with !(var)==(var)... :P so i just use (var)!=(var)

adam 01-31-2002 11:59 AM

hmm... well it doesn't hurt it. haha

entravial 02-01-2002 04:23 AM

~AlphaFlame~

I'd say it's about average-nice scripting... at least it isn't 9kb like mine... x.x;

*trots off with an axe*

BocoC 02-01-2002 07:04 AM

Quote:

Originally posted by adam
And they used to say Arrays aren't useful for hardly anything :cool:
They did? LOL.

adam 05-08-2002 11:01 AM

Quote:

Originally posted by BocoC

They did? LOL.


Hmm.... At one time the only script you could find that used arrays was the TechBow.... I think. Yes that was it.


All times are GMT +2. The time now is 06:51 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.