Message Board


Message Board > Fenix / Bennu / Gemix / DIV > Bug in get_angle

September 18, 2006, 21:42
yonni
None
420 posts
The rest of you probably noticed this ages ago, but I thought it would be worth posting anyway. When using get_angle() it always returns -1, whereas using fget_angle works fine. So instead of (for example) using:
Code:
angle=get_angle(mouse);

Use:
Code:
angle=fget_angle(x,y,mouse.x,mouse.y);


[Edited on September 18, 2006 by yonni]
____________
#
September 18, 2006, 22:42
Eckolin
Quite Whiskered
388 posts

Off by one isn't that bad in this case.

There's also a more serious bug in near_angle near multiples of 90 degrees.
____________
Maker of Games...
Wisdom is supreme; therefore get wisdom.
Need help with coding? I probably wrote something similar.
#
September 18, 2006, 23:08
yonni
None
420 posts
I dont mean it's one lower than it should be, I mean that it always returns "-1", with no relation to what it should be.

And while we're here, what exactly is that bug you mention with near_angle()?
____________
#
September 18, 2006, 23:23
Rincewind
programmer
1546 posts

You can easily create a mouse process with:

x=mouse.x;
y=mouse.y;

And then use get_angle(type mouseprocess);

But I bet you guessed that, but just in case it's easier for you.

[Edited on September 18, 2006 by Rincewind]
____________
Personal website: http://www.loijson.com
#
September 19, 2006, 00:12
yonni
None
420 posts
fget_angle() is so much easier, and if get_angle(mouse) doesnt work, then why should get_angle(mouse_process_wot_I_made)?
____________
#
September 19, 2006, 14:10
Rincewind
programmer
1546 posts

Quote:
fget_angle() is so much easier, and if get_angle(mouse) doesnt work, then why should get_angle(mouse_process_wot_I_made)?


It seems that get_angle (type mouseprocess_wot_I_made) doesn't work either indeed. Luckily it's easily fixed. :)

Get_angle() in fact works fine, you only have to fill out an ID between the brackets using get_id() because "type myprocess" doesn't seem to be outputting an ID when used within get_angle().

So that would be: get_angle(get_id(type myprocess)).

Enjoy: Get_angle example program

[Edited on September 19, 2006 by Rincewind]
____________
Personal website: http://www.loijson.com
#
September 19, 2006, 19:25
yonni
None
420 posts
ahh, merci.
____________
#
September 19, 2006, 19:46
Sandman
F3n!x0r
1194 posts

Quoting Rincewind:
Get_angle() in fact works fine, you only have to fill out an ID between the brackets using get_id() because "type myprocess" doesn't seem to be outputting an ID when used within get_angle().

This is logical, because 'type <processname>' returns a processtype identifier and not a processid identifier.
How should get_id() return the angle between one processid and a processtype? There can be more of the same type, so which should it take? Hence it returns -1 to signal there was a fault.
Processes, though, all have coordinates and a unique ID, so no problem there.
____________
BennuWiki
Yes, my avatar has grey borders in IE (so get a decent browser)
ROOFLEZ ROOFLEZ
#
September 19, 2006, 21:11
yonni
None
420 posts
But surely get_angle(mouse) should have worked? Because you can only have one "mouse" process.
____________
#
September 19, 2006, 21:41
PEader
お前はもう死んでいる
1486 posts

Quoting yonni:
But surely get_angle(mouse) should have worked? Because you can only have one "mouse" process.

mouse.id ??
____________
I see 57,005 people.
#
September 19, 2006, 21:51
Rincewind
programmer
1546 posts

Doesn't seem to be in the list.
____________
Personal website: http://www.loijson.com
#
September 19, 2006, 22:17
Sandman
F3n!x0r
1194 posts

Mouse isn't a process. Here and there you can use it as if it were, but I guess not in get_angle(). This could be a point of improvement for a later release of Fenix (or perhaps the current CVS version does have it).
____________
BennuWiki
Yes, my avatar has grey borders in IE (so get a decent browser)
ROOFLEZ ROOFLEZ
#
September 19, 2006, 23:43
yonni
None
420 posts
CVS version? (sorry if im being a noob)
____________
#
September 20, 2006, 10:20
Dennis
どこかにいる
2092 posts

Quoting Rincewind:
You can easily create a mouse process with:

x=mouse.x;
y=mouse.y;

And then use get_angle(type mouseprocess);

But I bet you guessed that, but just in case it's easier for you.
I think it's better (more logical) in your example to use get_angle(mouseprocess_id). Since there will never be more than one mouse process it's unnecessary to check every id with that particular process type.

Btw, i'm amazed Yonni tried to get the angle to a structure and didn't get a compilation error! :s

ps: what does the ID field of the mouse struct contain?

[Edited on September 20, 2006 by Dennis]
____________
Kwakkel
#
September 20, 2006, 12:52
Sandman
F3n!x0r
1194 posts

1. We just discussed there was no mouseprocess_id; if there is, that would help.
2. It was stated before: you can use 'mouse' as a process occasionally. He doesn't want to get the angle to a struct, just the angle to <<TYPE MOUSE>>, but like it was said getting an angle to a processtype is illogical. Fenix could handle this by returning angles of processes of that type in order of priority, but still.
3. ID is not in the mouse struct, as Rincewind linked to a topic containing all the elements of the struct mouse; it appeared not to be in it.
____________
BennuWiki
Yes, my avatar has grey borders in IE (so get a decent browser)
ROOFLEZ ROOFLEZ
#
September 20, 2006, 14:14
Dennis
どこかにいる
2092 posts

Sorry, I overlooked Rincewinds post linking to "the list".

Code:
program angle_test;
global
  int game_quit = false;
  int f_gui;
  int f_objects;
  int id_my_cursor;
  int anim_mouse[7] = 1,2,3,4,5,4,3,2;

begin
  f_gui = load_fpg("gui.fpg");
  f_objects = load_fpg("objects.fpg");
  id_my_cursor = my_cursor(f_gui,1); //create a process
  some_object(f_objects,1,100,100); //create an object on screen
  repeat
    frame;
  until(game_quit == true)
end

process my_cursor(mouse.file)
begin
  loop
    x = mouse.x;
    y = mouse.y;    
    mouse.graph = anim_mouse[i++];
    if (i>5) i = 0; end
    frame;
  end
end

process some_object(file,graph,x,y)
private
  int id_my_cursor;
begin
  loop
      angle = get_angle(id_my_cursor);
    frame;
  end
end
//etc...

Of course fget_angle(x,y,etc...) works fine too, but an overriding process is always better for the logic in your program in terms of adaptivity and clearity of the code. Plus, how would you make an animated cursor without using a process? You'll need at least a process that controls the mouse.graph variable...
____________
Kwakkel
#
September 20, 2006, 18:44
yonni
None
420 posts
Quoting Dennis:
Plus, how would you make an animated cursor without using a process? You'll need at least a process that controls the mouse.graph variable...

But that can be any process you like, I normally use play() (the one used to initiate the game/level, and handles exiting the game/level etc.)
____________
#
September 22, 2006, 10:25
Dennis
どこかにいる
2092 posts

what does initiating a level have to do with the animation of a cursor? i don't think a process should have more responsibilities than possible.

Also, I'd rather call it "level_manager" than "play"... This has no functional meaning but it is just clearer code. Sometimes you want to work on a process' code and you spend much time thinking "what was this process for?" and why is it doing this and this and so on.
____________
Kwakkel
#

Message Board > Fenix / Bennu / Gemix / DIV > Bug in get_angle

Quick reply


You must log in or register to post.
Copyright © 2005 Booleansoup.com
Questions? Comments? Bug reports? Contact us!