Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (sleakz, AndrewAMD), 684 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
function moveCamera() { #461967
08/31/16 15:04
08/31/16 15:04
Joined: Aug 2016
Posts: 5
N
NiceOneX Offline OP
Newbie
NiceOneX  Offline OP
Newbie
N

Joined: Aug 2016
Posts: 5
Hey guys smile ,
I'm new here in the forum and would like to learn how to programiert games. grin
I bought a book that something helps me. However, I have the same at the beginning a problem with my script ...

Although the level loads but the function with the camera can not be performed. I thank you in advance for the help.

and sorry for my bad english tired


Script:
Code:
#include <acknex.h>
#include <default.c>

#define WALK_SPEED 5

function moveCamera() {
	
	VECTOR* vecNewAngle = NULL;
	VECTOR* vecNewPosition = NULL;
	
	while(1) {
		vecNewAngle = vector(
			(camera.pan+(key_a-key_d)*time_step*WALK_SPEED)%360,
				0,
				0
			);
		
		vec_set(camera.pan,vecNewAngle);
		
		vecNewPosition = vector(
		camera.x+(key_w-key_s)*cosv(camera.pan)*time_step*WALK_SPEED,
		camera.y+(key_w-key_s)*sinv(camera.pan)*time_step*WALK_SPEED,
		0
		);
		
		vec_set(camera.x, vecNewPosition);
		
		wait(1);	
	}
}

function main() {
	level_load("terrain1.hmp");
	VECTOR* vecPosition = vector(0,0,0);
	ent_create("world1.mdl",vecPosition,NULL);
	moveCamera();
}



Last edited by NiceOneX; 08/31/16 15:50.
Re: function moveCamera() { [Re: NiceOneX] #461968
08/31/16 15:26
08/31/16 15:26
Joined: Jul 2008
Posts: 2,107
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,107
Germany
Hi and welcome on board.

The code itself seams to be ok ( i mean it runs without errors )

Create a Terrain (HMP) and a model file (MDL). Both with MED. Then your script will run. Pretty sure it cant load one of those files.

Or create a simple map (WMB) with WED. And modify your main function like this
Code:
function main() {
	level_load("yourlevel.wmb");

	moveCamera();
}



Guess problem now is your script / game cant found those files loaded from here
Code:
level_load("terrain1.hmp");
ent_create("world.mdl",vecPosition,NULL);



edit:
If you write your code here in the forum between [ c o d e ] and [ / c o d e ] but without the empty spaces your text will appear in a codebox and will be much more easy to read grin

edit2:
I made another very simple example. Create a map with WED. For example just a hollowed block. Save it as "yourlevel.wmp". Build the map ( will create the WMB file ).
Create a new script file with the following code
Code:
#include <acknex.h>
#include <default.c>

#define WALK_SPEED skill1   // mask skill1 of ent with WALK_SPEED
#define HEALTH     skill2   // same here but with health and skill2


action simpleHero(){        // actions will apear in the WED action list of your script
	my.WALK_SPEED = 6;       // set our speed 
	my.HEALTH     = 100;     // 100 lifepoints
	VECTOR dist;             // a vector for distance ent is moving
	while (my.HEALTH > 0){   // as long as weve lifepoints were looping the code below
		dist.x = ((key_w - key_s) * my.WALK_SPEED) * time_step; // forward backward moving
		dist.y = ((key_a - key_d) * my.WALK_SPEED) * time_step; // side moving
		move_mode = IGNORE_ME | IGNORE_PASSABLE | GLIDE;        // used from c_move below
		c_move (me, vector (dist.x, dist.y, 0), nullvector, move_mode); // finally move the ent!
		my.pan -= mickey.x * time_step;		 // handle PAN of entity ( left - right looking )
		vec_set (camera.x, my.x);            // set camera XYZ to entitys XYZ (follow)
		camera.pan = my.pan;                 // set camera PAN to ent pan
		camera.roll = 0;
		camera.tilt -= mickey.y * time_step; // handle camera TILT ( up - down looking )
		camera.tilt = clamp (camera.tilt, -85, 85); // clamp the camera TILT value
		wait (1); // wait one frame
	}
}

void main() {
	level_load("yourlevel.wmb"); // load the level created in WED
	ent_create("player.mdl", vector (0,0,0), simpleHero); // load your hero / player
	// needs two files in the folder: yourlevel.wmb and your player entity player.mdl
}



Greets



Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;
Re: function moveCamera() { [Re: rayp] #461971
08/31/16 15:56
08/31/16 15:56
Joined: Aug 2016
Posts: 5
N
NiceOneX Offline OP
Newbie
NiceOneX  Offline OP
Newbie
N

Joined: Aug 2016
Posts: 5
I'm already so many things tried. but every time loads only the level but the camera still does not move with the keys goes. =/

Re: function moveCamera() { [Re: NiceOneX] #461972
08/31/16 16:03
08/31/16 16:03
Joined: Jul 2008
Posts: 2,107
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,107
Germany
When i tested the function first, i only saw a blue Screen / sky caused by the empty placeholder models i used. Try with a hollowed block created in WED. Pretty sure with the code is everything ok.

edit: Or try my example, maybe it fit what you Needs.

Last edited by rayp; 08/31/16 16:05.

Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;
Re: function moveCamera() { [Re: rayp] #461973
08/31/16 16:18
08/31/16 16:18
Joined: Aug 2016
Posts: 5
N
NiceOneX Offline OP
Newbie
NiceOneX  Offline OP
Newbie
N

Joined: Aug 2016
Posts: 5
okay thanks for the help, I'll try it this way =)

Re: function moveCamera() { [Re: NiceOneX] #461974
08/31/16 16:23
08/31/16 16:23
Joined: Jul 2008
Posts: 2,107
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,107
Germany
No problem you are welcome. Good luck. wink


Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;
Re: function moveCamera() { [Re: rayp] #462003
09/02/16 10:01
09/02/16 10:01
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline
Serious User
Reconnoiter  Offline
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Hi NiceOneX welcome to do the forum.
Since your new; incase you want better shaders (/better graphics) for your game you may want to take a look at 'Shade-C EVO' on this forum or on Github.
That is a package that you can include in your script and which gives access to improved hdr, normal mapping, ssao etc.
You could basically see it as an upgrade over Gamestudio graphics wise.
Here is an usefull thread that you should rease incase you are going to use it and/or get stuck (you can also ask questions there): http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=461868&page=1


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