Jump to content


nibbs

Member Since 23 Oct 2006
Offline Last Active Dec 28 2012 08:58 PM

Topics I've Started

Changing the "state" of the player

28 December 2012 - 01:39 AM

What is the best way to handle the various "states" (e.g. jumping, attacking, crawling, climbing, hurt etc.)  of the player-controlled object in a platformer? One approach I've come up with is to have the input handling at the beginning of the step to determine which state the object is in, and at the end of the step do something based on the object's state. For example:

if press key  {
  state = 0;
}
if press different key  {
  state = 1;
}


if state == 0  {
  sprite_index = something;
  image_speed = something;
  y += 6;
}
else if state == 1  {
  sprite_index = something;
  index_speed = something;
  x += 2;
}


What approach is most common/best for platformers that have many different actions?

Ray Casting is Too Slow

12 September 2011 - 05:08 AM

Here's my code:
for(i=0;i<31;i+=5)
{

col[i]=noone; 
l[i]=0;

while col[i]=noone && l[i]<200
{
 l[i]+=1
 x2[i] = x + lengthdir_x(l[i],dir[i]);
 y2[i] = y + lengthdir_y(l[i],dir[i]);
 col[i]=collision_line(x,y,x2[i],y2[i],all,1,1);
}

}

This code creates a 'fan' of collision lines that stop when it hits something or if it reaches a max length 'l'. The code does the job but it is also really slow. Is there any way to optimize it?

Delete from List

20 February 2011 - 02:38 AM

I'm using a ds_list to store instances like this:

[x]
[x]
[x]
[x]
[x]

When a bullet hits one of these instances, it deletes the instance and its corresponding value in the list.

p=ds_list_find_index(ds,self.id)
 if health<=0
 {
  ds_list_delete(ds,p)
  instance_destroy();
 }

The problem is, is that the top value in the list is being deleted

[x]
[x]
[x] <-- if this is hit...
[x]
[x]

this is the result:

[ ]
[x]
[x]
[x]
[x]

I want it to be this:

[x]
[x]
[ ]
[x]
[x]

Depth Issues

23 January 2011 - 10:28 PM

When I draw blocks in 3D, I can see "seams" in between the blocks:

Posted Image

Is there any way to fix this? I've tried drawing planes on top of the blocks, but in order to completely cover the cracks, I have to draw the planes wider than the blocks (which doesn't look good).

Draw 3D Object on Screen

22 January 2011 - 01:01 AM

Is it possible to draw/control a 3D object on top of a 2D room? If so, how would it be done?