How can I s_kill it when it goes off screen?

Started by MisterN, July 28, 2011, 11:00:00 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MisterN

for player I have it set right now then when its underneath 240 y it automatically gets killed. i have a system where only so many bullets can be on screen but the problem is I cant figure out code so when its off screen it gets killed and the counter goes down (so you can fire more bullets). i tried using out_region, but i dont even think thats for what i wanted to do lol. do you know of an If code that signals when something goes off screen (or region) and then s_kill's it? Thanks
werg

MisterN

Hmm I tried making a border thing that went around the scren but that didn't really help at all. any ideas for when it goes off the cmaera/screen/thingy?
werg

handsource-dyko

out_region is the most appropriate way to do this, but it requires that an actual region is defined, and that the region it is assigned to the scroll. The region number is the second last argument of the start_scroll function.

MisterN

out_region doesnt work, like ive said, ive defined a region but 0 is the default region (which is what you see on the screen). i put it in the code but i get errors upon errors of why. and the wiki shows absolutely no example code of how it works. look at the code, i want it that when it goes of screen it gets destroyed and bullets on screen goes down 1 (like seen in the code)
[code language="bennu"]process playerbullet(x, y, dir);
private
    BULLET_SPEED = 8;
   int pixel; 
    int red,blue,green;
   int bullet_id;
begin
get_id(bullet_id);
ctype=c_scroll;
z=-1;
graph = bullet_graph;
        loop
            x = x + BULLET_SPEED * dir;
         pixel = map_get_pixel(0, levelmask, x, y);
         get_rgb (pixel, & red, & green, & blue);
            if (blue<220)
               play_wav(cant_hit_sound,0);
               bullets_on_screen = bullets_on_screen -1;
            break;
            end
        frame;
    end
end [/code]
werg

MisterN

tried some more different combinations, still confused
werg

gecko

inside the bullet process itself you should add

if ( region_out(id,0) )
    signal(id, S_KILL)
end
Torres Baldi Studio
http://torresbaldi.com

MisterN

Thank you so much! now I am almost done with my engine.
werg