Gw Temp

Menu

Tutorial - 'FPS System' by Dimensionwyrm

An item about RPGMaker 2000 posted on

Blurb

Dimensionwyrm/Lunchman introduces the basics to building a basic FPS-style shooting system without enemy attacking.

Body


A NOTE BEFORE BEGINNING: This tutorial IS NOT meant for complete newbies, and I will not reference everything constantly, you will be expected to know what I mean.
SIDE NOTE:I’ve just noticed, after finishing this tutorial, that you only need the top left and bottom right coordinates for step 3. Don’t do all four.


Today I’ll be teaching you how to create an FPS battle system! Okay, DON’T get all excited and start thinking “Oh boy! I’m gonna make a Halo fangame!” It’s not going to happen. Rm2k doesn’t support 3d graphics; this only implements a shooting system. I won’t do enemy attacking either, that might be in a later tutorial. To begin, you’ll need knowledge of the following.

-Good knowledge of implementing and manipulating variables.

-Knowledge of using pictures

-Basic knowledge of rm2k(3)

-The use of pages in events


Step 1

We’ll begin by setting up the targeting system. Make a new map, 20x15.
Make some panorama (this will be the environment in which you’ll fight. Fill all the squares with the blank ones. Make a new event, set to autostart. In page 1, have no start conditions, blank graphic. First have it shot a picture of a crosshair at the coordinates (160, 120). This will place the cross hair at the middle of the page. Now make a picture of a hand holding the weapon at the coordinates (160, x). Replace x with the height of the hand picture divided by 2. So if the height of the graphic is 28, you’d use the coordinates (160, 28). Make sure the crosshair picture is a lower number than the gun. Then set the variable Crosshair X and Crosshair Y to the correct values. Now turn on a switch labeled Begin fight. Make a page 2, triggered by the switch we just made. Make it a parallel process. First set a new variable, Key input, to 0. Then make an Enter Key command, set to the keys Up, Down, Left, Right, and Space. Now make a series of forks to check the direction or key pressed. In the four directional ones, for right have it increase the variable Crosshair X by x. Set x to however number of pixels you want the crosshair to move. 5-10 works well in my opinion. Do the same for each direction, except changing which variable is changed and how (increase/decrease). Pretty basic. Before going on to doing the directional key, which we will work on in Step 3, we’ll go on to moving the pictures. Just reshow the crosshair, with the X and Y positions being the coordinate variables we set earlier. Now reshow the hand, with the same Y value (do this by making a new variable then set that variable to the height of the picture divided by 2, then use that variable) and use same X value as the crosshair. Not very complicated either.


Step 2

In this step we will begin setting up the enemy, and the enemy’s movements. This will be a difficult thing to do, as you will be randomly moving a picture, and when shooting, will need the X/Y values of each corner. First of all, get the picture of the enemy. Next, go into the first page of the earlier event, and, before turning on the switch, have it show the enemy too (values 160, 120). Now, begin setting up movement by creating a new parallel process event. Have it basically set a new variable, random movement, to 1-x. x is the number of different movement ways the enemy will have. I suggest at least 10 or it’ll be really easy. Now make a series of forks to determine which number was drawn. In each fork, just move the picture in the way you want. Just remember to set it to ‘wait until done’. This tells rm2k to wait until that process is all finished before looping. This is the easiest step, and we’ll now move on to the hardest.


Step 3

In this last step the shooting will be done. This will be the most complicated part, so if you don’t understand, reread the sentence and try to figure out what I mean.

First of all, go back to page two of the first event, the page with moving the crosshairs. In the shooting fork, have it play a sound effect first. Then set a bullet(s) picture to X and Y coordinates of the gun. Having a lower number than the gun would be better. Now simply move it up to the coordinates of the crosshair really fast (.1-.3 seconds). Then the hard part. First draw an imaginary line on the diagonal from the top left to the bottom right and top right to the bottom left (on the enemy picture). Once you have the coordinates of the center (the place where the two lines meet), find how many pixels to the right and down compared to the top left corner. Once you have this, use the coordinates of the picture (the center), subtract the distance horizontally and vertically, and then you’ll have the coordinates of the top left corner. Repeat for every other corner. Once you have coordinates of each corner, read on.

Now that you have those coordinates, use forks to determine if the coordinates of the crosshair are:

X Coordinates

Crosshair (CH) is more than Top-left (TL)
CH greater than TR
CH Less than BL
CH Less than BR
Y Coordinates

CH Less than TL
CH Less than TR
CH Greater than BL
CH Greater than BR

If all that is true, lower the enemy’s health and use a fork to determine if it’s dead.
Congratulations! Now you have an FPS-type shooting system!

If you want to know the layers of each picture (which goes above another) then here:

Gun over Bullet over Crosshair over Enemy