Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 04-27-2002, 11:06 AM
Er1c Er1c is offline
Registered User
Er1c's Avatar
Join Date: Mar 2001
Location: Chicago, IL
Posts: 791
Er1c is on a distinguished road
Space Game

I am planning on making a completely space-based game (like Cosmic Rift or Starship Troopers (Cosmic Rift is going P2P and Starship Troopers went out of business)), but I really can't think of a way to make the movement work correctly with my limited math knowledge. I'll attach a level with what I have of the movement system so far, and also paste the code below.

NPC Code:
//#CLIENTSIDE
if (created) {
disabledefmovement;
showstats 0;
this.speed = 0;
this.dir = 0;
}
if (playerenters || timeout) {
//all
PI = 3.1415926535897932384626433832795;
this.rotatespeed = 0.1;
//normal
this.maxspeed = 1;
this.thrustspeed = 0.05;
this.turnspeed = 0.07;
//hyper
this.hypermaxspeed = 1.3;
this.hyperthrustspeed = 0.1;
this.hyperturnspeed = 0.02;

if (keydown(1))
this.dir = (this.dir+this.rotatespeed)%(PI*2);
if (keydown(3))
this.dir = (this.dir-this.rotatespeed)%(PI*2);

if (keydown(0) || keydown(2)) {
newspeed = this.speed+this.thrustspeed*(keydown(0)-keydown(2));
if (newspeed in <this.maxspeed*-1,this.maxspeed>) {
this.speed = newspeed;
}
this.angle = this.dir;
}
playerx += sin(this.angle)*this.speed;
playery += cos(this.angle)*this.speed;
for (i = 0;i<3;i++) {
showimg 200+i,@tempus sans itc@c@.,playerx+sin(this.dir)*(i*2),playery+cos(th is.dir)*(i*2);
changeimgcolors 200+i,0,0,2,.99;
changeimgvis 200+i,3;
}
temp();
timeout = .05;
}
function temp() {
if (keydown(5)) this.dir = (this.dir+PI)%(PI*2);
showimg 0,@#v(sin(this.angle)),10,50;
showimg 1,@#v(sin(this.dir)),10,70;
showimg 2,@#v(cos(this.angle)),10,90;
showimg 3,@#v(cos(this.dir)),10,110;
for (i = 0;i<50;i++)
changeimgvis i,4;
}

Attached Files
File Type: nw game-control1.nw (10.6 KB, 239 views)
__________________
Eric Kraft
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 05:19 AM.


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