Derp(duck)
Guest
|
|
« Reply #360 on: December 08, 2011, 10:44:00 AM » |
|
Some nice tutorials here
|
|
|
Logged
|
|
|
|
Sheepolution
|
|
« Reply #361 on: December 10, 2011, 06:16:46 AM » |
|
The origin of the boat and all the arrows is 32 x 32 (in the center). Does anyone know what the problem is and how I can solve it? For the .gmk file: http://updo.nl/file/7c64b95b.gmk
|
|
|
Logged
|
|
|
|
Geeze
|
|
« Reply #362 on: December 10, 2011, 08:08:17 AM » |
|
It happens because you are only checking one instance! Instead you should iterate through all instances(with is perfect for this) Here's a working(?) piece of code: with(obj_arrow_down) { if(x == other.x && y == other.y){ //other refers to ship not arrow direction = 270 image_angle = 270 } }
And repeat that for each arrow type
|
|
|
Logged
|
GM can do anything.
It's magic.
|
|
|
Sheepolution
|
|
« Reply #363 on: December 10, 2011, 08:21:17 AM » |
|
with(obj_arrow_down) { if(x == other.x && y == other.y){ //other refers to ship not arrow other.direction = 270 other.image_angle = 270 } } other.direction and other.image_angle added, without that the image_angle of the arrow changes. But you really helped me with this! Thanks :D
|
|
|
Logged
|
|
|
|
Dragonmaw
Guest
|
|
« Reply #364 on: December 13, 2011, 02:04:29 PM » |
|
Stickied thread.
|
|
|
Logged
|
|
|
|
Zack Bell
|
|
« Reply #365 on: January 05, 2012, 06:34:10 AM » |
|
I'm having troubles implementing both Chevy's scaling and the Easy Lighting extension at the same time. I'm assuming that Easy Lighting uses surfaces and that the scaling interferes with it.
|
|
|
Logged
|
|
|
|
Theophilus
Guest
|
|
« Reply #366 on: January 07, 2012, 01:46:38 PM » |
|
I'm having troubles implementing both Chevy's scaling and the Easy Lighting extension at the same time. I'm assuming that Easy Lighting uses surfaces and that the scaling interferes with it. The lighting extension probably resets the target. Here's an idea: make a script, and name it surface_reset_target. When called in code, it SHOULD execute that script instead of surface_reset_target. In the script, set the drawing target to the scaled surface in Chevy's example. Honestly, probably not ideal.
|
|
|
Logged
|
|
|
|
Zack Bell
|
|
« Reply #367 on: January 07, 2012, 02:45:27 PM » |
|
Hmm, that's not a bad idea. I'll give it a try
|
|
|
Logged
|
|
|
|
BomberTREE
|
|
« Reply #368 on: January 24, 2012, 07:25:31 PM » |
|
I have a top down player, my goal is to have the players head facing the mouse, as the players body slowly works its way towards the same direction. I would like to do this through the draw event possibly with draw_sprite_ext, but how would I get that rotation value to be perfectly towards the mouse?Mainly I would like to know how I would adjust the bodys rotation speed to be a tad bit slower than the heads xD Help would be very much appreciated
|
|
« Last Edit: January 24, 2012, 08:03:22 PM by kitheif »
|
Logged
|
|
|
|
Zack Bell
|
|
« Reply #369 on: January 24, 2012, 08:30:24 PM » |
|
//HEAD CODE
point_direction(x, y, mouse_x, mouse_y);
//BODY CODE
/* ** Usage: ** turn_toward_direction(direction,turnspeed) ** ** Arguments: ** direction direciton you wish to achieve, degrees ** turnspeed rate at which to turn, degrees ** ** Returns: ** nothing, but rotates the calling instance toward ** a desired direction by a given number of degrees ** ** GMLscripts.com */ { var wdir, tempdir, turnspeed; wdir = argument0; turnspeed = argument1; if (abs(wdir-direction) > 180) { if (wdir > 180) { tempdir = wdir - 360; if (abs(tempdir-direction) > turnspeed) { direction -= turnspeed; } else { direction = wdir; } } else { tempdir = wdir + 360; if (abs(tempdir-direction) > turnspeed) { direction += turnspeed; } else { direction = wdir; } } } else { if (abs(wdir - direction) > turnspeed) { if (wdir > direction) { direction += turnspeed; } else { direction -= turnspeed; } } else { direction = wdir; } } }
Something like that? EDIT: You would call the body script with something like: turn_towards_direction(oHead.direction, turnSpeed);
|
|
« Last Edit: January 24, 2012, 08:59:34 PM by Zack Bell »
|
Logged
|
|
|
|
BomberTREE
|
|
« Reply #370 on: January 24, 2012, 09:22:16 PM » |
|
You saved me from spending hours on the nasty game maker forums! Thanks alot :D
@thatshelby - Oh wow, that was easy :O
|
|
« Last Edit: January 25, 2012, 09:10:13 AM by kitheif »
|
Logged
|
|
|
|
Zack Bell
|
|
« Reply #371 on: January 24, 2012, 09:31:49 PM » |
|
Hahaha, no problem.
|
|
|
Logged
|
|
|
|
Theophilus
Guest
|
|
« Reply #372 on: January 24, 2012, 09:46:05 PM » |
|
image_angle += sin((direction - image_angle) * pi / 180) * 8; make 8 higher or lower to adjust the speed. This turns image_angle towards the value stored in direction; change them if you like
|
|
|
Logged
|
|
|
|
droqen
|
|
« Reply #373 on: February 06, 2012, 11:03:43 AM » |
|
I think you need to put some modulo in there somewhere. Otherwise:
if image_angle is 0 and direction is 359, you want image_angle -= 1 (because -1 = 360) but with that code, it'd take the long way around.
|
|
|
Logged
|
|
|
|
Theophilus
Guest
|
|
« Reply #374 on: February 06, 2012, 11:11:06 AM » |
|
hmmm, i'll test it
|
|
|
Logged
|
|
|
|
Desert Dog
|
|
« Reply #375 on: February 06, 2012, 06:29:43 PM » |
|
xot over at gmlscripts optimised the turn_toward_script down to this: direction += median(-argument1, argument1, ((((argument0 - direction) mod 360) + 540) mod 360) - 180);
with argument0 being the direction you want to turn to, and argument1 being the turnspeed.
|
|
|
Logged
|
|
|
|
BomberTREE
|
|
« Reply #376 on: February 06, 2012, 06:39:56 PM » |
|
Where's the wall of text? That's awesome
|
|
|
Logged
|
|
|
|
Zack Bell
|
|
« Reply #377 on: February 06, 2012, 10:46:49 PM » |
|
xot over at gmlscripts optimised the turn_toward_script down to this: direction += median(-argument1, argument1, ((((argument0 - direction) mod 360) + 540) mod 360) - 180);
with argument0 being the direction you want to turn to, and argument1 being the turnspeed.
Holy shit, that's impressive.
|
|
|
Logged
|
|
|
|
Theophilus
Guest
|
|
« Reply #378 on: February 06, 2012, 10:54:39 PM » |
|
Nice and short, and maybe better, but it doesn't feel as fluid. With my method there's sort of a whip to it. that's not there with xot's script
|
|
|
Logged
|
|
|
|
Desert Dog
|
|
« Reply #379 on: February 06, 2012, 11:57:31 PM » |
|
Here's a test you can try with 'your' method. 1- Open a new Gm project 2-load a sprite. A nice one to rotate 3-make a new object. Put your code in the step event. 4- make a key press event, and place this code in that: //code kudos, rinkuhero //http://studioeres.com/games/content/7-game-maker-tips-experienced-users execute_string(get_string("Command?",""));
Start the game. Hit the key you specified. and type in 'direction+=180' Watch your car rotate(or not, as the case may be). It sacrifices functionality for smooth rotation. Works 90% of the time, and is great for things like arrows, but not for a point-to-mouse game, at least, not without some additional code.
|
|
« Last Edit: February 07, 2012, 12:03:08 AM by Desert Dog »
|
Logged
|
|
|
|
|