BellGoRiiing
Member
I give up...>_>
#-------------------------------------------------------------------
# Create an array of triangles (A, B, C),
# where each corner is a point (x, y)
# in the order you want them to fly off
#-------------------------------------------------------------------
# Save the current map to a bitmap
# For each triangle
#-------------------------------------------------------------------
# determine the bounding rectangle of the triangle ABC
# and copy that rectangle to a new bitmap (sprite)
x = [Ax, Bx, Cx].min
y = [Ay, By, Cy].min
xm = [Ax, Bx, Cx].max
ym = [Ay, By, Cy].max
width = xm - x
height = ym - y
src_rect = Rect.new(x, y, width, height)
new_bitmap = blt(0, 0, src_bitmap, src_rect)
#-------------------------------------------------------------------
# Trim each bitmap to the triangle
# Determine if point D is inside or outside triangle made by ABC
angle DA = arctan((Ay - Dy) / (Ax - Dx))
angle DB = arctan((By - Dy) / (Bx - Dx))
angle ADB = angle DA - angle DB
angle ADB = ADB < 180 ? ADB : 360 - ADB
angle DA = arctan((Ay - Dy) / (Ax - Dx))
angle DC = arctan((Cy - Dy) / (Cx - Dx))
angle ADC = angle DA - angle DC
angle ADC = ADC < 180 ? ADC : 360 - ADC
angle DC = arctan((Cy - Dy) / (Cx - Dx))
angle DB = arctan((By - Dy) / (Bx - Dx))
angle BDC = angle DC - angle DB
angle BDC = BDC < 180 ? BDC : 360 - BDC
if angle ADB + ADC + BDC < 360, the point is outside. Erase it.
#-------------------------------------------------------------------
# now place each bitmap into a sprite, and position it on the screen
#-------------------------------------------------------------------
# erase the background image (transfer to the battle screen)
#-------------------------------------------------------------------
# Now make the sprites fly off the screen
frame = 0
for i in 0..<# of triangles * speed * delay> ???
for j in triangles (or bitmaps)
if j < frame / delay
triangle.x -= speed
end
end
end