Jump to content


Walter Sullivan

Member Since 23 Nov 2009
Offline Last Active Apr 22 2012 03:36 PM

Topics I've Started

Simple question[SOLVED]

07 October 2010 - 09:40 PM

Well, I'm trying to make that when my obj_player collides with a certain object, who needs to have an image_index of 1 or 2, it stops. But my obj_player needs to can go through this same object if it has an image_index = 0. Here is what I've done:

//in obj_player collide event with the other object:
if (other.image_index >=1) {
    vspeed=0;
}

The problem is, that even if the other object image_index is 0, it will collide with my obj_player and make it stop. How do I fix that? I need to can pass through this object if his image_index=0.  :(

Problem loading objects positions

04 October 2010 - 03:07 PM

I'm trying to create a save file to my game, so I can save the position of all the objects if I press a key, and when I open the game again all this positions be loaded, but only the last object is being saved(and with the coordinates all wrong), while the other objects are being ignored. Here's my code:

THE SAVE CODE(when I press S, it's saving a .ini file that looks perfect):
var i;
numPedras = instance_number(obj_rock);
numMadeiras = instance_number(obj_lumber);
numGramas = instance_number(obj_grass);
var ax,ay;
ax = obj_player.x;
ay = obj_player.y;
file = file_text_open_write("save.sav");
file_text_write_string(file,"[PLAYER]");
file_text_writeln(file);
file_text_write_string(file,"Player X = "+string(ax));
file_text_writeln(file);
file_text_write_string(file,"Player Y = "+string(ay));
file_text_writeln(file);
file_text_write_string(file,'ROCK');
for(i=0;i<numPedras;i+=1){
    pedra = instance_find(obj_rock,i);
    file_text_writeln(file);
    file_text_write_string(file,"PedraX= "+string(pedra.x));
    file_text_writeln(file);
    file_text_write_string(file,"PedraY = "+string(pedra.y));
}
file_text_writeln(file);
file_text_write_string(file,'LUMBER');
for(i=0;i<numMadeiras;i+=1){
    madeira = instance_find(obj_lumber,i);
    file_text_writeln(file);
    file_text_write_string(file,"MadeiraX= "+string(madeira.x));
    file_text_writeln(file);
    file_text_write_string(file,"MadeiraY = "+string(madeira.y));
}
file_text_writeln(file);
file_text_write_string(file,'GRASS');
for(i=0;i<numGramas;i+=1){
    grama = instance_find(obj_grass,i);
    file_text_writeln(file);
    file_text_write_string(file,"GramaX= "+string(grama.x));
    file_text_writeln(file);
    file_text_write_string(file,"GramaY = "+string(grama.y));
}
file_text_close(file)

And in the CREATE EVENT of the player, there is:
if(!file_exists("save.sav")){
//Lots of code
} 
   else{
        file = file_text_open_read("save.sav");
        file_text_readln(file);
        ax = file_text_read_string(file);
        obj_player.x = real(string_digits(ax));
        file_text_readln(file);
        ay = file_text_read_string(file);
        obj_player.y = real(string_digits(ay));
        file_text_readln(file);
        file_text_readln(file);
        while(file_text_read_string(file)!='LUMBER'){
            ax = file_text_read_string(file);        
            OBJX = real(string_digits(ax));
            file_text_readln(file);
            ay = file_text_read_string(file);   
            OBJY = real(string_digits(ax));
            instance_create(OBJX,OBJY,obj_rock);
            file_text_readln(file);
        }
        file_text_readln(file);
        while(file_text_read_string(file)!='GRASS'){
            ax = file_text_read_string(file);        
            OBJX = real(string_digits(ax));
            file_text_readln(file);
            ay = file_text_read_string(file);   
            OBJY = real(string_digits(ax));
            instance_create(OBJX,OBJY,obj_lumber);
            file_text_readln(file);
        }
        file_text_readln(file);
        while(!file_text_eof(file)){
            ax = file_text_read_string(file);        
            OBJX = real(string_digits(ax));
            file_text_readln(file);
            ay = file_text_read_string(file);   
            OBJY = real(string_digits(ax));
            instance_create(OBJX,OBJY,obj_grass);
            file_text_readln(file);
        }                        
        file_text_close(file);
   }

The player coordinates are being read correctly but...
The problem is: only the obj_grass are being made, and in different coordinates than they should be(and I checked the created INI file and it has the right position of ALL objects stored on it).
Oh, and if I save the game, load with the bugs and save again, it will store only the new obj_grass coordinate.
Anyone knows how to solve that problem? :(

Online Engine V2 Question...[solved :d]

12 April 2010 - 03:08 PM

Well, after a lot of time reading tutorials/looking at the source of examples/reading more tutorials I have managed to understand a bit of the 39dll and the Online Engine. So far, I know how to make the players see each other and everything, and when they press control(the dig button), the hole appears to both in the right place.
But... for example, if I'm playing alone, dig, and the other player enters the game, he won't see the hole that I have digged before he entered the game. So my question is: how do I make it to when a player enter the games, the objects that are on the room(and was created by other players before he enters) appears to him? If necessary, I can try to explain this better or post my code...
If anyone knows what I need to do, your help is welcome :)

Change The Sprite Error D:

02 April 2010 - 04:31 PM

Well, I'm trying to make that when my character is looking down and I press control, he uses a weapon and then, after the attack animation, go back looking down, but It enter in an infinite loop that only ends if I press the control again when it's on the 3rd animation weapon sprite.
The code that I made is this, and it is on the [Press Ctrl] event:

if sprite_index==spr_player_down
{
    sprite_index=spr_player_enx_down;
    image_speed=0.5;
}
if (image_index + image_speed >= 3)
{  
    sprite_index=spr_player_down;
    image_index=0;
    image_speed=0;
}

The attacking sprite looking down(that is the spr_player_enx_down) has 4 subimages, so I want that when it reaches the 4th one(that would be the image_index number 3), it goes back looking down... I already tried puting things like "if (image_index==3), (image_index >= 3) and float(image_index)>=3, but it always works the same, where it makes a infinite loop that only ends if I press the control again in the 3rd sprite animation...
If someone knows what I need to do, please help me :mellow: