Jump to content


mws_1991

Member Since 06 Feb 2007
Offline Last Active Mar 22 2011 04:51 AM

Topics I've Started

Draw Function Problems...

23 December 2009 - 09:04 AM

ok im currently using for my objEnemy in the draw event:

draw_sprite(sprite_index,image_index,x,y)
draw_set_font(fnt_test)
draw_set_halign(fa_center)

draw_set_color(c_gray)
draw_text(x + 8,y - 26,string(hp) + ":" + string(hp_max))

draw_set_color(c_dkgray)
draw_text(x + 8,y - 14,string(armor))

if hit = true
{
	if dmg > 0
	{
		draw_set_color(c_red)
	}
	else
	{
		draw_set_color(c_purple)
	}
		
	draw_text(x + 8,y - 40,string(dmg))
}

basically its displaying the enemies hp and its max hp and also showing the damage it has taken once it is hit. However the problem with this is that the draw_sprite(sprite_index,image_index,x,y) code is preventing the image from flipping when it changes direction. I dont have a problem when i dont use the draw event altogether but i need it to show the hp and damage... if i dont put the draw_sprite(sprite_index,image_index,x,y) altogether then you can even see the enemies :/

help would be appreciated!

Instance_activate_region Help?

23 December 2009 - 02:57 AM

just checking what instance_activate_region does exactly... to my knowledge it can be used to activate or deactivate instances that are within the distances(parameters) you set...

im using:

instance_activate_region(view_xview-64,view_yview-64,view_wview+(64*2),view_hview+(64*2),true);
instance_deactivate_object(objEnemy);

however the objEnemy will only appear ingame if the objPlayer.y is below the objEnemy.y is there something wrong with the code im using?
I want to make it so that the enemy will activate just outside the view area so that it is moving etc once it actually appears on screen. The view is 320x240

Any help is appreciated!

*solved* Sword Mask

22 December 2009 - 12:55 PM

Currently the code im using is:

objPlayer, end step event:

if can_attack=true and keyboard_check_pressed(mv_attack) and !place_free(x,y+1) {
	if c_item = 0 {
		can_attack=false;
		st_attack=true;
		image_speed=0.5
		sprite_index=spr_playerAttack
		instance_create(x,y,objSword)
		//sound_play(global.fxStickSwing);
	}

how can i make it create objSword so it is the direction objPlayer is facing? I'm pretty sure i need to use xscale but how and where would i put it? In the code above or in the objSword create step or something else altogether?

Any help would be appreciated

Textbox Following A View

27 October 2009 - 06:46 AM

Ok so ive coded the basics for a simple textbox that seems to work fine when im running it without a view. However my problem is that the textbox created doesn't follow my view. All it does is stay next to the object that is creating it. The code im currently using is:

CREATE:
image_speed = 0;
image_index = 0;

//All strings must be named as str0, str1, str2, str3 ect. in order to work
str0 = "Welcome to "
str1 = "To get this far you have already figured out how to move left and right using A and D"
str2 = "Have you tried jumping yet?"
str3 = "Try pressing the W key to jump!"
str4 = "Have you tried attacking yet?"
str5 = "Press E to swing your sword."
str6 = "Kill enemies to gain EXP and Level up to become stronger!"
str7 = "Carry on brave hero!"

//Modify these two to customize this engine
strmaxnumb = 7; //Max number of strings (Like, if str56 were the last string, this would just be 56)
typespeed = 14; //Typing speed

strnumb = 0; //Current string number
currentstr = str0; //The current string
pos = 0; //Position in the string to check for mouth expressions

alarm[0] = 1;

ALARM[0]
pos += typespeed/room_speed;

if (pos > string_length(currentstr) ||
string_char_at(currentstr,pos) == "," ||
string_char_at(currentstr,pos) == "." ||
string_char_at(currentstr,pos) == "!" ||
string_char_at(currentstr,pos) == "?" ||
string_char_at(currentstr,pos) == ":" ||
string_char_at(currentstr,pos) == ";") {
  image_index = 4;
  pos += typespeed/room_speed;
  alarm[0] = room_speed/typespeed*3;
} else {
  alarm[0] = 1;
}

END STEP:
//This checks if it should skip 'till the end of the current string, or jump to the next one, or end game if we reached the last string
if (keyboard_check_pressed(vk_enter)) {
  if (pos < string_length(currentstr)) {
	pos = string_length(currentstr);
  } else {
	if (strnumb < strmaxnumb) {
	  strnumb += 1;
	  currentstr = variable_local_get("str"+string(strnumb));
	  pos = 0;
	}// else {
	  //game_end();
	//}
  }
}

DRAW:
draw_set_color(c_white);
draw_rectangle(0,300,view_xview,view_yview,0);
draw_set_color(c_black);
draw_rectangle(0,300,view_xview,view_yview,1);

texture_set_interpolation(1);
draw_sprite(sprite_index,image_index,x,y);
texture_set_interpolation(0);

draw_set_halign(fa_center);
draw_set_font(-1);
draw_text(x,y-40,"Signpost");

draw_set_halign(fa_left);
draw_set_font(fnt_test);
scr_draw_text_ext_outline(x+40,y-16,string_copy(currentstr,1,pos),16,view_xview-100,c_white,c_black);

i think the problem lies somewhere in the draw event but i cant see where since ive set it to view_xview and view_yview respectively...

EDIT: Whoops for got to add the code in scr_draw_text_ext_outline...
/*
draw_text_ext_outline(x,y,string,sep,w,insidecol,outlinecol)
x,y,string,sep,w - Same as in draw_text_ext()
insidecol - Color inside outline
outlinecol - Color of outline
*/
var xx,yy,str,sep,w,insidecol,outlinecol,prec;
xx = real(argument0);
yy = real(argument1);
str = string(argument2);
sep = real(argument3);
w = real(argument4);
insidecol = argument5;
outlinecol = argument6;

prec = draw_get_color();

draw_set_color(outlinecol);
draw_text_ext(xx,yy+1,str,sep,w);
draw_text_ext(xx,yy-1,str,sep,w);
draw_text_ext(xx+1,yy,str,sep,w);
draw_text_ext(xx-1,yy,str,sep,w);

draw_set_color(insidecol);
draw_text_ext(xx,yy,str,sep,w);

draw_set_color(prec);

Custom Hp Bar

26 October 2009 - 11:22 AM

Ok so im tying to make a custom HP bar for my character. Im currently using:

barnumb=((global.hp)/(global.hp_max))* sprite_get_number(spr_playerHP)-1;
draw_sprite(spr_playerHP,barnumb,view_xview+8,view_yview+8);

However when i use this then the HP bar animation doesn't stop. I want it to stop at certain frames depending on the amount of hp the player has...

Any ideas as to why this would be happening?