Im trying to test out my multiplayer game! Ive got GM to connect via TCP/IP but I dont know how to get my IP address so I can tell my friend what IP to enter? How do I check what my IP address is so that my friend cam connect over the internet?
Im trying to test out my multiplayer game! Ive got GM to connect via TCP/IP but I dont know how to get my IP address so I can tell my friend what IP to enter? How do I check what my IP address is so that my friend cam connect over the internet?
If you're connecting over the internet, you can retrieve your internet address from this website
If you're testing it on LAN, you can see your IP in Window's network connection properties.
Hey guys, Im trying to have my game connect over the net! Now I was about to try connect to his PC but his net has just gone down!!! Please tell me if Im missing something in my code! All its supposed to do is check if I am connected to a session!
In the connection app:
Left released:
mplay_init_tcpip(his IP)
sesname = get_string('What is your session name?', '')
name = get_string('What is your name?', '')
mplay_session_create(sesname, 0, name)
room_goto(Game)
In the joining app:
Left released:
mplay_init_tcpip(his IP)
if (mplay_session_find() = true)
{
room_goto(Game)
}
else
{
show_message('Nothing')
}
Should this work or is it missing something! I have a button that tells me if Im connected or not!
Seems like that would work. I'd suggest doing a call to mplay_connect_status() to figure out if the connection resolved or not before you test the session stuff.
Remember that if you have firewalls and the like things are probably not going to work. GM uses the DirectPlay default network ports, so it often gets blocked.
-D
Like I said above, the button I was talking about does use mplay_connect_status(), and I have disabled my firewall, and my friend is disabling his!
Ah, I'd suggest using
if (mplay_session_find() > 0) instead of if (mplay_session_find() = true), mplay_session_find() returns the number of sessions, not a boolean value.
-D
Alrighty, I'm busy drawing a primitive like so:
What I want to know is how can I fill this primitive with a colour?draw_set_alpha(1);
draw_set_color(c_white);
draw_primitive_begin(pr_linestrip);
draw_primitive_begin(pr_linestrip);
for (i=0;i<num_points;i+=1)
{
dx = vx[i]-origin_x;
dy = vy[i]-origin_y;
r = sqrt(dx*dx + dy*dy);
theta = arctan2(dy, dx);
vert_x = x+r*cos(theta+degtorad(image_angle));
vert_y = y-r*sin(theta+degtorad(image_angle));
draw_vertex(vert_x,vert_y);
}
dx = vx[0]-origin_x;
dy = vy[0]-origin_y;
r = sqrt(dx*dx + dy*dy);
theta = arctan2(dy, dx);
vert_x = x+r*cos(theta+degtorad(image_angle));
vert_y = y-r*sin(theta+degtorad(image_angle));
draw_vertex(vert_x,vert_y);
draw_primitive_end();
draw_set_color(c_white);
@Cinimod: Monochrome supplies the host machine's IP address. GM's helpfile says that you don't need to do this on a LAN, but I just did it anyway. Monochrome has reportedly worked over the intertubes, so it might make a difference there :)
@Squid: You're going to need to change the type of primitive that you're drawing, lines don't have any area that can be filled, so you're going to need to draw triangles. That means using pr_trianglelist (list of triangles, three vertices at a time), pr_trianglestrip (three vertices initially, then 1 vertex for each triangle after that, the two "latest" vertices of the previous triangle are used) or pr_trianglefan (three vertices initially, then 1 for each triangle thereafter, the first vertex and the last vertex you supplied create the resulting triangle).
Obviously this has mathematical changes in your code, but I'm sure you can figure that out. I'd suggest starting with pr_trianglestrip and making sure you're always passing three vertices. You might also want to use a different vertex format, such as draw_vertex_color().
-D
Hey, I want to try mess around with GM 3D functions! Is it possible to use blender or poser to make a model, and then import it into GM?
I have a question or two:
In a game where the art goes through lots of iterations, reloading sprites becomes a chore, and a production bottleneck.
So is there some way of linking (instead of embedding) resources in GM? Of course objects can be made to reload their own sprites - but this needs manual setup in every object and will be error prone, especially since you cannot browse for a file to make sure you reload the correct one.
You can also setup objects automatically, but how do you refer to them in your scripts then? Normally you would just use the object name, but now all you have is an ID (which changes every step or something?)
Finally, what is the best way check whether two objects are touching? In heaven there would be two events "onTouchStarted" and "onTouchStopped"; what do we have here on earth? Using collisions and step events or performing proximity calculations seem a little clumsy...[Just to be clear - I have certain objects that should behave differently depending on whether other objects are over them or not, and I have lots of them...and I want even more! All objects are mostly stationary - some just appear and disappear depending on user input.]
Be gentle if I miss something obvious...I am still growing out of my noob phase!
thx
ht
@Cinimod: There's an answer to your question in the Deathbringer thread. :)
Not that I know of per se. I do know that you can load in sprites dynamically. So you might be able to use placeholder sprites for most of the development and then have an initialiser script on an object at depth 10000 which goes through all the sprites and pulls in the latest versions of their files (you'd probably have to have sprite names and filenames be exactly the same, or use some other identification system). You could also parent all your objects to a SpriteReloader object, although that wouldn't be optimal if you're creating tons of objects on the fly.
I know this can be a big headache. It's the main reason that I don't tend to colour sprites outside GM: I'll leave them white and colour them at the object level. Also I'm a big fan of minimalist graphics up until final release ;)
Not quite sure what you mean here. There are two types of object handles: ids and indexes. An id is a by-value pointer to a specific object, obtainable using object.id. Each instance in GM is assigned a unique id (starting from 10001 and going up from there) when you use that id in dot notation - variable.property or (number).property - GM looks up the object with that id and does things to it. An index is an object type name, object.object_index. When you create a new object in GM's editor, that's an object index. If you refer to an index in a scope that expects a type, it will act as a type - examples are in parenting settings, with statements or collision functions. If you refer to an index in a scope that expects an id, it will resolve to the id of the oldest object of that particular type. This is not guaranteed and can sometimes shuffle around if the list of objects is re-sorted due to memory management or excessive culling. This is probably the main cause of your "ids randomly change each frame" misconception.You can also setup objects automatically, but how do you refer to them in your scripts then? Normally you would just use the object name, but now all you have is an ID (which changes every step or something?)
Be careful how you use index to id resolution! Dot notation will change a specific value on the entire collection of instances of that type if used directly on an index... That means that
ObjectType.value = 0
and
oldestInstance = ObjectType;
oldestInstance.value = 0;
are different. The first will set value to 0 on ALL current instances of ObjectType. The second will only set value to 0 on the oldest instance of ObjectType.
Whenever you create an object in GM that object's unique id is returned. Whenever you create an object type that type's unique index is returned. Both are numbers, used in GM's internal object registries. An index is never above 10000, an id is never below 10000.
The event handler that generated onTouchStarted and onTouchStopped would be doing collision detection against flags every frame anyway ;). Logically it makes more sense, but go with simple collision setting a flag, step testing the flag, end-step clearing the flag. If you can get away with it, instance_position() is much cheaper than position_meeting() or other object-object collision testing methods.Finally, what is the best way check whether two objects are touching? In heaven there would be two events "onTouchStarted" and "onTouchStopped"; what do we have here on earth? Using collisions and step events or performing proximity calculations seem a little clumsy...[Just to be clear - I have certain objects that should behave differently depending on whether other objects are over them or not, and I have lots of them...and I want even more! All objects are mostly stationary - some just appear and disappear depending on user input.
-D
@Herman: Only read the "mostly stationary, dis/appear on user input" line now. In that case I'd suggest doing manual collision tests on creation and queueing up tests on collided objects with flags set on them during deletion. That would lower your calculation burden per frame quite substantially... Make sense?
-D
Hey, Im having a bit of a problem here! I want to store just one string in a text file, the text file is called check, and I want the string its storing to be check, so this is what I have:
Create:
if (file_exists('Check.txt')){
file_text_open_read('Check.txt')
check = file_text_read_string('Check.txt')
}
But it brings up an error saying the file is not open for reading!?!
I see your problem. You're trying to use the file name as a handle in your file_text_read_string(blah) function. Unfortunately, GM won't allow that. You need to create a handle variable for the file a-like-a so:
MyFile=file_text_open_read('Check.txt')
check = file_text_read_string(MyFile)
Also don't forget to close the file when you're done reading from it (can't remember the relevant command now. It's in the help). Just remember, all the file read and write functions use the handle you specify in your file open/create function.