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.