View Full Version : Tips and tricks
01DT!m3r
13-05-2008, 05:44 PM
I started this thread for those who are still learning to program . The idea of this thread is for anyone who has a solution to a problem that they believe could be very helpful to others . Therefore they could post it up here so if another person has the same problem they could just pop in here and look for the solution . Like wise this thread could be used to posts tips and tricks on programming to help those noobs out there . Thanks
dislekcia
13-05-2008, 07:35 PM
Good idea :)
Nostrick, you know what to do!
-D
Higushi
14-05-2008, 02:15 PM
Alrighty! :)
Variables form the basis of just about everything you do in programming. They are extremely useful and without them it would be VERY difficult to write games, if not impossible.
This is a variable (http://en.wikipedia.org/wiki/Variable)
This is a tutorial on variables (http://www.intap.net/~drw/cpp/cpp03_01.htm) - Its for C++, but the same concepts apply to all languages.
A variable is simply something that you store values (data) in, and those values could be text or numbers, or some other things which you don't have to worry about yet (as a beginner), see Data Types (http://computerprogramming.suite101.com/article.cfm/datatypes). Game Maker comes with a lot of variables already set for you to use and manipulate to get the results you wish (such as room_speed).
eg.
In Game Maker, say now an object is traveling across the screen. It has an inherent variable called "speed" which tells it how many pixels to move across per step (or something similar to that). So if you want to change the speed at which the object is moving, you need to directly manipulate that variable. If you want to speed it up, but want it to have a maximum speed (lets say 20) that it cannot go above, you would place something like this in the event of the button used to speed it up:
speed += 1 (or you could say: speed = speed + 1)
if speed > 20
{
speed = 20;
}
we say if speed is bigger 20, then set the variable to 20. This ensures that the variable "speed" never goes above 20.
You can also define your own variables. You could make a variable called "speed_limit" and set it to 20 and use that in the place of all the number 20s in the above example. This makes it easier for you to adjust your game's settings in the future, where you would normally have to go and change all of those numbers into a new speed limit, now you only have to change the variable speed_limit.
Powered by vBulletin® Version 4.2.4 Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.