GameMakerHelpBlog

Thursday, January 24, 2008

Operators,Loops,Arrays

Some of these have already been explained before but i believe that they possibly could be bought up again.



Arrays



One dimesional:



Usuage: Variable[Number]

Uses: Storing information or values

Description: 1 Dimension arrays will store information you assign to them. You must initlise them a value for them to work.



Example: Banana[1]=20

Example2: Banana[i]=20



Example1 Explanation: This says that banana[1]=20, so the variable array banana[1] value is 20. you can now add and subtract the value



Example2 Explanation: This is harder to use, you must use the variable to init the array so before banana[i]=20 you must add i=1. This will say exactly the same as banana[1] now



Editing arrays: In a different event add (maybe Up or Down)



Banana[1]-=1 or Banana[1]+=1



2 Dimesional



Usuage: Variable[number,number]

Uses: Storing Co-ordinates/Values/Information

Description: These are more complex, use them in you want more than one value in an array



Example1: Worker[1,1]="Bob" Worker[1,2]="Wage:5000"

Example2: Worker[2,1]="Mary" Worker[2,2]="Wage:4650"



Example3: Xcord[object_index,id-100000]=x

Example4: Number[i,ii]=floor(random(100))



Example1&2 Explanation: Example1 has worker[val,val] as the array and the numbers as 1,1 and 1,2

1,1 value is equal to Bob and 1,2 is equal to wage:5000.



Example 3&4 Explanation: Example 3 i would use to define an objects position, it uses object_index as it's first dimesion and its own id as it's second. The reason i put id-100000 is becuase the array index can't go over 32000 Example 4 just uses variables you need to initise before writing that code e.g i=1 ii=1



Editing arrays: In a different event add (maybe Up or Down)



if worker[0,1]="Bob

{

worker[0,1]="Joe"

}

else

{

worker[0,1]="Bob"

}

Labels:

Monday, January 21, 2008

Basic 3D Model Trees (created in GameMaker)

Hi

This script will make a basic tree which you can use. It would be more suitable for cartoonish games, rather than realistic.

Remeber the [CODE] and [/CODE] tags aren't included in your game

[code]
d3d_draw_cylinder(x-4,y-4,0,x+4,y+4,16,background_get_texture(bg_trunk),1,1,true,16)
d3d_draw_cone(x-8,y-8,16,x+8,y+8,32,background_get_texture(background6),1,1,true,24)
[/code]

Labels: