Tuesday, 30 March 2021

【GAMEMAKER】Character Stats Progression Upgrade

 Information about object: obj_splash

Sprite:
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:

///set up stats
//would load from saved data in actual game
global.stats[1,1]="Magic";
global.stats[1,2]=6;
global.stats[2,1]="Kindness";
global.stats[2,2]=8;
global.stats[3,1]="Evilness";
global.stats[3,2]=2;
global.stats[4,1]="Strength";
global.stats[4,2]=3;
global.stats[5,1]="Wisdom";
global.stats[5,2]=0;
global.stats[5,1]="Charisma";
global.stats[5,2]=0;
global.upgrades=6;


//goto main room
room_goto(room_character_progression);

Information about object: obj_button
Sprite: spr_button
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:

image_speed=0;
image_index=0;
Step Event:
execute code:

///mouse button
if mouse_check_button_pressed(mb_left) && position_meeting(mouse_x, mouse_y, id)
{
if global.upgrades>0 && global.stats[my_id,2]<10
{
//upgrade
global.upgrades--;
global.stats[my_id,2]++;
}
}
Draw Event:
execute code:

draw_self();
//draw the text 
draw_set_valign(fa_middle);
draw_set_halign(fa_left);
draw_text(50,my_id*100,global.stats[my_id,1]);


//draw red sprite - not the quickest approach, but easy to understange
for (var loop=1; loop < 11; loop += 1)
{
draw_sprite(spr_info,1,150+loop*40,my_id*100)
}

//draw yellow sprite
for (var loop=1; loop < global.stats[my_id,2]+1; loop += 1)
{
draw_sprite(spr_info,0,150+loop*40,my_id*100)
}

draw_set_halign(fa_center);
if global.stats[my_id,2]<10 && global.upgrades>0
{
image_index=0;
draw_text(x,y,"Available");
}
else if global.stats[my_id,2]==10
{
image_index=1;
draw_text(x,y,"Maxed Out");
}
else
{
image_index=1;
draw_text(x,y,"Not Available");
}

Information about object: obj_setup_buttons_and_hud
Sprite:
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:

///create buttons
for (var loop = 1; loop < 6; loop += 1)
{
button=instance_create(700,100*loop,obj_button);
button.my_id=loop
}
Step Event:
execute code:

if keyboard_check_released(ord('R'))
{
game_restart();
}
Draw Event:
execute code:

draw_set_halign(fa_left);

draw_text(100,50,"You Have "+string(global.upgrades)+" Upgrade Points - Press R To Restart Example");

No comments:

Post a Comment

BREAKING: North Carolina automotive group acquires 7 Upstate dealerships

Breaking news from GSA Business Report Click here to view this message in a browser window. ...