GameMakerHelpBlog

Monday, January 7, 2008

drawing triangles with 2D

hi

Notice how one of the shapes not included is a triangle. So this scipt can form a 2D trinangle, it uses one argument, The size of it. Also the triangle is what you would call of perfect angle, so it has a right angle and then two 45O angles. To edit the perfect angle you need alot of knowledge of Co-ordinates (i cant remember what you call the mathematical term) and angles

[code]
//put in draw event!
draw_line(x,y,x,y+argument0)
draw_line(x,y,x+argument0,y+argument0)
draw_line(x,y+argument0,x+argument0,y+argument0)

[/code]

Labels:

Sunday, January 6, 2008

Turn in one direction to a point

Hi

This script will turn an object from one direction to another ONE way

[code]

dir = point_direction(x,y,argument0,argument1)
if direction!=dir
{
if direction < dir
{
direction+=3
}
else
if direction > dir
{
direction-=3
}
}
else
{
direction = direction
}
[/code]

Labels:

Quoting Written Text - VB

Hi

my first script for Visual Studio Visual Basic

This script is about quoting written text when a button is pressed. I can't really explain it more than that sorry

[code]

Public Class Form1
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = "quote : " + TextBox1.Text
End Sub
End Class

[/code]

The Textbox1 and Burron1 can be changed with a different name, but i wouldn't advise it if you are a new user

Labels:

New Topic - Visual Basic

Hi

I have decided to share some visual basic with you. I am only a novice so people who know what i am talking about, don't be shocked when you see these posts are nooby

Labels:

Encryption

Hi

The purpose of this script is to encrypt or dencrypt a string. It is very simple and useable by novice GameMaker Users. I am still finishing on the dencryption which may come in a little while



[code]

{
str = argument0
key = argument1
str2 = str
str2=ord(str2)
str2*=key*2
show_message(string(str2))
}

[/code]

Labels:

AI - 3D collisions

Following on from my last script:here

This is the collisions for this script. You can just add The nesscery stuff into the script as i quote from the same GMC topic

i have worked out collisions! (for your AI) just add these codes where i say

[CODE]
/////////////////////////////////////////
*Create Event*
//////////////////////////////////////////
collision=false//initates the variable/trigger which is set to false
/////////////////////////////////////////
*Step event*/ //i can't explain what this does else my codebox mucks up
/////////////////////////////////////////
if distance_to_object(argument0)<2 and collision=false
{
alarm[0]=1
collision=true
}
/////////////////////////////////////////
*Alarm0*/ // add in the "position_meeting" ELSE Bracket after "done"
/////////////////////////////////////////
if collision=true
{
alarm[1]=30
}
////////////////////////////////////////
*alarm1*
//////////////////////////////////////////
collision=false //resets the variable
[/code]


Ok so i will explain what you up in argument0. Make a new object called par_solid. this is a parent. when you open a static (unmoveable) objects properties. where it says parent add par_solid so it has all the effects of par_solid

Labels:

AI - 3D and Topdown

This Ai script is for topdown and 3D. It was made for 3D and you may have to optimise it for Topdown. And i have copied it off a topic i posted of here:Link

Here it is anyway

[code]
//////////////////////////////////////////*create event*/////////////////////////////////////////
tagetx=x
targety=y
done=false
alarm[0]=1
//////////////////////////////////////////
*step event*
////////////////////////////////////////
dist = distance_to_point(targetx,targety)
if (dist>0)
{
direction = point_direction(x,y,targetx,targety)
speed=2
image_speed=1
}
else{
speed=0
image_speed=0
done=true
}
if done=true
{
done=false
alarm[0]=1
}
////////////////////////////////////////////////////
*alarm[0] event*
//////////////////////////////////////////////////
targetx=floor(random(room_width))
targety=floor(random(room_height))
if position_meeting(targetx,targety,all)
{
alarm[0]=1
}
else
{
done=false
}
[/code]

Labels:

Factorising

The opposite of expanding. It basically factorises 2 numbers to make a(b+c) or - or / or * as the mathematical operators. Factorising can simplify numbers and expanding functions can un-simplify them (as most people would think)

Unforuantely unless more functions are added to GameMaker or if i upgrade this script, you have to figure out the lowest common divsion between the two numbers.

I will look into it :)

[code]

fig1 = argument0 // BIGGER NUMBER
fig2 = argument1 //SMALLER NUMBER
divison = argument2
new_fig1 = fig1 / division
new_fig2 = fig2 / division
[/code]

Labels:

Expanding

Hi

Here is another Mathematical function from me.

Expanding is when you multiply two figures in a bracket with the number on the outside on the left hand side. Or as most people would call it. Blimn algebra. Expanding works as follows a(b+c) or a(b-c) or a(b/c) or a(b*c) . A is the multiplying factor and B and C are the figures that are multiplyed.

[code]

fig1 = argument0
fig2 = argument1
multiplyer = argument2
fig1 = fig1*multiplyer
fig2 = fig2*multiplyer
fig3 = string(fig1) + " + " + string(fig2)

[/code]

Labels:

fibonacci

I was looking at fibonacci sequences and i thought, was this GM compatiable. And of course it was. There are better scripts for this but this one doesn't use sqrt or power, but it does require variables!

[code = create event]

last_number = 0
new_number = 1

[/code]

Last_number is the last number which is 0, this won't be found unforunately without calling it first.
new_number is our first number

Don't put this in STEP event
[code]
//usuage: fibonacci(num) - num is the number of figures to find
repeat(argument0)
{
i = new_number + last_number
last_number = new_number
new_number = i
}

i is the finding of the last two figures


that is it. I am not sure how this would help with your games but it is here

Labels:

Finding the difference in Angles

Hi.

This post is about finding the difference in angles. Angles are very unbelievable in GameMaker. Because they have to use the X and Y co-ordinates to give 2 angles this makes it harder to figure out what the difference in angles. We will have to use a example to make this script more easier to understand.

[code]

angle = point_direction(x,y,argument0,argument1)
angle2 = point_direction(x,y,argument2,argument3)
angle3 = angle - angle2
show_message(string(angle3))
[/code]

Explaining what everything does.

angle = point_direction(x,y,argument0, argument1) - The biggest angle you need to use. This defines the angle which is will be taken away from the smaller angle (or the first angle)

angle 2= point_direction(x,y,argument2, argument3) - The smaller angle. Subtracts the first one from itself.

angle3 = angle - angle2 - Finds the difference by taking away angle (big one) - the smaller one

Labels: