AccueilAccueil  FAQFAQ  RechercherRechercher  Dernières imagesDernières images  S'enregistrerS'enregistrer  Connexion  
Le Deal du moment : -45%
WHIRLPOOL OWFC3C26X – Lave-vaisselle pose libre ...
Voir le deal
339 €

 

 [RÉSOLU] collision_line() return the POS of the collision.

Aller en bas 
3 participants
AuteurMessage
Caly
Utilisateur confirmé: Rang ****
Caly


Messages : 1285
Localisation : Haute Normandie
Projet Actuel : Capturer, apprivoiser et dresser des Pokémons sauvages pour faire des spectacles de rue et en faire mon métier.

[RÉSOLU] collision_line() return the POS of the collision. Empty
MessageSujet: [RÉSOLU] collision_line() return the POS of the collision.   [RÉSOLU] collision_line() return the POS of the collision. EmptyMer 14 Sep 2011 - 21:54

Bonsoir je reviens encore avec une nouvelle question (oui je sais que j'en pose beaucoup, mais bon faut un début à tout).

Je creer un bloc par un click gauche sur l'écran (le bloc est un sort lancé par mon personnage).
Je verifie donc si mon personnage à une ligne de vue avec le point visé avec :
Code:
collision_line(obj_hero.x,obj_hero.y,x,y,all.solid,true,true))
Ce qui marche parfaitement.

Au cas ou je ne dispose pas de ligne de vue j'aimerais afficher une animation à l’endroit où la première collision gênante bloque ma LDV.

En sachant que "collision_line()" renvois un booléen et que je dois exécuter l'action en un seul step existe t'il une fonction GML, ou dois-je faire une boucle de vérification par pixel en direction de ma position final?


Dernière édition par Caly le Jeu 15 Sep 2011 - 10:43, édité 1 fois
Revenir en haut Aller en bas
onilink_
Modérateur
onilink_


Messages : 9180
Localisation : Montpellier
Projet Actuel : Planet Centauri
OniDev

[RÉSOLU] collision_line() return the POS of the collision. Empty
MessageSujet: Re: [RÉSOLU] collision_line() return the POS of the collision.   [RÉSOLU] collision_line() return the POS of the collision. EmptyMer 14 Sep 2011 - 21:57

A mon avis tu devrais utiliser ça : https://cbna.forumactif.com/t9641-gml-laser_length

_________________
[RÉSOLU] collision_line() return the POS of the collision. Runningpotato1[RÉSOLU] collision_line() return the POS of the collision. TvF6GED [RÉSOLU] collision_line() return the POS of the collision. MdetltS
Revenir en haut Aller en bas
M@d_Doc
Modérateur
M@d_Doc


Messages : 6600
Localisation : 47°44'8.04
Projet Actuel : aucun

[RÉSOLU] collision_line() return the POS of the collision. Empty
MessageSujet: Re: [RÉSOLU] collision_line() return the POS of the collision.   [RÉSOLU] collision_line() return the POS of the collision. EmptyMer 14 Sep 2011 - 23:04

wouhouuu, de la pub pour mes fonctions crossa

_________________
[RÉSOLU] collision_line() return the POS of the collision. Control-commentTous les icones de gm utilisables sur le cbna ICI  [RÉSOLU] collision_line() return the POS of the collision. Main1-change-sprite
Revenir en haut Aller en bas
http://www.lecbna.org
Caly
Utilisateur confirmé: Rang ****
Caly


Messages : 1285
Localisation : Haute Normandie
Projet Actuel : Capturer, apprivoiser et dresser des Pokémons sauvages pour faire des spectacles de rue et en faire mon métier.

[RÉSOLU] collision_line() return the POS of the collision. Empty
MessageSujet: Re: [RÉSOLU] collision_line() return the POS of the collision.   [RÉSOLU] collision_line() return the POS of the collision. EmptyJeu 15 Sep 2011 - 10:42

onilink_ merci pour le lien de la fonction made home.

Donc il fallait bien procéder avec une boucle, dommage qu'il n'y ai pas une fonction tout prête pour calculer la distance d'impact d'un objet avec un autre, je trouve ça bête.

Bref voici le résultat si ça peut aider quelqu'un (reprise de la fonction de M@d_Doc avec quelques modifications).

Code:

//Déclaration des variables
            var x_depart, y_depart, dist_impact, precision, long_max, dir;
                       
            x_depart = obj_hero.x; //peut se modifier pour cibler les yeux du hero.
            y_depart = obj_hero.y; //#
            dist_impact=0;
            precision=2; // minimum de 2.
            long_max= floor(point_distance(x_depart, y_depart, mouse_x, mouse_y));
            dir= point_direction(x_depart, y_depart, mouse_x, mouse_y);
           
            //On calcule la distance d'impact au px pres.               
            while (precision>1 or dist_impact>long_max)
            {
                while !collision_line(x_depart, y_depart,floor(x_depart+lengthdir_x(dist_impact,dir)),floor(y_depart+lengthdir_y(dist_impact,dir)),all.solid,true,true) && dist_impact<long_max
                    dist_impact += precision;
               
                dist_impact -= precision;
                precision /= 2;
            }
           
            //On creer une instance a l'endroit de l'impact.
            instance_create(floor(x_depart+lengthdir_x(dist_impact,dir)),floor(y_depart+lengthdir_y(dist_impact,dir)),obj_balle);


M@d_Doc suis-je obligé de te rajouter dans mes crédits ? :°

En tout cas merci pour l'aide!
Revenir en haut Aller en bas
M@d_Doc
Modérateur
M@d_Doc


Messages : 6600
Localisation : 47°44'8.04
Projet Actuel : aucun

[RÉSOLU] collision_line() return the POS of the collision. Empty
MessageSujet: Re: [RÉSOLU] collision_line() return the POS of the collision.   [RÉSOLU] collision_line() return the POS of the collision. EmptyJeu 15 Sep 2011 - 16:28

non non, t'es pas obligé de me mettre dans les crédits, c'est un tout petit script, pas le travail d'un mois ^^

_________________
[RÉSOLU] collision_line() return the POS of the collision. Control-commentTous les icones de gm utilisables sur le cbna ICI  [RÉSOLU] collision_line() return the POS of the collision. Main1-change-sprite
Revenir en haut Aller en bas
http://www.lecbna.org
Contenu sponsorisé





[RÉSOLU] collision_line() return the POS of the collision. Empty
MessageSujet: Re: [RÉSOLU] collision_line() return the POS of the collision.   [RÉSOLU] collision_line() return the POS of the collision. Empty

Revenir en haut Aller en bas
 
[RÉSOLU] collision_line() return the POS of the collision.
Revenir en haut 
Page 1 sur 1
 Sujets similaires
-
» [RÉSOLU] Ds_List_Size return 43.
» [RÉSOLU] Script return an array.
» [Résolu] Collision en GML
» [Résolu]Probleme de collision
» [Résolu] collision imprécises

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
Forum Le CBNA :: Développement :: Entraide débutants-
Sauter vers: