Jump to content


JamEngulfer221

Member Since 20 Jan 2012
Offline Last Active Apr 21 2012 09:58 PM

Posts I've Made

In Topic: Drawing a line to a point around a circle

26 February 2012 - 05:16 PM

Some awesome code.


Thank you so much! It worked perfectly!

In Topic: Draw event not recognising variables

10 February 2012 - 05:35 PM

Thanks! That works brilliantly, except for one thing.

I want to draw variables instead of text. I have all of that done and it works fine, however, I have 5 individual buttons that all have different values for this variables. I currently have 4 of those towers set with btn_tower_laser as their parent, but no matter how much I try, I can't get them to all draw the different variables. Can I have some help on this?

Parent Draw event:

//  Draw the sprite and the required price

{
    draw_sprite(sprite_index,image_index,x,y);
    if image_index = 1
    {
        draw_set_color(c_white);
        draw_set_font(ft_hud);
        draw_text(x,y,price);
    }
     var width, height, range, rate, damage, name;
         range = 200;
         rate = 3;
         damage = 10;
         name = 'Laser';
         width = sprite_get_width(sprite_index)/2;
         height = sprite_get_height(sprite_index)/2;

         if mouse_x>x-width and mouse_x<x+width and
         mouse_y >y-height and mouse_y<y+height
     {
        draw_set_font(ft_header);
        draw_text(400,2,name);
        draw_set_font(ft_hud);
        draw_text(400,32,'Damage: '+string(damage)+' HP');
        draw_text(400,48,'Range: '+string(range));
        draw_text(400,64,'Fire rate: '+string(rate)+' shots/second');
        draw_text(400,80,'Selling price: '+string(floor(price/2)));
    }
}

In Topic: Unknown variable in referenced object

05 February 2012 - 07:43 AM


with(x)  //where x = id of a Tower_Laser instance
{
   draw_text();
}



Remove the 'obj_tower_laser.' prefix in your draw_text script


Well, the thing is, I want to have it display the stats of the tower when you mouse over the button, before you click on it. Also, the game is the one linked in my signature.

In Topic: Unknown variable in referenced object

04 February 2012 - 10:19 PM

You can't reference the variables of an Object - because it doesn't exist. Think of an Object like a definition/class - an abstract idea. An instance is a realization of that idea. You need to create an instance of an object in order to use it. You then access the instance's variables - not the Objects.


Ah, so should I have a separate object like the controller that defines ALL variables for things like price etc?

In Topic: Unknown variable in referenced object

04 February 2012 - 09:56 PM

Your not in the CSUC game production class by chance?


Nope, and my mouse derped somehow and clicked the submit button before I could change the content of my post. It's completely different now to what you saw.