Pages: 1 ... 4 5 [6] 7 8 ... 64
  Print  
Author Topic: Game Maker Help Thread!  (Read 311583 times)
Kegluneq
Big Bossy
Mossy
*
Posts: 2260



View Profile Email
« Reply #75 on: January 16, 2010, 04:24:07 PM »

I gave it a shot, but it's more complex than I thought...
Logged

A wild SHINY MOSSY appeared!
Kirby
Mossy
*
Posts: 1502


Too Long Away

nrmario@hotmail.com
View Profile WWW
« Reply #76 on: January 16, 2010, 07:09:11 PM »

How would I go about editing the rooms that spawn and make paths in game?
Logged

I'm learning Japanese!
Add me on Steam! http://steamcommunity.com/id/KirbyLord/
marsgreekgod
Big Bossy
Mossy
*
Posts: 9806


The will of the Galaxy.


View Profile WWW Email
« Reply #77 on: January 16, 2010, 07:12:56 PM »

http://mossmouth.com/forums/index.php?topic=628.0

this answers you question oh lord of kibry
Logged

Show your power, Gun Del Hell! Show them their fate! Yes! Yes! Yes! Yes! Yes! Here we go! Let's go, go, go, go, Django! Light and Dark! It comes down to this! Be afraid, Sun!
Kirby
Mossy
*
Posts: 1502


Too Long Away

nrmario@hotmail.com
View Profile WWW
« Reply #78 on: January 16, 2010, 07:17:17 PM »

http://mossmouth.com/forums/index.php?topic=628.0

this answers you question oh lord of kibry

THANKS I can probably do a lot with this...
Logged

I'm learning Japanese!
Add me on Steam! http://steamcommunity.com/id/KirbyLord/
Arucard
Mossy
*
Posts: 2811


Hey! Is that CANDY?!?!?

Arucard.Tepes
View Profile Email
« Reply #79 on: January 18, 2010, 02:32:44 PM »

I've hit a snag with the Shopkeeper. The limited ammo is implemented and working fine, but there are two issues I would like to resolve before another release:

1. is purely cosmetic, I can't figure how to get the shotgun sprite to draw only when firing and only when the ammo is >0. I've tried setting it a few places with some interesting results at times, and the closest I've come is to have it appear for a brief second, but before the shot is fired. It doesn't look bad without it, but if I can get it in there I'd like to.

2. is implicit to gameplay, as it stands you will start the game with 7 shells. I have added an item (box of shells) to give 7 more and put it in the shop/box lists. I can't tell if it's not showing up, or if it's giving me bombs instead since I copied and edited the functions from the bomb bag. I also want to take the shotgun out entirely, but that may have to wait until the shells are at least working. The biggest issue I'm having is where to find the functions of items? Is it simply in the hold item script? Steal item?

Anyway, if you can help thanks, I'm about to give in.
« Last Edit: January 21, 2010, 12:03:28 PM by Arucard » Logged

Oh, they look like monsters to you?

There's a light in the darkness of everybody's life.
Kegluneq
Big Bossy
Mossy
*
Posts: 2260



View Profile Email
« Reply #80 on: January 19, 2010, 04:12:38 PM »

More item trouble, this seems to be the bane of everyone's mod right now.
Logged

A wild SHINY MOSSY appeared!
Darkness3313
Mosskid
*
Posts: 710


That reminds me of a puzzle...


View Profile
« Reply #81 on: January 19, 2010, 08:11:12 PM »

And then the answers to everyones questions layed upon us and drew us near and he explained, oh yes he did.








not really.

But seriously, I have a question,
In my Yeti Mod, I'm trying to make it so the Yetis attack is a throw, my question, how do I activate it in the oAction script? I'm not too sure on how to work this.
(Going along well though)

EDIT: Not oAction, the action coding in the oPlayer object.
« Last Edit: January 19, 2010, 08:12:46 PM by Darkness3313 » Logged
DariusK
Bulb
*
Posts: 97



View Profile WWW
« Reply #82 on: January 20, 2010, 08:53:25 AM »

I can't figure how to get the shotgun sprite to draw only when firing and only when the ammo is >0

In the script scrUseItem, line 245,  you see this:

Code:
            if (not scrPlayerIsDucking())
            {
            if (facing == LEFT and firing == 0)
            {
                instance_create(x-9, y+1, oShotgunBlastLeft);
                obj = instance_create(x-9, y-2, oBullet);
                obj.xVel = (-1 * rand(6,8)) + xVel;
                if (obj.xVel >= -6) obj.xVel = -6;
                obj.yVel = 0;
                if (state != HANGING and state != CLIMBING)
                {
                    yVel -= 1;
                    xVel += 1;
                }
                playSound(global.sndShotgun);
                firing = firingPistolMax;
            }

Just add another clause to the if statement, like "and global.ammo > 0". I'm assuming you're using a global ammo variable since that's how bombs and ropes are tracked, plus it'll make it easier to add a new UI element (see below).

You'll want to do the same thing to line 260, which is the same code but for when you're facing right.

Specifically, it's when the game creates oShotgunBlastLeft and oShotgunBlastRight that it displays the muzzle flashes. So you could also put an "if (global.ammo > 0) right before the instance_create for those objects as well.

2. is implicit to gameplay, as it stands you will start the game with 7 shells. I have added an item (box of shells) to give 7 more and put it in the shop/box lists. I can't tell if it's not showing up, or if it's giving me bombs instead since I copied and edited the functions from the bomb bag. I also want to take the shotgun out entirely, but that may have to wait until the shells are at least working. The biggest issue I'm having is where to find the functions of items? Is it simply in the hold item script? Steal item?

Most of the code for what happens when you're holding and using an item is in scrUseItem. That's for active items like guns and the machete and the damsel. What you might want to do is add a new UI element to the top of the screen that shows how much ammo you have -- that way you can tell if your box of shells is working or not. To do this, open up scrDrawHUD and you'll see this:
Code:
if (global.drawHUD and instance_exists(oPlayer1))
{
    lifeX = 8;
    bombX = 64;
    ropeX = 120;
    moneyX = 176;
    draw_set_font(global.myFont);
    draw_set_color(c_white);
    draw_sprite(sHeart, -1, lifeX, 8);
    life = global.plife;
    if (life < 0) life = 0;
    draw_text(lifeX+16, 8, life);
    if (global.hasStickyBombs) draw_sprite(sStickyBombIcon, -1, bombX, 8);
    else draw_sprite(sBombIcon, -1, bombX, 8);
    draw_text(bombX+16, 8, global.bombs);
    draw_sprite(sRopeIcon, -1, ropeX, 8);
    draw_text(ropeX+16, 8, global.rope);
    draw_sprite(sDollarSign, -1, moneyX, 8);
    draw_text(moneyX+16, 8, global.money);

What you'll want to do is create ammoX, which is the X offset of the new ammo UI element. I would actually put it in between rope and money, because money is variable length so you want it at the far right hand side. Then you just add the draw_text() and draw_sprite() functions. I used the sprite for the shotgun in the example below:

Code:
if (global.drawHUD and instance_exists(oPlayer1))
{
    global.ammo = 7; // CHANGE THIS ELSEWHERE IN THE CODE, this is just for test purposes
    lifeX = 8;
    bombX = 64;
    ropeX = 120;
    ammoX = 176;
    moneyX = 232;
    draw_set_font(global.myFont);
    draw_set_color(c_white);
    draw_sprite(sHeart, -1, lifeX, 8);
    life = global.plife;
    if (life < 0) life = 0;
    draw_text(lifeX+16, 8, life);
    if (global.hasStickyBombs) draw_sprite(sStickyBombIcon, -1, bombX, 8);
    else draw_sprite(sBombIcon, -1, bombX, 8);
    draw_text(bombX+16, 8, global.bombs);
    draw_sprite(sRopeIcon, -1, ropeX, 8);
    draw_text(ropeX+16, 8, global.rope);
    // I had to fiddle a bit with the x and y vars here to make things look good
    draw_sprite(sShotgunRight, -1, ammoX, 16);
    draw_text(ammoX+8, 8, global.ammo);
    draw_sprite(sDollarSign, -1, moneyX, 8);   
    draw_text(moneyX+16, 8, global.money);


Logged

DariusK
Bulb
*
Posts: 97



View Profile WWW
« Reply #83 on: January 20, 2010, 08:54:52 AM »

Of course, I just noticed that Arucard already fixed his problems!

I guess I'll take the post I just did and post it as a mini-tutorial on how to implement a new inventory item type.
Logged

Arucard
Mossy
*
Posts: 2811


Hey! Is that CANDY?!?!?

Arucard.Tepes
View Profile Email
« Reply #84 on: January 20, 2010, 12:07:14 PM »

Of course, I just noticed that Arucard already fixed his problems!

I guess I'll take the post I just did and post it as a mini-tutorial on how to implement a new inventory item type.
Mostly, anyway. I had already done the bulk of what you suggested with a global ammo, drawing on the HUD, etc. I still need to figure where to set the function for drawing the sprite in his hand temporarily when shooting. I think I could make it show up the whole time he has ammo, but picking up other items would look silly.

I put this in the draw event of the player object, and ended up at one point getting a brief glimpse of the gun, but only the split second after pushing the button. I guess my confusion is in the drawing of sprites, if I make a seperate script and have that script checked when pressing attack might that work? Or is it limited to the draw event?

Code:
kAttackPressed = checkAttackPressed ()
if (kAttackPressed and global.ammo >0 and facing == LEFT and !scrPlayerIsDucking)
{
draw_sprite (sShotgunLeft,0,x-6,y+1)
}
    else if (kAttackPressed and global.ammo >0 and facing == RIGHT and !scrPlayerIsDucking)
{
draw_sprite (sShotgunRight,0,x+8,y+1)
}
P.S. the coordinates on that may be wonky, I thought it was showing up right under the blast and tried to get it out of the way.  Tongue
Logged

Oh, they look like monsters to you?

There's a light in the darkness of everybody's life.
DariusK
Bulb
*
Posts: 97



View Profile WWW
« Reply #85 on: January 20, 2010, 01:02:19 PM »

I put this in the draw event of the player object, and ended up at one point getting a brief glimpse of the gun, but only the split second after pushing the button.
What you want is to put in a timer somewhere. There are plenty of examples of timers all over the code, but basically when the gun is fired you want to set showShotgunTimer = 1000 (or whatever value), and then something like

Code:
if (kAttackPressed and global.ammo >0 and facing == LEFT and !scrPlayerIsDucking and showShotgunTimer > 0)
{
draw_sprite (sShotgunLeft,0,x-6,y+1);
showShotgunTimer -= 1;
}
Logged

Arucard
Mossy
*
Posts: 2811


Hey! Is that CANDY?!?!?

Arucard.Tepes
View Profile Email
« Reply #86 on: January 20, 2010, 02:57:56 PM »

Alright thanks, I'll see if I can get that to work. It's funny the stuff I was able to figure out and this freaking sprite not showing up is what's really killing me.  Sad
Logged

Oh, they look like monsters to you?

There's a light in the darkness of everybody's life.
Kegluneq
Big Bossy
Mossy
*
Posts: 2260



View Profile Email
« Reply #87 on: January 20, 2010, 03:03:48 PM »

Okay then, my turn.

I need help finding where the code for picking up items is.
I've looked everywhere (everywhere that isn't where what I need is) and can't find it, anyone know the exact location?
Logged

A wild SHINY MOSSY appeared!
DariusK
Bulb
*
Posts: 97



View Profile WWW
« Reply #88 on: January 20, 2010, 03:12:09 PM »

If you mean the code where you press down and attack and pick something up, it is in the oPlayer1 object, in the Step Event, in the second block of code, line 807. It starts like this:

Code:
    else if (kAttackPressed and kDown)
    {
        // pick up item
        if (collision_rectangle(x-8, y, x+8, y+8, oItem, 0, 0))
        {
            obj = instance_nearest(x, y, oItem);
            if (obj.canPickUp and not collision_point(obj.x, obj.y, oSolid, 0, 0))
            {
                holdItem = obj;
                holdItem.held = true;
                whoaTimer = whoaTimerMax;
                pickupItemType = holdItem.type;

That's the code that says "if I'm pressing down and attack and I'm on top of an object, set my holdItem to that object and set that object's 'held' variable to be true."
Logged

Kegluneq
Big Bossy
Mossy
*
Posts: 2260



View Profile Email
« Reply #89 on: January 20, 2010, 03:34:34 PM »

There it is! Such a small block of code, I imagined it would of been a little bigger.

Thanks a lot!
Now the MP mod can get back under development!
Logged

A wild SHINY MOSSY appeared!
Pages: 1 ... 4 5 [6] 7 8 ... 64
  Print  
 
Jump to: