Skocz do zawartości

Kolizje tylko z jednej strony


WebCM

Rekomendowane odpowiedzi

Robię grę na wzór supaplex. Mam problem ze spadającymi kulami. Otóż mają one spadać w przypadku braku kolizji od dołu z solidnym obiektem (lub wybranymi...).

 

Jak wykryć kolizję pewnego obiektu z drugim tylko z jednej strony? W TGF/MMF nie ma z tym problemu. Jak jest zaś w GameMaker?

Odnośnik do komentarza
Udostępnij na innych stronach

Od tego masz coś takiego jak polecenie collision_... ;] Więcej info :

When planning motions or deciding on certain actions, it is often important to see whether there are collisions with other objects at certain places. The following routines can be used for this. All these have three arguments in common: The argument obj can be an object, the keyword all, or the id of an instance. The argument prec indicates whether the check should be precise or only based on the bounding box of the instance. Precise checking is only done when the sprite for the instance has the precise collision checking set. The argument notme can be set to true to indicate that the calling instance should not be checked. All these functions return either the id of one of the instances that collide, or they return a negative value when there is no collision.

 

collision_point(x,y,obj,prec,notme) This function tests whether at point (x,y) there is a collision with entities of object obj.

collision_rectangle(x1,y1,x2,y2,obj,prec,notme) This function tests whether there is a collision between the (filled) rectangle with the indicated opposite corners and entities of object obj. For example, you can use this to test whether an area is free of obstacles.

collision_circle(xc,yc,radius,obj,prec,notme) This function tests whether there is a collision between the (filled) circle centered at position (xc,yc) with the given radius and entities of object obj. For example, you can use this to test whether there is an object close to a particular location.

collision_ellipse(x1,y1,x2,y2,obj,prec,notme) This function tests whether there is a collision between the (filled) ellipse with the indicated opposite corners and entities of object obj.

collision_line(x1,y1,x2,y2,obj,prec,notme) This function tests whether there is a collision between the line segment from (x1,y1) to (x2,y2) and entities of object obj. This is a powerful function. You can e.g. use it to test whether an instance can see another instance by checking whether the line segment between them intersects a wall.

Odnośnik do komentarza
Udostępnij na innych stronach

Patrzyłem w pomocy, jednak trochę nagmatwane tam jest. Spróbuję się doczytać... W razie czego zapytam tutaj.

 

Ważna rzecz, jaką ma podręcznik PHP, a nie ma podręcznik GML - przykłady.

 

Z resztą zrobiłem w inny sposób - poustawiam kule tak, by nie kolidowały się z góry i boków...

 

PS. Grę robię na klockach...

 

Można zamknąć.

Odnośnik do komentarza
Udostępnij na innych stronach

Jeśli chcesz dodać odpowiedź, zaloguj się lub zarejestruj nowe konto

Jedynie zarejestrowani użytkownicy mogą komentować zawartość tej strony.

Zarejestruj nowe konto

Załóż nowe konto. To bardzo proste!

Zarejestruj się

Zaloguj się

Posiadasz już konto? Zaloguj się poniżej.

Zaloguj się
  • Ostatnio przeglądający   0 użytkowników

    • Brak zarejestrowanych użytkowników przeglądających tę stronę.
×
×
  • Dodaj nową pozycję...