Kind of a bump, it was the color setting, it works now, but I have more doubts:
I'm trying to make a flametrhower effect. I don't want to create an object just for that if I can avoid it (if there is no other way, I'll do it). Here's the effect I want:
- When I press space, many flame sprites are successively drawn moving away from the object, one after another, until a maximum lenght is reached.
- When I press "left/right", the sprites keep being drawn, but moving in another angle. Plus, the ones that are already drawn keep the angle they got, giving to the flames a "snake" aspect.
- When I press "up/down", it increases the lenght the flames go until disapear.
- If that's not hard enough, I want the flames to incease in size as move away from the object.
- Ah, using GM8, lite.
Using an object for the flames would be simple, but I'm complicated. Well, I already have something, but as anyone who tests it will notice, it is far from the effect I want. Let me post the object info:
Information about object: obj_flamethrower
Create Event:
execute code:
fire=12
fire_lenght=32
var i;
for (i=0;i<=fire;i+=1)
{
dir[i]=direction
xx[i]=x
yy[i]=y
}
Step Event:
var i;
for (i=fire;i>0;i-=1)
{
xx[i]=xx[i-1]+lengthdir_x(fire_lenght,dir[i-1])
yy[i]=yy[i-1]+lengthdir_y(fire_lenght,dir[i-1])
dir[i]=dir[i-1]
}
xx[0]=x
yy[0]=y
dir[0]=direction
if keyboard_check(vk_space)
fire_lenght=32
else
fire_lenght=0
if keyboard_check(vk_left)
direction+=10
if keyboard_check(vk_right)
direction-=10
if keyboard_check(vk_up)
fire+=1
if keyboard_check(vk_down)
fire-=1
Draw Event:
var i;
for (i=0;i<=fire;i+=1)
{
draw_sprite(spr_fire,0,xx[i],yy[i])
}So far, the sprites are all the same size. When I stop pressing space, the flames "go back" to the object (I'd like them to keep their move until the maximum lenght and disappear). And, when I try to increase the chain size (pressing up beyond the point it started) I get the following error:
___________________________________________
ERROR in
action number 1
of Draw Event
for object obj_flamethrower:
Error in code at line 4:
draw_sprite(spr_fire,0,xx[i],yy[i])
^
at position 25: Unknown variable xx or array index out of bounds
I know, I didn't set the array to go that far, but how do I do this on the fly? Do I need to make a huge array and hope the player doesn't go beyond its size?
Edited by saim, 19 March 2010 - 02:24 AM.