Jump to content


Sindarin

Member Since 01 Apr 2004
Offline Last Active Apr 19 2012 06:18 PM

Topics I've Started

Question on Inventory with data structures

09 February 2012 - 10:15 AM

I am planning to create an item inventory and going to use data structures for it.
Problem is that I don't know if there is any data structure that supports key/value pairs but with more... values?

I have my inventory items like this "item name | description | sprite | number in possession" so I need one key and 3 values,

e.g.
ds_something_add(myDS, "Potion", "Restores 50 HP", spPotion, 1);

They will also need to be sortable.

Using bounding box in collisions instead of sprite

30 August 2011 - 06:04 AM

I made this script to check if two objects collide, thing is I want to use the bounding box instead of sprite width/height. I tried with bbox_right and bbox_bottom but couldn't get this done,

collidesWith(object1,object2);
{
	if (instance_exists(argument[0]) && instance_exists(argument[1]))
	{
    	return real(argument[0].x < argument[1].x + argument[1].sprite_width && 
    	argument[0].x + argument[0].sprite_width > argument[1].x && 
    	argument[0].y < argument[1].y + argument[1].sprite_height && 
    	argument[0].y + argument[0].sprite_height > argument[1].y);
   	//return 1 if true, 0 if false
	}
	else
	{
    	return -1; //return -1 if instance doesn't exist
	}
}

Jumping animations

22 September 2010 - 12:26 AM

I am trying to make a two different animations for the jumping, and after, the falling state of a character. However the states got a bit messed up. So the full animation shows when the character jumps but not when he falls down.

Draw Event:
if (objPlayer.var_direction=='left')
{image_xscale = -1;}
else
{image_xscale = 1;}


if (objPlayer.var_action=='standing' && !(objPlayer.var_action=='falling') && !(objPlayer.var_action=='jumping'))
{sprite_index = global.spr_player_standing;image_speed = 0.2;}

/* action: Running */
if (objPlayer.var_action=='running' && !(objPlayer.var_action=='attacking') && !(objPlayer.var_horizontal_speed==0) && !(objPlayer.var_action=='pushing')
&& !(objPlayer.var_action=='falling')
&& !(objPlayer.var_action=='jumping')
)
{objPlayerSprites.sprite_index = global.spr_player_running; 

if(objPlayer.var_horizontal_speed < 0 && objPlayer.var_action=='running') 
	{image_speed = -objPlayer.var_horizontal_speed/10;} //this sets the image_speed to the right speed
if(objPlayer.var_horizontal_speed > 0 && objPlayer.var_action=='running') 
	{image_speed = objPlayer.var_horizontal_speed/10;}
}

/* action: Jumping */
if (objPlayer.var_action=='jumping' && !(objPlayer.var_action=='falling') && !(objPlayer.var_action=='attacking') && !(objPlayer.var_action=='running'))
{objPlayerSprites.sprite_index = global.spr_player_jumping;
if (image_index >11)
{image_index=10;}
}

/* action: Falling */
if (objPlayer.var_action=='falling' && !(objPlayer.var_action=='jumping') && !(objPlayer.var_action=='attacking') && !(objPlayer.var_action=='running'))
{objPlayerSprites.sprite_index = global.spr_player_falling;
if (image_index > 12)
{image_index=11;}else{image_speed=0.8;}
}

draw_sprite_ext(sprite_index,image_index,x,y,image_xscale,image_yscale,0,c_white,1);

Graphical inconsistency

19 September 2010 - 05:38 PM

My game is created in 1024 x 768, unfortunately my laptop screen is wide and when in fullscreen the graphics "break" if I choose to "keep aspect ratio".

Sprite left : fullscreen (sprite scales badly and pixels are "broken")
Sprite right: windowed (crisp)

Is there any way to achieve crisp graphics while mainting aspect ratio in fullscreen? Any way to do this by e.g. using surfaces to draw the game screen?

Animating, a plant struck by wind, motion

07 September 2010 - 07:33 AM

I have drawn this sprite of a plant, and I want to give it a windy motion like in the animation I did below,

I can do this by using frames, but I was wondering if there is another way to do this with code, like skewing the sprite somehow?