Hi. I'm thinking about making a bowman type game
(if you've never played it:
http://www.addicting...om/bowman2.html
)
i was wondering, could anyone make me some code (or example/tutorial)
on how to do the lines like in bowman
NEEDS
[1] knows where first click is, and draw a line to the current mouse_x (I may be able to do this myself)
[2] have a limit length of say 300 pixels
[3] Show angle (if ground is 0) off ground (not very clear, i know)
i think i can do the rest.
Credit for you if you can help.
Thanx
~MT
Bowman Type Game
Started by :MT:, May 02 2008 01:57 PM
2 replies to this topic
#1
Posted 02 May 2008 - 01:57 PM
#2
Posted 02 May 2008 - 02:38 PM
Okay, I'll give this a shot...
make a global_controller object, stick in "mouse button left" event: (you don't have to do it this way, but it's good practice)
[codebox]
target_x = mouse_x;
target_y = mouse_y;
[/codebox]
Now you have where the user clicked...
now in the bloke event of draw put these two lines:
[codebox]
//you can edit this, by looking at the help file for draw_sprite_ext();
draw_sprite_ext(<whatever your bowmans sprite is called>,-1,x,y,image_xscale,image_yscale,image_angle,c_whit
e,1);
//now to draw the line of movement..
draw_line_color(x,y,global_controller.target_x,glo
bal_controller.target_y,c_white,c_white);
[/codebox]
That should give you a bloke, and when you click the mouse, anywhere, it'll update the draw routine in "bowman"
that's the line dealt with..
2. make it limit to 300 pixels.
Simple...
just do this check in the "mouse button left"
[codebox]
if distance_to_point(bowman.x,bowman.y,mouse_x,mouse_
y) < 300 {
//rest of the code above here//
}
[/codebox]
3. Show angle.. Bit trickier.. But still pretty simple
in the global.controller DRAW event (make one) and put this GML in it
[codebox]
draw_set_font(<make a font and name it here>);
draw_text_color(x,y,string(point_direction(bowman.
x,bowman.y,target.x,target.y)),c_white,c_white,c_wh
ite,c_white,1);
[/codebox]
Hope this helps !
make a global_controller object, stick in "mouse button left" event: (you don't have to do it this way, but it's good practice)
[codebox]
target_x = mouse_x;
target_y = mouse_y;
[/codebox]
Now you have where the user clicked...
now in the bloke event of draw put these two lines:
[codebox]
//you can edit this, by looking at the help file for draw_sprite_ext();
draw_sprite_ext(<whatever your bowmans sprite is called>,-1,x,y,image_xscale,image_yscale,image_angle,c_whit
e,1);
//now to draw the line of movement..
draw_line_color(x,y,global_controller.target_x,glo
bal_controller.target_y,c_white,c_white);
[/codebox]
That should give you a bloke, and when you click the mouse, anywhere, it'll update the draw routine in "bowman"
that's the line dealt with..
2. make it limit to 300 pixels.
Simple...
just do this check in the "mouse button left"
[codebox]
if distance_to_point(bowman.x,bowman.y,mouse_x,mouse_
y) < 300 {
//rest of the code above here//
}
[/codebox]
3. Show angle.. Bit trickier.. But still pretty simple
in the global.controller DRAW event (make one) and put this GML in it
[codebox]
draw_set_font(<make a font and name it here>);
draw_text_color(x,y,string(point_direction(bowman.
x,bowman.y,target.x,target.y)),c_white,c_white,c_wh
ite,c_white,1);
[/codebox]
Hope this helps !
Edited by ScrewYouHippy, 02 May 2008 - 02:41 PM.
#3
Posted 03 May 2008 - 02:28 AM
i got a lot of errors.
i think i'm doing it wrong.
Would you mind making an example?
sorry.
i think i'm doing it wrong.
Would you mind making an example?
sorry.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











