|
Post by bdk336 on Mar 31, 2009 16:35:40 GMT -5
So I'm designing a game, which won't be done for some time, and I want a turret to point at the mouse. I have two scripts that I use to get the direction the turret should point in degrees:
{ difx = mouse_x-x; dify = mouse_y-y; switch (0) { case difx: ang_m=90; break; case dify: ang_m=0; break; default: ang_m=arctan(abs(dify)/abs(difx))*100; } switch (sign(difx)) { case 0: if (sign(dify)=1) {quad_m=3}; break; case 1: if (sign(dify)=1) {quad_m=4} else {quad_m=1}; break; case -1: if (sign(dify)=1) {quad_m=3} else {quad_m=2}; break; default: quad_m=1; } }
and the other:
{ switch (quad_m) { case 2: direct_m=180-ang_m; break; case 3: direct_m=180+ang_m; break; case 4: direct_m=360-ang_m; break; default: direct_m=ang_m; break; } }
After that I have an action that sets the image for the turret to: round(direct_m/2)
All of the functions seem to work but the turret still doesn't rotate right. So I gave the object an action to draw both the direct_m and ang_m variables and I discovered that the problem seems to be in the math; The turret rotates just as it should based on the values from the equation, but the values are not right.
I got the equation for getting the angle from a math teacher, but instead of ang_m coming out to values between 0 and 90 it comes out to values between 0 and 157.
This is the piece of code that seems to be problematic: ang_m=arctan(abs(dify)/abs(difx))*100
For anyone who knows math but not the Gamemaker language here's what the code does in math terms:
dify is the difference between the y position of the object (in this case the mouse pointer) that I want the turret to face and the y position of the turret, difx is the difference between their x values.
ang_m is supposed to be the angle created by the intersection of the line between the mouse and turret and the y=0 line (or X axis)
the equation would be ang_m=[inverse tangent(|dify|/|difx|)]*100
Please help I cannot seem to figure this out. The game will take a while to make but it will never happen if I can't get this piece of code worked out. This basic script is going to be essential to more than one game so any help with this would be very much appreciated.
This code is going to be essential to more than one game so any help with this would be very much appreciated.
|
|
|
Post by bdk336 on Apr 1, 2009 15:34:13 GMT -5
well now, I figured out what the problem was. When the script processes the inverse tangent it gives the answer in radians, not degrees, so the inverse tangent of 1 is about 79 instead of 45. I'm going to check if there is a function to deal with this in degrees in the GM language, otherwise I'll have to proceed along the annoying path of changing it manually.
Also it looks like I might be able to work with the math functions so that I won't have to use the pieces of the script that find and implement the quadrant the mouse is in at all.
Once I get the script working properly I'll post it so that others can use it in their games. I don't even need credit for it as long as people share their games with this community.
|
|
|
Post by bdk336 on Apr 2, 2009 16:17:41 GMT -5
Hurray, I altered the script and it works now ;D, and it's also been compacted into one shorter script. Here it is:
{ var difx,dify; difx = mouse_x-x; dify = mouse_y-y; ang_m=radtodeg(arctan2(dify,difx)); if (sign(ang_m)=1) {direct_m=ang_m*-1} else {direct_m=abs(ang_m)}; }
feel free to use this code in your own games in game maker 7, no need to give me credit as long as you share them with this community. Also if anyone wants help with this or other issues with actions/scripts in game maker feel free to ask.
|
|
|
Post by bdk336 on Apr 6, 2009 20:36:01 GMT -5
so does this mean that there is no one still coming here regularly who is actually making games anymore?
|
|
|
Post by betaman on Apr 6, 2009 23:41:30 GMT -5
I don't think ANYONE comes here regularly anymore...
|
|
|
Post by bdk336 on Apr 7, 2009 5:09:22 GMT -5
okay I know for a fact that there are regulars, it just seems that none of them are making games anymore.
|
|
|
Post by betaman on Apr 8, 2009 13:19:48 GMT -5
Most of the fan games people plan for Legends usually die down within a year or so. It's not surprising there are less people trying to make fan games for it.
|
|
duo
Gorubeshu
Posts: 261
|
Post by duo on Apr 16, 2009 0:15:53 GMT -5
I wonder what the biggest problem regarding the completion of games is. Does anyone have ideas, or comments from personal experience? I know that some people start games without any real design, just vague ideas. These end pretty abruptly. There are a bunch on this site like that. These people start fangames the wrong way; they see a cool game they want to recreate, but without substantial ideas. I would like to see a lot more game outlines instead of the many insubstantial demos. Stuff that arne did was cool. www.amazon.com/Art-Game-Design-book-lenses/dp/0123694965 This is the best book of game design I have ever come across. It was written by a guy from Carnegie Mellon university (panda3d people!): "Good game design happens when you view your game from many different perspectives, or lenses. While touring through the unusual territory that is game design, this book gives the reader one hundred of these lenses one hundred sets of insightful questions to ask yourself that will help make your game better. These lenses are gathered from fields as diverse as psychology, architecture, music, visual design, film, software engineering, theme park design, mathematics, writing, puzzle design, and anthropology. Anyone who reads this book will be inspired to become a better game designer and will understand how to do it. "
|
|
|
Post by bdk336 on Apr 16, 2009 12:33:24 GMT -5
I think there are three issues, other than conflicting commitments, that commonly show up: Lack of understanding of and difficulty learning the way in which basic programming (game maker still qualifies even when you don't use code) works and ways to achieve the desired effect in game mechanics Lack of a clear idea or planning regarding the overall game mechanics and game content Frustration over the amount of time it takes to create a full fledged game, even for small ones. I think that we can help with all these problems by encouraging people to post any issues they have while making the game and helping with them, having discussions about designing games before creating them and game content, and encouraging people to post versions their games even before the game mechanics and graphics have been added so that other players can give them advice and they can get some fulfillment from the mid-way steps. Personally I think it would be good for the Sky Pirate Arcade to have a section for games that are still somewhat under development in graphics/mechanics. Right now you can't get something up there unless it is a demo and even with small games the majority of the time is spent getting the graphics and game mechanics right, it would be good to have an area where people can put up debug rooms or other individual rooms for their games. Actually even if it isn't on the arcade I think it would be good to encourage people to share their games at these in between stages. Wow I spent a long time talking .
|
|
MayImilae
Zakobon
Badgeless, and proud of it!
Posts: 145
|
Post by MayImilae on Apr 16, 2009 16:29:35 GMT -5
Chiz, who knows everything, did a great rant on the subject of why fangames die. mmls.proboards.com/index.cgi?board=talkmml1&action=display&thread=2865&page=1#44714As for your little project here, I'll just be blunt. There is plenty of apathetic encouragement about. Everyone that sees "gamemaker" in the title immediately considers this project a failure, or at best, just plain bad. Such is how things get with mountains of semi-completed, bad fangames made with it. The rest of you can lie, but you thought it too! Because of the overwhelming tide of junk that is never completed, I think I can speak for everyone that people are just tired of it all and as such are automatically skeptical of any project; I know I am! And if that project has gamemaker involved? Automatic write off. It doesn't mean you can't make a good game with gamemaker, I have seen some good ones, but the natural assumption is that it is more garbage. If you can make an entertaining game and FINISH IT with gamemaker, then I'll believe you can. Because of all this I doubt you'll get much help in making your project. Sorry mate.
|
|
|
Post by bdk336 on Apr 16, 2009 17:56:48 GMT -5
you are emphasizing exactly what I am saying, if there was a method for people to get some enjoyment out of their games even before completion and to easily get help there would be way less of these failures/dropped projects and more in general.
|
|
duo
Gorubeshu
Posts: 261
|
Post by duo on Apr 16, 2009 23:32:18 GMT -5
I don't know exactly what game maker is, but I can imagine. Why would you, when there's python?
|
|
|
Post by bdk336 on Apr 17, 2009 5:10:45 GMT -5
Why would I? Because it's faster and easier than Python, and many other people who use it don't have the time to learn Python or aren't very good with code.
|
|
Goopygoo, Lord of the Whilst
Arukoitan
Sometimes, life gives you lemons. Which is odd, what with abstract concepts handing out free citrus.
Posts: 178
|
Post by Goopygoo, Lord of the Whilst on Apr 17, 2009 13:01:13 GMT -5
Why would you, when there's python? This is why.
|
|
duo
Gorubeshu
Posts: 261
|
Post by duo on Apr 17, 2009 15:27:33 GMT -5
Hm, I understand now, although it makes me upset that 1 isn't considered to be a prime number.
|
|