Help with object spawning in the background

Started by MisterN, May 29, 2013, 11:48:10 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MisterN

Hello, I need some help with the tiled library that is available here:
http://forum.bennugd.org/index.php?topic=3437

The enemy in my game will spawn, but wont be shown every time. Even though I set the z, it still doesnt. Now there may be no correlation with my issue, but I looked in the libraries code, and lines 253 and 374 of api.inc has this:


for (i=0; i<map.layercount; i++)
    layer     = tilemap_layer_scroll(i, map.layers[i], map.tileset,  width,  height);
    layer.x = graphic_info(0, 0, G_WIDTH)/2;
    layer.y = graphic_info(0, 0, G_HEIGHT)/2;
    SCROLL[i].z -= i;
    viewport.layer_scrolls[i] = layer;
end


and I see later on line 253 there is:

z = SCROLL[scroll_id].z;

Do any of you have the slightest idea what the link between these two is? Do you think that by changing this it will correct the issue of the enemy not appearing? I also wonder why the fps is usually 48-50 instead of 60 (it is either my pc or its the game somehow). Please help me.
Thanks
werg

JaViS

Hey I'm very sorry for the super late reply.


What's the z you're giving to your enemy process?



Working on Anarkade. A couch multiplayer 2D shooter.

MisterN

look at the code, its -1. Player z is 0 and appears just fine.
werg

JaViS

Then I think it shouldn't be a Z problem. maybe the enemy isn't spawning.
Working on Anarkade. A couch multiplayer 2D shooter.

MisterN

no it spawns, play with the code, if you give it a say command when it first starts up it will say it. and if you make a button that will return a say command at any time inside the process, it will say it.
werg

JaViS

ok, can you update your code and upload it again?


last time I revised it was working for me and not for u so I think it's important both of us to have the same version
Working on Anarkade. A couch multiplayer 2D shooter.

MisterN

just replace this part of enemy.prg
begin
z = -1;
ctype = c_scroll;
//upon startup it will either move left or right
dir = rand(0,1);
//load the sprites
enemy_r = load_png("enemy_r.png");
enemy_l = load_png("enemy_l.png");
get_id(procID);
say("i exist");
    loop
    if(key(_q))
        say("i still exist");
    end
    if (!out_region(id , 0))
werg

MisterN

put this into the main loop
if(key(_d))
            enemy(game_width,game_height);
            while(key(_d))frame;end
        end


I noticed that if theres more than 3 processes doing collision checks, the game slows down alot. if that is the case, then I cant really use this engine as is at the moment. i hope everything becomes spectacular soon one day.
werg