Jump to content


kiznal

Member Since 02 Jul 2011
Offline Last Active Apr 29 2013 05:07 AM

Topics I've Started

Beat-Em-Up Attack Problem

08 March 2013 - 01:59 AM

So I'm trying to make a 2D fighting game with stick men. I already have all the sprites figured out and have implemented a few controls and I've run into a problem: actually hitting enemies. Right now I have it so when the player pressed the attack button, the animation starts to play and an alarm is set. In the middle of the animation, the alarm reaches 0 and the code for attacking is this:

if image_xscale = 1 {
    var i;
    for (i=0; i<=40; i+=1) {
        if place_meeting(x+i,y,obj_hitable) {
        instance_create(x+i,y,obj_impact)
            with instance_position(x+i,y,obj_hitable) {
            event_user(0);
            }
        break;
        }
    }
} 

if image_xscale = -1 {
    var i;
    for (i=0; i<=40; i+=1)
    if place_meeting(x-40,y,obj_hitable) {
    instance_create(x-40,y,obj_impact)
        with instance_position(x-40,y,obj_hitable) {
        event_user(0);
        }
    exit;
    }
}

I was trying to do a sort of hitscan thingie where it starts out from obj_player.x and loops until i hits 40, that way you don't have to hit the enemy right on to do damage... but this way I don't hit him at all. Any thoughts?

Third-Person Shooter Camera Angle

22 February 2013 - 09:37 PM

In designing a basic 3rd person shooter, I have everything figured out except for the camera. Because the camera is external to the player, every time the player turns, the camera turns also. But if the player is in a hallway and turns, then the camera goes through the wall and can't see the player anymore. What would be a good way to fix this problem? Ideally have the camera get closer to the player so it doesn't go through walls, but having the walls disappear or go 0.3 alpha or something would be fine too.

Here's a gmk file with my work on it. Normal FPS controls. Hold the right mouse button to zoom in! (you can only shoot when zoomed in)

Screens:

You can see on the left the camera is doing its job, but on the right the camera is beginning to go into the wall because the player is turning.

Posted Image Posted Image

Sliding against all kinds of walls

02 February 2013 - 04:15 AM

Remember how in the FPS tutorial, you could slide against those wonderful 90-degree walls when you ran into them at an angle? The code for that was wonderful, but it only worked for straight walls.

Here's an example that allows for sliding agains ALL kinds of walls! Straight, slanted, curved! It's all in this .gmk.

Note: I did not write the move_player script for this. I found somewhere on this website. I think Tepi wrote it, but I don't remember. All I did was impliment the script into the FPS example.

Posted Image

Fps Example With Multiple Guns, Enemies

11 January 2013 - 04:14 AM

  • Title: FPS example with multiple guns, enemies
  • Description: An updated version of Mark Overmars FPS tutorial
  • GM Version: :GM8:
  • Registered: Yes (uses 3D)
  • File Type: .gmk
  • File Size: 3MB
  • File Link: .gmk .exe
  • Required Extension: none
  • Required DLL: none
  • Tags: tutorial, FPS

Updates:
Jan 15: Updated .gmk file. There was a bug where bullets wouldn't hurt the brown monsters.
Jan 16: Added a .exe also so people can play it whether they have registered or not.
Jan 18: So it appears there's a problem with 8.0 lighting not working with 8.1. So I updated the .gmk file by adding a light switch. The game starts with lighting off. Hit L to turn the lighting on.
Feb 16: Big update. - Added movement that slides agains all shapes of walls (not just 90-degree ones).
- Added multiple kinds of walls (diamonds, diagonal, pillars)
- Added enemy blood;
- Added a 4th enemy.
- Added outside environments (skybox, grass)
- Added death cam.
- Added levels of ground so the game isn't so flat and 2D looking
- Added doors that open AND close
- Added switches that you activate to go to the next level.

Summary:
This is a very heavily modified and commented version of the FPS tutorial for GameMaker. Great for easy first person shooters.

Features:
- sprite models (script by Cubasy)
- multiple guns (pistol, rifle, shotgun, chaingun, plasma rifle, rocket launcher, BFG 9000)
- multiple types of ammo (bullets, shells, rockets, and energy cells)
- secret stuff (i.e. doors that look like walls...)
- lava that you can fall into
- enemy ai (shooting, seeking out player)
- four types of enemies (all from DOOM)
- enemy in-fighting (between species)
- player death animation
- doors that open and shut
- enemy blood! (toggle on/off with <G>)
- slanted/circular walls!
- player now bobs when running
- outdoor environments
- different levels of ground
- end-level switches. I put on at the beginning of each level too so you can easily go from one level to the next.

I tried to comment most of the code.
Please leave feedback! Constructive criticism, compliments and questions are welcome. I'll try to fix any glitches reported.
I hope you like this example.

And remember, I based this example off Mark Overmars' original FPS tutorial. I just heavily edited and modified it. I claim no credit for any of the graphics (I believe they're all from DOOM) or any of the code that Mr. Overmars wrote.

Have fun with this, y'all!

In-Fighting: you can also see the sprite models at work here!
Posted Image

Blood:
Posted Image

Obviously, my favorite weapon is the shotgun. haha :)

Outdoors:
Posted Image

Levels of ground:
Posted Image

billboard sprite makes other things invisible

23 December 2012 - 01:19 AM

I found a script that makes "3D" models out of a series of 2D pictures, like in DOOM. The sprites are drawn on a invisible wall that rotates toward the player object, also known as a billboard, (like in the FPS tutorial). Because the sprites change upon direction, it sorta looks 3D.

Having this script, I tried to make a fireball that the enemy shoots at you. But, when the fireball is drawn, if it is in front of another object, like a plant, the collision mask of the 2D sprite completely erases the part of the plant that is behind it. Screenshot. See how the fireball is erasing part of the plant? I have absolutely no idea why this is happening. I tried messing around with the image_alpha and stuff, but I don't think that's it. Another thing about this glitch is that the walls aren't blocked out or anything. It's just other objects within the rooms like plants and monsters and stuff (that are also drawn on billboards).

Here's the link to my .gmk file. In the room that the player starts off in I placed a non-moving fireball so it's easy to see the erasing thing. Just move to the right and left, and the fireball sprite blocks out the plants.
Controls are WASD, mouse to look and shoot. The monster AI is changed a bit from the original tutorial, too. I haven't really done anything else with it, I was just seeing if this problem was the same in 8.0 as in Studio (it is).



The other problem I have is specific to GameMaker:Studio. This time, not only do the sprite collision masks block out background objects, but the sprites are stretched in a weird way. I set the size of the sprite to be the same for all 8 directional sprites (again, the 3D sprite model). Since it's a fireball that we're drawing, some of the pictures have a trail of smoke behind them (looking at the fireball from the front you don't see any smoke, but looking at it from the side, you can. It's the same fireball as in the above example). But this time the longer sprites (with the smoke and flames) are stretched smaller, to the size of the head-on view fireball (with no smoke). I have no idea why this is happening. I have played around with the collision masks, precise collision checking, and none of those seem to work. This problem is only in Studio, not 8.0.

If anyone has a solution for either of these problems, please let me know. Thanks! :)/>/>