It is currently Sun May 28, 2017 12:22 pm

 All times are UTC

Welcome
Welcome to am2r

 Page 1 of 2 [ 11 posts ] Go to page 1, 2  Next
 Print view Previous topic | Next topic
Author Message
 Post subject: Gamemaker Scripts and General Support for NewbiesPosted: Wed Nov 16, 2016 7:09 pm

Joined: Fri Nov 07, 2014 8:12 pm
Posts: 20
Location: Tallon IV
Programming has a sharp learning curve that makes it hard for newbies to understand, at first anyway. I'm sure all you newbies have ever heard is just how easy it is, and I will tell you no different, but I will also say that it just doesn't click for beginners. So I have decided to give you newbies a little support by coding some of the harder things for you in the form of scripts for Gamemaker Studio. I will also accept requests for scripts depending on how much code it actually takes to do what you ask, however, if it's actually really easy to do, I will just help you out here on this thread.

Please note that if you use my scripts, all I ask is that you give me credit in your game as Programming Support

Spoiler:
~Equations
includes the distance formula, direction in degrees, step function, polar equations, and dot products
Code:
VARIABLE = script_execute(scr_equations,equation id, x1, y1, x2, y2, radius1, radius2, angle);

/* EQUATIONS */
// 0 = Distance formula (requires: x,y,x2,y2)
// 1 = x polar equation (requires: x,radius,angle) {for circular mobility}
// 2 = y polar equation (requires: y,radius,angle)
// 3 = step function (requires: x) {returns values left of the decimal point}
// 4 = dot product (requires: x,y,x2,y2) {quadradic method (2 dimensional)}
// 5 = dot product (requires: radius,radius2,angle) {polar method (2 dimensional)}
// 6 = angle between points (requires: x,y,x2,y2)

//just enter 0 for arguments that aren't required for the formula you want to use

[REQUESTED SCRIPTS]
Spoiler:
DONE
HALF WAY THERE
STARTED
NOPE
///////////////
~none at this time~

[HOW TO INSTALL SCRIPTS]
Spoiler:
Steps:
1) right click on the "Scripts" folder in your project's file tree in Gamemaker Studio (left-most part of the screen)
2) click "add existing script"

Happy Coding!

_________________

Top

 Post subject: Re: Gamemaker Scripts and General Support for NewbiesPosted: Sat Nov 19, 2016 6:45 am

Joined: Thu Nov 17, 2016 1:59 am
Posts: 1
Hello Zack,

What IS coding?

Top

 Post subject: Re: Gamemaker Scripts and General Support for NewbiesPosted: Sun Nov 20, 2016 2:16 am

Joined: Fri Nov 07, 2014 8:12 pm
Posts: 20
Location: Tallon IV
zerkton264 wrote:
Hello Zack,

What IS coding?

That is an excellent question!

Programming (aka coding) is by definition "the action or process of writing computer programs" as stated by Google. But that hardly does it any justice, now does it?

My definition for coding is math that you ask questions, that works exactly like physics. If some factor is true, then perform law. If object is near a planet, the gravity. But of course there's more to it than a simple question.

Programming is governed in large part by two things: variables and If statements. Variables come in many forms and store values that your program tells them to store. For instance, if we have a variable named "number" and we tell the program to store the number "5" in it, the variable will hold that number until the program is restarted or tells the variable to hold a different value.

Declaring a variable looks like this:
int number = 0;

Variables must be declared before they can be used in a question, but after they're declared, they don't need the variable type (int) to be typed out for any statement involving the variable proceeding it. So if you want to change the value to 5:

number = 5;

"int" stands for integer or any number without a decimal point. There are many other kinds of variable types including char (character), float (decimal), double (an integer with a decimal point), string (multiple characters), etc. In terms of Gamemaker, these variable types are not required as Gamemaker handles that for the user, so declaring and using variables look the same in this regard.

Using variables, you can store the result of a math equation (which is the basis of algorithms, but more on those on a later date). So, you can set your number variable equal to an equation:

number = 35 / 4;

It is important to note that if your variable is an integer and any decimals are given to it, the system will simply round the number down to the nearest whole number. So 5.3467835 becomes 5 when a variable is set equal to it. (Again, Gamemaker handles variable types, so no need to worry in this regard if you're using Gamemaker).

Now that's math, and the questions are even easier. The first of these is "If/Then":
if (number == 5)
{number = 56;}

The curly brackets "{}" follow every question and function (more on these on a later date), and stand for the "then" part of the question. The double equals is the operator , which you can think of in terms of synonyms: "if number is equal to 5".

Of course there are other kinds of questions than "if" and operators as well.
Spoiler:
if (){}else{} <performs the "then" if the question is true or the "else" if it's not>

while (){} <continuously performs the "then" until the question is false>

for (int i = 0; i < 10; i++){} <performs the "then" 10 times>

do {}while(); <another "while" that performs the "then" at least once every time>

switch ("variable"){
case "value": "then";break;
} <question with many "then" statements and equations cannot be used here>

Spoiler:
!= not equal
> greater than
< less than
>= greater than or equal to
<= less than or equal to
+= adds to the value in the variable
-= subtracts from the value in the variable

There are also some operators that do not require a question:
Spoiler:
++ adds one to the variable (number++;)
-- subtracts one from the variable (number--;)
% "modulo" sets the variable equal to the decimal of the division (5%2=5)
/ divide
* multiply
- subtract

Of course, this information is just the basics, but knowing this is the first step to becoming a programmer as it is the foundation of programming. Everything in code runs off of it, so if you haven't already tried it, then you should download Gamemaker Studio and give it a shot.

_________________

Top

 Post subject: Re: Gamemaker Scripts and General Support for NewbiesPosted: Wed Nov 23, 2016 3:24 pm

Joined: Mon Nov 11, 2013 5:41 pm
Posts: 83
Highscores: 3
also to note, i'd suggest using gms 2 over gms since it's superior in almost all aspects

_________________
AM2R Playtester and Game Developer

Top

 Post subject: Re: Gamemaker Scripts and General Support for NewbiesPosted: Wed Nov 23, 2016 5:32 pm

Joined: Wed Mar 04, 2015 3:16 pm
Posts: 48
Can anyone here tell me how to code behavior for objects and characters. What I'm currently trying to figure out is how to make a futuristic door with two sliding objects.

Top

 Post subject: Re: Gamemaker Scripts and General Support for NewbiesPosted: Wed Nov 23, 2016 10:05 pm

Joined: Tue Sep 27, 2011 8:34 pm
Posts: 632
Location: Norfair Depths, Zebes
Why not make the door one object with an animation that looks like two objects? With a transparent space between the two elements of the sprite that grows and shrinks when the door opens and closes respectively.

If your game is 3D, and uses modeled objects with texture meshes, then that's not all that different. You can still use the same technique if the door model also "fakes" being two models.

If your game is 2D, then it would definitely be easier from a programming perspective to make the door one object. And its animation "fake" being two objects.

As far as behavior. For a door I would give it a variable called "state" or "status". And this will hold onto the fact of whether or not the door is "open", "opening", "closed", or "closing". And the animation is set, based on this variable.

There's a couple of ways you can do this. I would recommend using an Enum. But I don't know the language that game maker uses very well. So on the off chance gml doesn't support enums, you can use integers.

Basically what an Enum is is a toggle-able integer. In this example it would be something like: "open" = 1, "opening" = 2, "closed" = 3, and "closing" = 4. And based on the value of this variable, you perform your behavior. Enums are nice in that you can use the name of the door status in code, rather than having to remember which number represents which status. It also enforces the integrity of the code by not allowing you to use a wrong number.

EXAMPLE:
Spoiler:
My favorite language is C#. Which unfortunately means you'll have to convert these ideas into game maker. I also wouldn't use this code in a real project, it's only to illustrate the concept of setting the state of a door and changing the animation based off of that.
There are actually much better ways to do this too. Reorganize the code here to be more efficient. You'll need an animation listener if you want to draw the animation frame by frame. But that's getting into more advanced concepts. my only mission here was to illustrate the state code idea.

Also gifs would be a terrible idea. I don't know what extension Game Maker uses, so I used gif to express the fact that this is an animatable image.

A MORE DETAILED EXAMPLE:
Spoiler:
There's still a lot of room for improvement here. but this example is merely to illustrate how to handle some of the animation process.

_________________
The only being that Samus fears.

Top

 Post subject: Re: Gamemaker Scripts and General Support for NewbiesPosted: Fri Nov 25, 2016 5:12 am

Joined: Wed Jul 28, 2010 10:29 pm
Posts: 153
I'm working on making a game myself, luckily we already have a coder. The game is really super rough right now, and I may share details once we iron them out, though I have had the desire to learn how to code to help the project beyond simply being the writer of the story and dialogue.
The issue I tend to see is that many "intros" for beginners, tend to say they are for beginners, but immediately jump into explaining that you should already have some coding knowledge. It sets the bar for introductory knowledge unfairly high when you expect the reader who comes for beginning knowledge to have beginning knowledge to understand that beginning knowledge.
I would love to see a guide that just spells things out, explaining to people not just what the code is, but WHY it's written a certain why. It's good to see that this variable and this line of code does x, but I think, at least for some (like me) it's nice to walk through the logic to understand it.
Any chance of perhaps an intro guide to coding like that? I've read through the game makers tutorial on coding, even programmed what they told me to for some things, I get WHAT to do...but I can't grasp WHY I do it.

_________________
If you try to fail and succeed. What have you done?

Top

 Post subject: Re: Gamemaker Scripts and General Support for NewbiesPosted: Fri Nov 25, 2016 12:35 pm

Joined: Fri Nov 07, 2014 8:12 pm
Posts: 20
Location: Tallon IV
As far as using GM:S2, I might get into it given time. Like you said, it's far superior to GM:S, but I really don't want to have to familiarize myself with the whole new set up it has.

As for the door, Ridley pretty much hit the nail on the head.
In Gamemaker an enumerator is initialized with the following syntax:
enum "variable" {"elements separated by comas"}

Or

enum "variable" {"elements = values separated by comas"}

And as for a tutorial series, a buddy of mine asked me to teach him how to program. So I plan to record our sessions where I will be using Gamemaker Studio to teach him the basics of code. As to why it's done the way it is I guess depends on how confused/curious he gets during the sessions.
As to you specifically, what topics do you wish to know why they are? I mean, I could get into why everything is the way it is, but that'd be over kill especially when most of it will more than likely be TMI. (Probably the wrong term for that...meh, you get what I mean)

_________________

Top

 Post subject: Re: Gamemaker Scripts and General Support for NewbiesPosted: Fri Nov 25, 2016 4:32 pm

Joined: Tue Sep 27, 2011 8:34 pm
Posts: 632
Location: Norfair Depths, Zebes
Game Maker is actually what taught me the basics of programming. I began by only being able to use the Drag n' Drop interface. But that interface still followed the same rules and logic of actual programming. After a lot of practice (in the form of projects that began but never completed) I gradually started to use more complex logic, figuring it out on my own without being taught.

Later I discovered RPG Maker. Which is essentially the same thing as Game Maker, but with focus on RPG games. Instead of drag n' drop interfaces, it had drop down n' selection interfaces that you used on each line of the object's behavior. The coding of each object was suddenly more complicated, but it still wasn't guess work. The interface still guided me a little bit.

Both Game Maker and RPG Maker have their own native programming language which you can use to code your own scripts. Once I started to get some experience, I started mixing typed scripts along with the drag n' drop commands. And it starts to look like a spectrum.

One side of the spectrum is strictly using the interface, the other all code. And I slowly found myself starting to shift across the spectrum naturally.

Now I'm a programmer by trade. Making business applications for corporations. I never finished a single game in Game Maker or RPG Maker, but I still credit them for getting me to where i am now.

_________________
The only being that Samus fears.

Last edited by Ridley on Mon Nov 28, 2016 1:42 pm, edited 1 time in total.

Top

 Post subject: Re: Gamemaker Scripts and General Support for NewbiesPosted: Sun Nov 27, 2016 11:36 pm

Joined: Fri Nov 07, 2014 8:12 pm
Posts: 20
Location: Tallon IV
Ridley wrote:
-snip

Really?
Ironically enough, I told my high school computer science teacher that Gamemaker is a better place to start newbies on than the hour of code nonsense he was using, for the very reason you just explained.

I mean, it's cool what their doing with it, but it's just too basic and teaches poor habits because of it.

_________________

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 2 [ 11 posts ] Go to page 1, 2  Next

 All times are UTC

#### Who is online

Users browsing this forum: No registered users and 1 guest

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ Project AM2R    General Info and Announcements    Project Discussion and Ideas    Localization    Metroid: Confrontation General    General Discussion    Metroid Games    Fan Games

Donate Now