GameMakerHelpBlog

Saturday, November 25, 2006

3D - FPS full

I put about the Start of 3D b4 but lets put it to the test......
Create event
[code]
{
friction = 0.2;
// initialize 3D
d3d_start();
d3d_set_hidden(true);
d3d_set_lighting(false);
d3d_set_culling(false);
d3d_set_fog(true,c_white,10,300);
// interpolate textures
texture_set_interpolation(true);
}
[/code]
Create event too
[code]
{
global.camx = x;
global.camy = y;
global.camsin = sin(direction*pi/180);
global.camcos = cos(direction*pi/180);
}
[/code]
^this uses pi for this code.
End step event
[code]
{
global.camx = x;
global.camy = y;
global.camsin = sin(direction*pi/180);
global.camcos = cos(direction*pi/180);
}
[/code]
Left arrow key event
[code]
direction+=3
[/code]
Right arrow key event
[code]
direction-=3
[/code]
Up arrow key event
[code]
{
var maxspeed;
if keyboard_check(vk_shift) maxspeed = 3 else maxspeed = 1.5;
if (speed < speed =" min(maxspeed" maxspeed =" 3" maxspeed =" 1.5;"> -maxspeed) speed = max(-maxspeed,speed-0.4);
}
[/code]
draw event includes arguments
argument0 = floor background
argument1 = sky background
[code]
{
// set the projection
d3d_set_projection(x,y,10, x+cos(direction*pi/180),y-sin(direction*pi/180),10, 0,0,1);
// set color and transparency
draw_set_alpha(1);
draw_set_color(c_white);
// draw floor and ceiling
d3d_draw_floor(0,0,0,room_width,room_height,0,
background_get_texture(argument0),32,32);
d3d_draw_floor(0,0,32,room_width,room_height,32,
background_get_texture(argument1),24,24);
}
[/code]
This should make a basic FPS game if not please tell me

Labels:

3D - Start

this code will start the 3D world for FPS but not actually show it i will post more turtorials to do that later
In create event
[code]
{
friction = 0.2;
// initialize 3D
d3d_start();
d3d_set_hidden(true);
d3d_set_lighting(false);
d3d_set_culling(false);
d3d_set_fog(true,c_white,10,300);
// interpolate textures
texture_set_interpolation(true);
}
[/code]
This will set fog and other stuff that doesn't effect your game

Coming soon: Camera 3D FPS Code

Mplay - GM Function

This is a simple Server for GM Mplay This doesn't include the movement or messaging but the basics of setting up a server people join. Warning: Must have a little knowledge of GML

Remember: [code]&[/code] doesn't mean anything with GM and will muck up your code
[code]
str=get_string("ip address",'')
mplay_init_tcpip(str)
[/code]
^^this code is for init a tcpip connection
[code]
//create a server

{
if (mplay_session_create('',2,''))
{
global.master = true;
room_goto_next();
}
else
show_message('Failed to create a session.')
}
[/code]
^^Note this has a max of 2 players due to lag or slowness in the connection
[code]
//join a server

{
if (mplay_session_find() > 0)
{
if (mplay_session_join(0,''))
{
global.master = false;
room_goto_next();
}
else
show_message('Failed to join a session.')
}
else
show_message('No session available to join.')
}
[/code]
^^This will join the server you request

This is all for now... To find movement check up this later

Labels:

Moving Mouse 3 - RTS style

This is an RTS style movement system , can be used for topdown too...

This has more than one part to it so we will go through it 1 by 1
1. In create event (stuff the color coding for this turtorial) Put this code
[code]
target_x=x;
target_y=y;
[/code]
(oh i should say don't add the code tags)
This code above should init the target variables for your guy to move too.
2. In step event This code checks whether you have met your mouse clicked position put this code
[code]

/ If we didn't reach the target pos yet..
dist=point_distance(x, y, target_x, target_y);
if(dist>0) {
// Move towards it.
direction=point_direction(x, y, target_x, target_y);
speed=min(dist, 4);
} else {
// Otherwise stop moving.
speed=0;
}
[/code]
3. In global.left pressed in mouse event. This code will move you to the target Put this code
[code]
//argument0 = player object or allied
(argument0).target_x=mouse_x; //player object = argument0
(argument0).target_y=mouse_y;

Labels:

Shooting in Topdown

Hi

This is to do with the shooting in topdown games. It is best to use the mouse_movement 1 with this.
[code]
//argument0 = player
//argument1 = speed
direction=argument0.direction
image_angle=direction
speed=argument1
[/code]
This code needs to be put in create and you need to change argument 0 and 1 to the green bit in the Script editior in GameMaker

Labels:

Mouse Movement 1

Hi

This is a simple Mouse Movement Script for you for topdown games. It is better than having to make 36 sub images :)

How to do it:

[Code]
direction=point_direction(x,y,mouse_x,mouse_y)
image_angle=direction
[/code]

Labels:

Welcome

Hi

Welcome to the GameMakerHelpBlog. My username is Millzyman or the_true_millzyman on the GMC UGMC and the GMH. this webblog was created to help newbies with there troubles or post examples of my work and others..

The founders of this were Millzyman and GameMakerMaster...

I was lucky to get GameMakerMaster on cause he is a little bit to loyal to the GMH.....

Enjoy your stay

FAQ's
Q. Do i add [code]&[/code] to the GML script
A. No it is there to tell you that it is a script

Q. Can i contribute to GameMakerHelpBlog
A. Yes please e-mail me at millzyman1@hotmail.com or go to the GameMakerHelpForum (side at links) and join and PM me or create a topic in examples

Labels: