Something went wrong. Try again.
Example for an easy dialog system with many features for use in GameMaker:Studio
Something went wrong. Try again.
5.1 kB · 160 lines
at master
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161<!--This Document is generated by GameMaker, if you edit it by hand then you do so at your own risk!--><object> <spriteName>sLuke</spriteName> <solid>0</solid> <visible>-1</visible> <depth>0</depth> <persistent>0</persistent> <parentName><undefined></parentName> <maskName><undefined></maskName> <events> <event eventtype="0" enumb="0"> <action> <libid>1</libid> <id>603</id> <kind>7</kind> <userelative>0</userelative> <isquestion>0</isquestion> <useapplyto>-1</useapplyto> <exetype>2</exetype> <functionname></functionname> <codestring></codestring> <whoName>self</whoName> <relative>0</relative> <isnot>0</isnot> <arguments> <argument> <kind>1</kind> <string>///Initialize variables//For movementmoving = 0;//For running the animationimage_speed = 0;imageSpeed = 0;imageIndex = 0;dir = 0;//Other thingsname = "";</string> </argument> </arguments> </action> </event> <event eventtype="3" enumb="0"> <action> <libid>1</libid> <id>603</id> <kind>7</kind> <userelative>0</userelative> <isquestion>0</isquestion> <useapplyto>-1</useapplyto> <exetype>2</exetype> <functionname></functionname> <codestring></codestring> <whoName>self</whoName> <relative>0</relative> <isnot>0</isnot> <arguments> <argument> <kind>1</kind> <string>///Grid based movement with arrow keys//Count down the timer before player can move againif(moving) { moving--; imageSpeed = 4/8; //Run the animation}if(!moving) { //Set the hspeed/vspeed to arrow keys. Replace with ord('w'), etc. for wasd controls hspeed = (keyboard_check(vk_right) - keyboard_check(vk_left)) * 4; vspeed = (keyboard_check(vk_down) - keyboard_check(vk_up)) * 4; //If moving, prevent the player from changing direction if(hspeed != 0 || vspeed != 0) { moving = 32 / 4; } else { //Otherwise stop the animation imageSpeed = 0; }}//Use this method of running the animation to limit the frames to just one directionimageIndex = (imageIndex + imageSpeed) % (image_number / 4); //imageIndex is the frameif(vspeed > 0) { //Dir holds the directions dir = 0;} else if(vspeed < 0) { dir = 9;} else if(hspeed > 0) { dir = 6;} else if(hspeed < 0) { dir = 3;} else if(imageSpeed == 0) { //If not moving, choose the standing pose imageIndex = 1;}//Add them together for the correct animationimage_index = imageIndex + dir;</string> </argument> </arguments> </action> </event> <event eventtype="5" enumb="32"> <action> <libid>1</libid> <id>603</id> <kind>7</kind> <userelative>0</userelative> <isquestion>0</isquestion> <useapplyto>-1</useapplyto> <exetype>2</exetype> <functionname></functionname> <codestring></codestring> <whoName>self</whoName> <relative>0</relative> <isnot>0</isnot> <arguments> <argument> <kind>1</kind> <string>///Talk to peopleif(instance_exists(_NPC)) { inst = instance_nearest(x, y, _NPC); if(distance_to_object(inst) < 32) { //If in a space next to an NPC //Show their messages //Note that this is just one way to do it, and there are certainly other ways it could be done better. with(inst) { if(array_length_2d(message, 0) < 5) { //Manually if the dialog is entered manually var i; for(i = firstMessage; i < messageCount + firstMessage; i++) { dialog_msg(message[i, 0], message[i, 1], message[i, 2], message[i, 3]); } } else { //From array if there is a fifth element dialog_from_array(firstMessage, firstMessage + messageCount - 1); } if(firstMessage + messageCount < array_height_2d(message)) { firstMessage += messageCount; } } }}</string> </argument> </arguments> </action> </event> </events> <PhysicsObject>0</PhysicsObject> <PhysicsObjectSensor>0</PhysicsObjectSensor> <PhysicsObjectShape>0</PhysicsObjectShape> <PhysicsObjectDensity>0.5</PhysicsObjectDensity> <PhysicsObjectRestitution>0.100000001490116</PhysicsObjectRestitution> <PhysicsObjectGroup>0</PhysicsObjectGroup> <PhysicsObjectLinearDamping>0.100000001490116</PhysicsObjectLinearDamping> <PhysicsObjectAngularDamping>0.100000001490116</PhysicsObjectAngularDamping> <PhysicsObjectFriction>0.200000002980232</PhysicsObjectFriction> <PhysicsObjectAwake>-1</PhysicsObjectAwake> <PhysicsObjectKinematic>0</PhysicsObjectKinematic> <PhysicsShapePoints> <point>0,0</point> <point>16,16</point> </PhysicsShapePoints></object>