Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Ayumi, Power_P), 1,065 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
solved, silly me never looked properly at the code #158058
10/01/07 10:10
10/01/07 10:10
Joined: Nov 2005
Posts: 1,007
jigalypuff Offline OP
Serious User
jigalypuff  Offline OP
Serious User

Joined: Nov 2005
Posts: 1,007
i`m a bit stuck here, the following code works ok untill i change the while (1) to while (my.healthpoints>0)
the mouse and keys just stops working, which is kind of a pain as the camera rotation is controled by the mouse, any thoughs on this.
Code:

function fnct_chc_1
{
me = ent_create (chc_1, vector(0,0,0), null);
player = my;
my.scale_x = 1.0;
my.scale_y = my.scale_x;
my.scale_z = my.scale_x;
var ship_speed;
while (my.healthpoints>0)
{
if (key_w == on)
{
if (ship_speed.x < 1)
{
ship_speed.x += 10.0 * time;
}
}
else
{
if (ship_speed.x >= 0)
{
ship_speed.x -= 0.05 * time;
}
}
if (ship_speed.x < 0) {ship_speed.x = 0;}
if (key_a == on)
{
my.pan += 3 * time;
}
if (key_d == on)
{
my.pan -= 3 * time;
}
if (ship_speed.z < 0) {ship_speed.z = 0;}
if (key_q == on)
{
my.tilt + = 3 * time;
}
if (ship_speed.z < 0) {ship_speed.z = 0;}
if (key_e == on)
{
my.tilt - = 3 * time;
}
ent_move (ship_speed.x, nullvector);
{

camera.pan -= mouse_force.x * 12 * time;
camera.tilt += mouse_force.y * 8 * time;
camera.tilt = clamp(camera.tilt,-30,10);
temp = fcos(camera.tilt,-camera_distance);
vec_set(camera.x,vector(my.x + fcos(camera.pan,temp),my.y + fsin(camera.pan,temp),my.z + 20 + fsin(camera.tilt,-camera_distance)));

vec_diff(temp.x,camera.x,my.x); //find the vector from the player to the camera
vec_normalize(temp.x,16); //get the magnitude of it's vector to 16 quants and store it in temp
vec_add(temp.x,camera.x); //add the vector (from player to camera) of a magnitude of 16 quants and add it to the camera's position.

trace_mode = ignore_me+ignore_passable+ignore_models;
result = trace(my.x,temp.x); //trace from the player to 16 quants behind the camera.
IF (result > 0) {
vec_diff(temp.x,my.x,target.x); //find the vector from the point the trace hit to the player
vec_normalize(temp.x,16); //get the magnitude of this vector to 16 quants and store in temp
vec_set(camera.x,target.x); //place the camera at the trace hit point
vec_add(camera.x,temp.x); //move the camera away from the wall by the vector temp, 16 quants towards the player
}
wait(1);
}
}
}



Last edited by jigalypuff; 10/01/07 11:03.

Why does everyone like dolphins? Never trust a species which smiles all the time!
Re: whats wrong with this (apart from me) [Re: jigalypuff] #158059
10/01/07 10:19
10/01/07 10:19
Joined: May 2006
Posts: 398
Bot190 Offline
Senior Member
Bot190  Offline
Senior Member

Joined: May 2006
Posts: 398
Did you define "healthpoints" as a skill for "my" before the while?


Wait, there isn't a "Make My Game Now" button?
Re: whats wrong with this (apart from me) [Re: Bot190] #158060
10/01/07 10:23
10/01/07 10:23
Joined: Nov 2005
Posts: 1,007
jigalypuff Offline OP
Serious User
jigalypuff  Offline OP
Serious User

Joined: Nov 2005
Posts: 1,007
define healthpoints, skill18;
yep


Why does everyone like dolphins? Never trust a species which smiles all the time!
Re: whats wrong with this (apart from me) [Re: jigalypuff] #158061
10/01/07 11:28
10/01/07 11:28
Joined: Apr 2005
Posts: 3,076
Germany, NRW
rvL_eXile Offline

3D Artist
rvL_eXile  Offline

3D Artist

Joined: Apr 2005
Posts: 3,076
Germany, NRW
Maybe write it not in the While Loop, take a If function. Like so:

Code:

function fnct_chc_1
{
me = ent_create (chc_1, vector(0,0,0), null);
player = my;
my.scale_x = 1.0;
my.scale_y = my.scale_x;
my.scale_z = my.scale_x;
var ship_speed;
while (1)
{
if(my.healthpoints>0)
{
if (key_w == on)
{
if (ship_speed.x < 1)
{
ship_speed.x += 10.0 * time;
}
.
.
.
}



cYa Sebastian


Tutorials:
[Blender]Terrain creation ENG/GER
[Blender]Low Poly Tree Modeling
[GIMP]Create a Texture for Terrains
CLICK HERE


Re: whats wrong with this (apart from me) [Re: rvL_eXile] #158062
10/01/07 11:53
10/01/07 11:53
Joined: Jun 2001
Posts: 1,004
Dossenbach
N
nfs42 Offline
Serious User
nfs42  Offline
Serious User
N

Joined: Jun 2001
Posts: 1,004
Dossenbach
perhaps
Code:

my.healthpoints = 100;


before the while loop

or is this defined in 'chc_1'?


Andreas
GSTools - Home of
GSTScript 0.9.8: lua scripting for A6/7/8
GSTNet 0.7.9.20: network plugin for A6/7/8
GSTsqlite 1.3.7: sql database plugin for A6/7/8
3DGS Codebase: 57 snippets || 3DGS Downloads: 248 files
Re: whats wrong with this (apart from me) [Re: nfs42] #158063
10/01/07 12:11
10/01/07 12:11
Joined: Nov 2005
Posts: 1,007
jigalypuff Offline OP
Serious User
jigalypuff  Offline OP
Serious User

Joined: Nov 2005
Posts: 1,007
i solved it guys, it was because i had not put my.healthpoints=1000; in the chc_1 function


Why does everyone like dolphins? Never trust a species which smiles all the time!

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1