Looking For Some Kind Of... Touching? System


Quiest

I like turtles!
Joined
Sep 2, 2004
Messages
3,411
Age
37
Location
Dteuschland ;)
Puuh, hard to describe, sorry if the title is a bit confusing...

Let`s say I want to make a drag&drop item.
I have my cursor moving around and move it over a sprite.
and when I push a button, it should detect, that the sprite is below the cursor.


Is there any better solution than just using the coordinates?
Something like the if(collision (type something)) command, only permanent?
Like a on.mouse.over or something like that.


I hope it`s clear what I mean...
 

WhiteFalcon

Certified Guru
Joined
Nov 4, 2003
Messages
732
Age
39
Location
Czech Republic
Website
Visit site
I don't know Fenix at all, but in C I would do it by coordinates (bouncing-box collision) and if need be also by the particular shape of the sprite (pixel perfect collision). Combining these two together you can get nice speed and perfect functionality.
 

Quiest

I like turtles!
Joined
Sep 2, 2004
Messages
3,411
Age
37
Location
Dteuschland ;)
Oh, I tried with collision, but the term if(collision (type sprite)) is only true for the time of impact, atleast that is what it seems to be for me.

WhiteFalcon, thanks, seems plausible to me, but if nobody knows an equivalent in Fenix, it`s not much help.


Well, going on improvise tour, if anybody comes up with an idea, let me know :D
 

devlkore

^_^
Joined
Jul 15, 2004
Messages
274
Website
www.sparktasty.net
I think you could do a "do while" to make it work.

That is, "do while" the collision is true AND the button is being pressed. Make sure you've got your "frame" in the right place.
 

Quiest

I like turtles!
Joined
Sep 2, 2004
Messages
3,411
Age
37
Location
Dteuschland ;)
Thats what I tried, but it didn`t work, the collision is only true at the time of impact, I mean, when the cursor touches the sprite, and gets false when it stays longer on it.

That`s how I think why it didn`t work (did some tests with variables).


Here is a little test I did:

Code:
program spider_ball;
 global
   over;
 
 begin
   set_mode(320,240,16);
   set_fps(30,0);
   
   load_fpg("main.fpg");
   
   spiderball(160,10,2);
   wall(160,130,3);
  end;
  
process spiderball(x,y,z); //this ball just moves from up to down
 begin
   graph=1;
    
   write_int(0,10,10,0, &over); //display the value of "over"
    
   loop
     y++;               //one pixel down every frame.
     if(y>230)y=10;end; //start again if ball is too low 
     
     if(collision (type wall)) //if the ball is over the wall,
       over=1;                 //"over" should be 1, but it isn`t
      end;
     if(not collision (type wall)) //if the ball is not over the wall,
       over=0;                     //"over" is 0 (which it always is)
      end;                         
     frame;
    end;
  end;

process wall(x,y,z); //it`s a wall in the middle of the screen
  begin
    graph=3;
    loop
      frame;
     end;    
   end;
 

Quiest

I like turtles!
Joined
Sep 2, 2004
Messages
3,411
Age
37
Location
Dteuschland ;)
devlkore posted on Apr 7 2005 at 12:15 PM said:
It would only work in a circular shap, but you could check the distance instead of the collision (thanx Moogle).

In a circular shape? What do you mean by that?
The distance check is good idea, going to try this, thanks.
 
Last edited by a moderator:

Goity

VIP Sleaze
Joined
Jun 22, 2004
Messages
5,598
Location
Isle of Ewe
Is that that weird 1 problem I have? Where one doesn't seem to work with an if=1 statement?
If it's a switch, try using
Code:
IF(over>0)
 

devlkore

^_^
Joined
Jul 15, 2004
Messages
274
Website
www.sparktasty.net
Quiest posted on Apr 7 2005 at 11:20 AM said:
devlkore posted on Apr 7 2005 at 12:15 PM said:
It would only work in a circular shap, but you could check the distance instead of the collision (thanx Moogle).

In a circular shape? What do you mean by that?
The distance check is good idea, going to try this, thanks.

Because you'd be checking the distance from one thing to another, it would only detect how far away the center points are, so if you had a non circular shape, it wouldn't detect corners, etc.

Also, you could check the collision on the button press, and only drop the object when you let go of the button, that way, you would only need to check the collision once anyway.
 
Last edited by a moderator:

Moogle

.
Joined
Apr 27, 2004
Messages
283
Age
35
Location
Netherlands
Website
Visit site
Well, for those that are interested I fumbled together another tutorial like example! It gives one the possibility to drag around some squares(pixel perfect, they could have been conhexawikiaeders too). Fully documented(the explanation : code ratio is approaching 2 : 1 :) ).



Download from here.

Or probably in a moment from the File Archive under Fenix Sourcecodes.
Hm, I got to put stuff in my signature one of these days :)
 

Quiest

I like turtles!
Joined
Sep 2, 2004
Messages
3,411
Age
37
Location
Dteuschland ;)
I thought so :D

I`m going on camping tour with some friends this summer to the Niederlande :) (again)

Last time we were at Falkenberg (if I remember correctly), near Maastricht.





EDIT: Couldn`t resist doing this:



:eek:
 
Top