Gamestudio Links
Zorro Links
Newest Posts
A simple game ...
by VoroneTZ. 06/18/24 10:50
Face player all the time ...
by bbn1982. 06/18/24 10:25
Executing Trades on Next Bar Open
by vicknick. 06/13/24 08:51
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, alibaba, VoroneTZ), 1,225 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19059 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
(REQ) Lite-C tutorial nOOb #280695
07/23/09 20:04
07/23/09 20:04
Joined: Jul 2009
Posts: 39
Chile!
Renard Offline OP
Newbie
Renard  Offline OP
Newbie

Joined: Jul 2009
Posts: 39
Chile!
Hi, i`ve been reading the lite C workshops, but i think it needs more deep info, I mean, "this is how you program the player" or, this is how you make a camera, this definitions, funcions, etc, etc.


WRYYYYYYYYYYYYYYYYYY!!!1!!ONE!!11
Re: (REQ) Lite-C tutorial nOOb [Re: Renard] #280715
07/23/09 22:20
07/23/09 22:20
Joined: May 2004
Posts: 1,510
Denmark
Claus_N Offline
Serious User
Claus_N  Offline
Serious User

Joined: May 2004
Posts: 1,510
Denmark
Hi,

About "how to program the player" is quite hard to tell, as it depends a lot on your game genre, however, you just need how to do the following in Lite-C:

- Moving the player
- Setting the camera position
- Getting input from the player

These are the most basic things you need to know about, for making your player - more stuff could be added later.

- Moving the player

This can be done in a very simple way: simply by changing the x, y and z position of the player. However, doing it that way would allow you to ignore all obstacles and walk straight through anything, as it does not involve collission detection.

Instead, you should be using c_move (check the manual) to move the player, like this:

Code:
action player_script()
{
	while(my)
	{
		c_move(my,vector(my.skill1 * time_step,0,0),nullvector,IGNORE_PASSABLE + GLIDE);
		
		wait(1);
	}
}



I am using "while(my)" to make the loop continue as long as the "my"-entity exists (you could as well use "while(1)" if you are not removing your player somewhere in the code).

The c_move command is moving the "my"-entity (the player) in the direction that the entity is facing, with a speed of "my.skill1 per second", and passable objects are ignored (you can move right through those). Additionally, the "GLIDE" flag allows you to glide along walls, but you'll figure out what that means by experimenting.

All you need to do now, is set skill1 of the entity with the player script, and it will move.

- Setting the camera position

How you want to set the camera depends on your game - it could be first-person, third-person, isometric, or something else. Let's add the code for a first-person camera:

Code:
action player_script()
{
	while(my)
	{
		camera.x = my.x;
		camera.y = my.y;
		camera.z = my.z + 50;
		
		camera.pan = my.pan;
		
		c_move(my,vector(my.skill1 * time_step,0,0),nullvector,IGNORE_PASSABLE + GLIDE);
		
		wait(1);
	}
}



This sets the camera at the player's position (so don't do this if you assign this action to multiple entities!), and adjusts the height to be 50 quants above the player - play a bit with this value.

Then the camera is set to face the same way as the player model (using the pan-axis).

You could set the player entity invisible if you like by using "my.flags |= INVISIBLE".

- Getting input from the player
For getting input from the keyboard keys, you can check e.g. "key_w" to see whether W was pressed - if it returns 0, the key is not pressed, and if it returns 1, it's pressed. For using the mouse to look around, you need to use mouse_force.x and y:

Code:
action player_script()
{
	my.flags |= INVISIBLE;
	
	while(my)
	{
		camera.x = my.x;
		camera.y = my.y;
		camera.z = my.z + 50;
		
		camera.pan = my.pan;
		
		if(key_w)
		{
			my.skill1 = 10;
		}
		else
		{
			my.skill1 = 0;
		}
		
		my.pan -= mouse_force.x;
		camera.tilt += mouse_force.y;
		
		c_move(my,vector(my.skill1 * time_step,0,0),nullvector,IGNORE_PASSABLE + GLIDE);
		
		wait(1);
	}
}


This is by far not the most elegant way of using "key_w", but it is probably the most simple in this case: if W is pressed, the speed is set to 10, and if it's not pressed, the speed is set to 0, which means no movement.

As camera pan is set to the same as the player's pan, you can as well just turn the player (using pan) instead of only the camera, but it doesn't make a difference as long as we don't see the player. The player should keep a constant tilt value though, and you might want to limit camera.tilt to be between e.g. -80 and 80 degrees (check out "clamp" in the manual).

I didn't test the code and wrote it in quite a hurry, but it should give you an idea of how to get started. Also remember, that the manual is one of the best resources available whenever you need coding help wink

Oh, and I know that this wasn't the only thing you asked about, but I don't know any other tutorials which might suit your needs frown But I hope you can use this in any way grin

Re: (REQ) Lite-C tutorial nOOb [Re: Claus_N] #280958
07/24/09 19:32
07/24/09 19:32
Joined: Jul 2009
Posts: 39
Chile!
Renard Offline OP
Newbie
Renard  Offline OP
Newbie

Joined: Jul 2009
Posts: 39
Chile!
Thanks a lot, i`m planning a 3th person camera thought.
but now i have where to start.
I want the camera from the "kingdom hearts movement" tutorial, but i can`t "separate" the camera code from the rest of the code, since my game is a shooter, with little close combat.
Thanks again.


WRYYYYYYYYYYYYYYYYYY!!!1!!ONE!!11
Re: (REQ) Lite-C tutorial nOOb [Re: Renard] #280997
07/24/09 21:07
07/24/09 21:07
Joined: May 2004
Posts: 1,510
Denmark
Claus_N Offline
Serious User
Claus_N  Offline
Serious User

Joined: May 2004
Posts: 1,510
Denmark
I don't know about the "kindom hearts movement" (though I've heard it mentioned before), but you can adjust the camera using simple trigonometry:

camera.x = my.x - fcos(my.pan,100);
camera.y = my.y - fsin(my.pan,100);

This can be used instead of just setting x and y to that of the "my"-entity like in the code I posted above smile

It could be improved by e.g. not letting a wall get in between the player and the camera using c_trace.

Re: (REQ) Lite-C tutorial nOOb [Re: Claus_N] #281608
07/27/09 20:20
07/27/09 20:20
Joined: Jul 2009
Posts: 39
Chile!
Renard Offline OP
Newbie
Renard  Offline OP
Newbie

Joined: Jul 2009
Posts: 39
Chile!
The KH Movement tutorial is on the wiki, anyway, i`ll have to forget about using it, it gets weird results when using c_trace, it uses normal trace, so i`ll use basic trigonometry as you said.

thanks again!


WRYYYYYYYYYYYYYYYYYY!!!1!!ONE!!11
Re: (REQ) Lite-C tutorial nOOb [Re: Renard] #281675
07/28/09 05:09
07/28/09 05:09
Joined: Jul 2007
Posts: 424
EUROPE
maslone1 Offline
Senior Member
maslone1  Offline
Senior Member

Joined: Jul 2007
Posts: 424
EUROPE
I know the KH Movement. And believe me -> scripts like KH Movement is not a good starting point for newbies. Please start with easy things like pong, or have a look at my 2.5D spaceshooter (also to download via AUM 82, or 83 - i cant remember) - a realy good workshop is created by HeelX - the workshop name is "Rudi" on the 3dgs Download-page.

But scripting a shooter-game (as a newbie) is realy - REALY not easy.
(May you could start a 2D shooter)


cheers
Marcel


A8c, Blender, FlStudio, Unity3d
Re: (REQ) Lite-C tutorial nOOb [Re: Claus_N] #281858
07/29/09 01:17
07/29/09 01:17
Joined: Dec 2008
Posts: 83
Buenos Aires, Argentina
F
Funeral Offline
Junior Member
Funeral  Offline
Junior Member
F

Joined: Dec 2008
Posts: 83
Buenos Aires, Argentina
hey am new and i also had that problem it was useful thx
and i would like to know what changes should i do to that script for 3rd person and instead of moving with the mouse and key w with the joystick
i've tried the "joy_force" command but am doing something wrong ...

Re: (REQ) Lite-C tutorial nOOb [Re: Funeral] #281887
07/29/09 08:42
07/29/09 08:42
Joined: May 2004
Posts: 1,510
Denmark
Claus_N Offline
Serious User
Claus_N  Offline
Serious User

Joined: May 2004
Posts: 1,510
Denmark
Check my previous post for getting a 3rd person camera smile

I have never tried using a joystick with 3DGS, however you should be using joy_force.x and y.

Re: (REQ) Lite-C tutorial nOOb [Re: maslone1] #282212
07/30/09 19:53
07/30/09 19:53
Joined: Jul 2009
Posts: 39
Chile!
Renard Offline OP
Newbie
Renard  Offline OP
Newbie

Joined: Jul 2009
Posts: 39
Chile!
Yeah, it`s not a good idea, but i really like the diagonal movement, I`d relly like if someone coud provide a movement code wich allows to run diagonally when pressing W and D or A, AND a function to rotate arms and head to follow the cursor. it`s the only code i need.

BTW, the Rudi tutorial is in German, and I only know English and Spanish.

Last edited by Renard; 07/30/09 19:54.

WRYYYYYYYYYYYYYYYYYY!!!1!!ONE!!11
Re: (REQ) Lite-C tutorial nOOb [Re: Renard] #282233
07/30/09 21:34
07/30/09 21:34
Joined: May 2004
Posts: 1,510
Denmark
Claus_N Offline
Serious User
Claus_N  Offline
Serious User

Joined: May 2004
Posts: 1,510
Denmark
I don't really know how you want it work frown

I don't know the "Rudi" tutorial, and my german is quite bad.

Page 1 of 2 1 2

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