Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #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, 237 views)
__________________
Eric Kraft
Reply With Quote
  #2  
Old 04-27-2002, 08:57 PM
RavenTelvecho RavenTelvecho is offline
Registered User
RavenTelvecho's Avatar
Join Date: Apr 2002
Location: Toronto, Ontario, Canada
Posts: 0
RavenTelvecho is on a distinguished road
Send a message via ICQ to RavenTelvecho Send a message via AIM to RavenTelvecho Send a message via Yahoo to RavenTelvecho
looks neat but i dont know what it does lol
feels like a plane
__________________

^tuff newbie ;x
RavenTelvecho
!Booj
we are 'brothers'
Reply With Quote
  #3  
Old 04-28-2002, 04:55 AM
Gohan43331 Gohan43331 is offline
Registered User
Join Date: Jan 2002
Posts: 87
Gohan43331 is on a distinguished road
Send a message via AIM to Gohan43331
Wow...looks awsome...

Not sure what you mean by moving "correctly"... Seems to work pretty well for me...
__________________
Reply With Quote
  #4  
Old 04-28-2002, 09:01 AM
Gohan43331 Gohan43331 is offline
Registered User
Join Date: Jan 2002
Posts: 87
Gohan43331 is on a distinguished road
Send a message via AIM to Gohan43331
Ah, i see what you mean now...where you can change direction instantly...
__________________
Reply With Quote
  #5  
Old 04-28-2002, 11:18 AM
Kadar Kadar is offline
Registered User
Join Date: Jan 2002
Posts: 636
Kadar is on a distinguished road
Quote:
Originally posted by Gohan43331
Ah, i see what you mean now...where you can change direction instantly...
No.
Go play cosmic rift and u will see
Its hard to explain.
__________________
Reply With Quote
  #6  
Old 05-01-2002, 09:22 AM
prozac424242 prozac424242 is offline
Registered User
prozac424242's Avatar
Join Date: May 2001
Location: Gone crazy: back soon
Posts: 356
prozac424242 is on a distinguished road
Send a message via ICQ to prozac424242 Send a message via AIM to prozac424242
cool

very nice, now to jsut add a ship image sprite rotaded liek every 5 degrees and a changeimgpart and have it work in mulitple levels... heh i like to hold right and up to fly in circles heh
__________________

Useful links:
Graal Stats
Client Script Functions-GS1 to GS2
Serverside Script Functions-Gscript page
Particle Engine-Player Attributes
Server Options-Admin rights-Gmaps
Quote:
Originally Posted by Admins
Thanks for developing and improving playerworlds and such
Reply With Quote
  #7  
Old 05-01-2002, 12:58 PM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
Perhaps I should try my hand at the Asteroids game I was working on again.


I felt it was quite nice. Especially since I had never had trig.
But im in trig class now.
We did vectors last week. Me likes.

And I finally understand the proper use of arcTan
I loves it. Very useful. I recall seeing it used and being baffled.
I am now knowing how to be using it.
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
Reply With Quote
  #8  
Old 05-01-2002, 01:17 PM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
Anytime you need an angle =/ arctan is there. I didn't even know it returned an angle until a few weeks ago.


It's been a while but I remember wanting to figure out an angle and not knowing exactly how I was gonna do that. I prabably did way more than I needed to. arcTan would make it faster.
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
Reply With Quote
  #9  
Old 05-01-2002, 01:21 PM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
Well say you wanted to make a compas for some odd reason? =/

Trivial things I guess. Hey it could happen.
I remember somebody once saying something like.
"You almost never need to use arrays"
hah. what a statement.
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
Reply With Quote
  #10  
Old 05-01-2002, 02:11 PM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
=/ Ok so Im just crazy. gimmie a break.
We can live without angles I guess.
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
Reply With Quote
  #11  
Old 05-02-2002, 03:06 AM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
Quote:
Originally posted by Kaimetsu
Actually, you're kinda right. I just realised that Graal's rotation function uses angles instead of transformation matrices. I suppose Stefan wanted to make it easier for us kiddies :-/
Graal has a rotation function?
What is a transformation matrices. haha. I know graphing my transformation and I kinda know finding determinants with matrices. but that it.
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
Reply With Quote
  #12  
Old 05-02-2002, 10:27 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
Quote:
Originally posted by Kaimetsu
The movement is dependent on the heading rather than the general velocity. Maybe I should just fix it to show you.
Could you please? It's really just this part that needs to be fixed (well, more like changed... it's not broken, but it isn't working how I want):
NPC Code:
    newspeed = this.speed+this.thrustspeed*(keydown(0)-keydown(2));
if (newspeed in <this.maxspeed*-1,this.maxspeed> ) {
this.speed = newspeed;
}
this.angle = this.dir;


this.speed would be the velocity, and this.angle should be the heading. The heading should be determined by the direction and the velocity... but I'm not into math enough to do this.

I have done something like this, but instead of using a direction, I just had a x and y speed, which would be added to as keys were held, but using angles would make other things work much more efficently -- so, if someone (*looks at Kaimetsu*, lol) can help me out here, please do.
__________________
Eric Kraft
Reply With Quote
  #13  
Old 05-02-2002, 11:45 AM
BocoC BocoC is offline
Registered User
BocoC's Avatar
Join Date: Jun 2001
Location: Washington State, USA
Posts: 980
BocoC is on a distinguished road
Send a message via AIM to BocoC Send a message via Yahoo to BocoC
Quote:
Originally posted by adam


Graal has a rotation function?
What is a transformation matrices. haha. I know graphing my transformation and I kinda know finding determinants with matrices. but that it.
Transformation matrices are mainly used in 3D Programming, like with Direct3D. I wouldn't worry about them if I were you.
__________________
-Boco

FLKJH$TRFG*$(&%>FMG >REN<>F ;.kjsd
Reply With Quote
  #14  
Old 05-02-2002, 01:09 PM
Slaktmaster Slaktmaster is offline
man with the mastahplan
Slaktmaster's Avatar
Join Date: Apr 2001
Location: Half-way over the river styx
Posts: 4,422
Slaktmaster is an unknown quantity at this point
Send a message via ICQ to Slaktmaster Send a message via AIM to Slaktmaster
newx = x+sin(angle)*velocity;

Could that work?
Reply With Quote
  #15  
Old 05-03-2002, 04:33 AM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
Quote:
Originally posted by Kaimetsu


<DELETED ALL PROOFS>

Silly Kai. he was answering a question for me. Dun worry bout it.
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly

Last edited by Kaimetsu; 05-03-2002 at 08:48 AM..
Reply With Quote
Reply


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 07:50 PM.


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