Jump to content


Chilisoup

Member Since 26 Jul 2008
Offline Last Active Apr 26 2011 11:22 PM

Topics I've Started

Mobs of zombies

26 April 2011 - 06:23 PM

I have a feeling im going to flood the entire forums with questions of every other step of my project...but here we go.

I have a zombie object (named 'obj_red') who will chase down the player if he's close enough. That works fine, but I wanted to add a kind of 'horde' feeling to the zombies AI, so I included some minor additions to my code, and made a 'chase' variable. They're behavior is a little funny, and they will follow me just fine if I enter their range, but I can't quite figure out their pattern, and if its what I aimed for. Help please?

Obj_Red step event
Spoiler

Drawing Sprites with Animation

26 April 2011 - 01:58 AM

So I have an object that I want to use two different sprites for. It's overhead, and i want to have spr_body be on top of spr_legs.

From my (very limited; this is day three of messing with GML instead of drag n drop xD) understanding of GML, I thought it best to set in the DRAW event to 'draw_sprite(spr_legs,0,self.x,self.y) and then repeat that for the body sprite on top of it. But i realized that it only draws the single subimage of the sprite that i specified. That's great for standing still, but what if i want his legs to move? I looked in the Help thing built in to Gamemaker, but I can't seem to find anything about 'draw_sprite(blahblahblah) with animations.

First off, am I going at this the right way? I don't want to use two seperate object (Legs and Body), and is it best to 'draw_sprite(blahblahblah) here?

and second, if I'm in the right general direction, what myserious command can't I find that allows animation? I've tried image_speed = x.

I really want to get a better comprehension of GML

THANKS :)

Draw_set_alpha?

24 April 2011 - 11:39 PM

So, im new to gamemaker, and I know im probably always doing things the wrong, or complicated way, but thats part of the learning experience right? Well I came across a hiccup that I honestly can't make any sense of. I integrated a 'day/night/ system into my game, by setting 2 global variables (minutes and hours), and for the lighting effect, I simply made the same object that determines the time, draw a large, black, transparent rectangle on the screen, covering the whole thing. I then coded it, so when the 'Hours' variable is at certain values, it changes the alpha, and draws a new rectangle. It works fine up until 6 am, then at 8 am, it gets really dark, and then at 8 pm, things start to work again. Heres my code


if global.hours <6//before 6 am
    {
    draw_set_color(c_black)
    draw_set_alpha(.7)
    draw_rectangle(obj_hero.x-800,obj_hero.y-800,obj_hero.x+800,obj_hero.y+800,false)
    }
if global.hours >= 6  //after 6 am
    {
    draw_set_color(c_black)
    draw_set_alpha(.6)
    draw_rectangle(obj_hero.x-800,obj_hero.y-800,obj_hero.x+800,obj_hero.y+800,false)
    }
if global.hours >= 8      //after 8 am
    {
    draw_set_color(c_black)
    draw_set_alpha(.5)
    draw_rectangle(obj_hero.x-800,obj_hero.y-800,obj_hero.x+800,obj_hero.y+800,false)
    }
if global.hours >= 9    //after 9 am
    {
    draw_set_color(c_black)
    draw_set_alpha(.4)
    draw_rectangle(obj_hero.x-800,obj_hero.y-800,obj_hero.x+800,obj_hero.y+800,false)
    }
if global.hours >= 12   //after noon
    {
    draw_set_color(c_black)
    draw_set_alpha(.2)
    draw_rectangle(obj_hero.x-800,obj_hero.y-800,obj_hero.x+800,obj_hero.y+800,false)
    }
if global.hours >= 19  <7 //after 7 pm
    {
    draw_set_color(c_black)
    draw_set_alpha(.6)
    draw_rectangle(obj_hero.x-800,obj_hero.y-800,obj_hero.x+800,obj_hero.y+800,false)
    }
if global.hours >= 19   //after 7:30 pm
    {
    if global.minutes =30
    {
    draw_set_color(c_black)
    draw_set_alpha(.7)
    draw_rectangle(obj_hero.x-800,obj_hero.y-800,obj_hero.x+800,obj_hero.y+800,false)
    }}
if global.hours >= 20   //after 8 pm
    {
    draw_set_color(c_black)
    draw_set_alpha(.8)
    draw_rectangle(obj_hero.x-800,obj_hero.y-800,obj_hero.x+800,obj_hero.y+800,false)
    }
if global.hours >= 20   //after 10 pm
    {
    draw_set_color(c_black)
    draw_set_alpha(.9)
    draw_rectangle(obj_hero.x-800,obj_hero.y-800,obj_hero.x+800,obj_hero.y+800,false)
    }

Whats going on?

Drawn Inventory (Duplicate Items)

24 April 2011 - 10:08 PM

Hello, I have decided to get back into Game Maker, and everything is going pretty good so far, except one bug I can't seem to figure out.

I have an object(obj_inventory) that draws an inventory, and it's slots just fine. And I have an object (obj_handgun) which, is supposed to go into JUST the first slot, but my one handgun, will appear in both of my present inventory slots.

'Handgun' Create
global.handgun += 1 //only true when created for testing sake, its my only item as of now

'Handgun' Step
//Inventory checking code
if global.inv1 = false
{
global.inv1 = global.handgun
exit
}
else
if global.inv2 = false
{
global.inv2 = global.handgun
exit
}
else
exit

'inventory' create
global.inv1 = false
global.inv2 = false

'inventory' draw
draw_roundrect(obj_hero.x-200,obj_hero.y-385,obj_hero.x-150,obj_hero.y-335,true) //Invenrory Slot 1

if global.inv1 = false
{
exit
}
else
if global.inv1 = global.handgun {
draw_sprite(spr_handgun,0,obj_hero.x-200,obj_hero.y-385)

}

draw_roundrect(obj_hero.x-100,obj_hero.y-385,obj_hero.x-50,obj_hero.y-335,true) //Inventory Slot 2
if global.inv2 = false
{
exit
}
else
if global.inv2 = global.handgun {
draw_sprite(spr_handgun,0,obj_hero.x-100,obj_hero.y-385)
}


I only want ONE handgun in my inventory, whats wrong with my code?

Wtf Is Wrong Here?

28 July 2008 - 08:50 PM

So i set some mp for my character in my game, this spell uses up 15 mp and clearly i dont want to be able to launch the spell when i dont have enough mana so this simple little problem was solved with just a little code
if mp >= 15
sprite_index=Casting
alarm[2]=10
...but it doesnt work...the mana just keeps going into the negatives. Whats going on?