// File: /workspace/github_cpp_makefile_star2_O2/Jacobious52[P]Tanks/Bullet.cpp
// Function: Bullet::update(int)
void Bullet::update(int t)
{
    // don't update unless launched
    if (_launched == false)
    {
        return;
    }

    // increment velocity and position
    // vel += (gravity + wind) * slowdownfactor
    // pos += vel
    _velocity = _velocity + (Point<float>(0, GRAVITY) + Point<float>(_terrain->get_wind_speed(), 0)) * Point<float>(0.1, 0.1);
    _position = Point<int>(static_cast<int>(_position.x + _velocity.x), static_cast<int>(_position.y + _velocity.y));

    // remove if outside of view
    if (_position.y >= _terrain->get_size().y
        || _position.x >= _terrain->get_size().x
        || _position.x <= 0)
    {
        _should_remove_from_parent = true;
    }
    else if (_position.y <= 0)
    {
        // show ^ for above screen
        _position.y = 0;
        _texture = "^";
    }
    else
    {
        // going left to right
        if (_velocity.x > 0.5)
        {
            // going down
            if (_velocity.y > 0.5)
            {
                DebugView::shared_view()->watch("direction", 1);
                _texture = TextureTools::get_texture("bullet_down");
            }
            else if (_velocity.y < -0.5)
            {
                // going up
                DebugView::shared_view()->watch("direction", 2);
                _texture = TextureTools::get_texture("bullet_up");
            }
            else
            {
                // going horrizontal
                DebugView::shared_view()->watch("direction", 3);
                _texture = TextureTools::get_texture("bullet_flat");
            }
        }
        else if (_velocity.x < -0.5)
        {
            if (_velocity.y > 0.5)
            {
                // going down
                DebugView::shared_view()->watch("direction", 4);
                _texture = TextureTools::get_texture("bullet_up");
            }
            else if (_velocity.y < -0.5)
            {
                // going up
                DebugView::shared_view()->watch("direction", 5);
                _texture = TextureTools::get_texture("bullet_down");
            }
            else
            {
                // horizontal
                DebugView::shared_view()->watch("direction", 6);
                _texture = TextureTools::get_texture("bullet_flat");
            }
        }
        else
        {
            // vertical
            DebugView::shared_view()->watch("direction", 0);
            _texture = TextureTools::get_texture("bullet_vert");
        }

        LOOPV(i, _terrain)
        {
            if (_position.y >= _terrain->get_floor(_position.x))
            {
                // bullet hit ground.. remove it
                _position.y = _terrain->get_floor(_position.x);
                if (_terrain->impact(Point<int>(_position.x, _terrain->get_floor(_position.x)), 10))
                {
                    DebugView::shared_view()->watch("impact x", _position.x);
                    DebugView::shared_view()->watch("impact y", _terrain->get_floor(_position.x));
                    _should_remove_from_parent = true;
                }
            }
        }
    }

    // update debug watch vars
    DebugView::shared_view()->watch("bullet pos x ", static_cast<float>(get_position().x));
    DebugView::shared_view()->watch("bullet pos y ", static_cast<float>(get_position().y));
    DebugView::shared_view()->watch("bullet vel x ", _velocity.x);
    DebugView::shared_view()->watch("bullet vel y ", _velocity.y);

    Sprite::update(t);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2b8, %rsp            # imm = 0x2B8
cmpb $0x0, 0x70(%rdi)
je 0x84bb
movq %rdi, %r14
movl %esi, -0x58(%rbp)
movq 0x80(%rdi), %rdi
callq 0x7630
xorps %xmm1, %xmm1
addss %xmm0, %xmm1
mulss 0x2fd9(%rip), %xmm1     # 0xb238
addss 0x60(%r14), %xmm1
movss 0x64(%r14), %xmm0
addss 0x2fc9(%rip), %xmm0     # 0xb23c
movaps %xmm1, %xmm2
unpcklps %xmm0, %xmm2            # xmm2 = xmm2[0],xmm0[0],xmm2[1],xmm0[1]
movlps %xmm2, 0x60(%r14)
cvtsi2ssl 0x18(%r14), %xmm2
addss %xmm1, %xmm2
cvttss2si %xmm2, %eax
cvtsi2ssl 0x1c(%r14), %xmm1
addss %xmm0, %xmm1
cvttss2si %xmm1, %ebx
movq %rbx, %rcx
shlq $0x20, %rcx
orq %rcx, %rax
movq %rax, 0x18(%r14)
movq 0x80(%r14), %rdi
callq 0x8d2e
shrq $0x20, %rax
cmpl %eax, %ebx
jge 0x83a4
movl 0x18(%r14), %ebx
movq 0x80(%r14), %rdi
callq 0x8d2e
cmpl %eax, %ebx
jge 0x83a4
cmpl $0x0, 0x18(%r14)
jle 0x83a4
cmpl $0x0, 0x1c(%r14)
jle 0x84cd
movss 0x60(%r14), %xmm0
ucomiss 0x2f45(%rip), %xmm0     # 0xb240
jbe 0x84e7
movss 0x64(%r14), %xmm0
ucomiss 0x2f32(%rip), %xmm0     # 0xb240
jbe 0x859b
callq 0x4aac
movq %rax, %rbx
leaq 0x2f48(%rip), %rsi      # 0xb26b
leaq -0x298(%rbp), %rdi
leaq -0x50(%rbp), %rdx
callq 0x3120
leaq -0x298(%rbp), %rsi
movss 0x2f1a(%rip), %xmm0     # 0xb25c
movq %rbx, %rdi
callq 0x8f84
leaq -0x298(%rbp), %rdi
callq 0x3340
leaq 0x2f18(%rip), %rsi      # 0xb275
leaq -0x278(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x3120
leaq -0x50(%rbp), %rdi
leaq -0x278(%rbp), %rsi
callq 0x79ee
leaq 0x38(%r14), %rdi
leaq -0x50(%rbp), %rsi
callq 0x3180
leaq -0x50(%rbp), %rdi
callq 0x3340
leaq -0x278(%rbp), %rdi
callq 0x3340
jmp 0x887f
movb $0x1, 0x30(%r14)
callq 0x4aac
movq %rax, %rbx
leaq 0x2efd(%rip), %rsi      # 0xb2b5
leaq -0xd8(%rbp), %rdi
leaq -0x50(%rbp), %rdx
callq 0x3120
movq %r14, %rdi
callq 0x8d1a
cvtsi2ss %eax, %xmm0
leaq -0xd8(%rbp), %rsi
movq %rbx, %rdi
callq 0x8f84
leaq -0xd8(%rbp), %rdi
callq 0x3340
callq 0x4aac
movq %rax, %rbx
leaq 0x2ec5(%rip), %rsi      # 0xb2c3
leaq -0xb8(%rbp), %rdi
leaq -0x50(%rbp), %rdx
callq 0x3120
movq %r14, %rdi
callq 0x8d1a
shrq $0x20, %rax
cvtsi2ss %eax, %xmm0
leaq -0xb8(%rbp), %rsi
movq %rbx, %rdi
callq 0x8f84
leaq -0xb8(%rbp), %rdi
callq 0x3340
callq 0x4aac
movq %rax, %rbx
leaq 0x2e89(%rip), %rsi      # 0xb2d1
leaq -0x98(%rbp), %rdi
leaq -0x50(%rbp), %rdx
callq 0x3120
movss 0x60(%r14), %xmm0
leaq -0x98(%rbp), %rsi
movq %rbx, %rdi
callq 0x8f84
leaq -0x98(%rbp), %rdi
callq 0x3340
callq 0x4aac
movq %rax, %rbx
leaq 0x2e57(%rip), %rsi      # 0xb2df
leaq -0x78(%rbp), %rdi
leaq -0x50(%rbp), %rdx
callq 0x3120
movss 0x64(%r14), %xmm0
leaq -0x78(%rbp), %rsi
movq %rbx, %rdi
callq 0x8f84
leaq -0x78(%rbp), %rdi
callq 0x3340
movq %r14, %rdi
movl -0x58(%rbp), %esi
callq 0x63c2
addq $0x2b8, %rsp            # imm = 0x2B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
andl $0x0, 0x1c(%r14)
leaq 0x38(%r14), %rdi
leaq 0x2d8c(%rip), %rsi      # 0xb269
callq 0x34b0
jmp 0x83a9
movss 0x2d55(%rip), %xmm1     # 0xb244
ucomiss %xmm0, %xmm1
jbe 0x8642
movss 0x64(%r14), %xmm0
ucomiss 0x2d3b(%rip), %xmm0     # 0xb240
jbe 0x86cd
callq 0x4aac
movq %rax, %rbx
leaq 0x2d51(%rip), %rsi      # 0xb26b
leaq -0x1d8(%rbp), %rdi
leaq -0x50(%rbp), %rdx
callq 0x3120
leaq -0x1d8(%rbp), %rsi
movss 0x2d17(%rip), %xmm0     # 0xb250
movq %rbx, %rdi
callq 0x8f84
leaq -0x1d8(%rbp), %rdi
callq 0x3340
leaq 0x2d2d(%rip), %rsi      # 0xb281
leaq -0x1b8(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x3120
leaq -0x50(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x79ee
leaq 0x38(%r14), %rdi
leaq -0x50(%rbp), %rsi
callq 0x3180
leaq -0x50(%rbp), %rdi
callq 0x3340
leaq -0x1b8(%rbp), %rdi
callq 0x3340
jmp 0x887f
movss %xmm0, -0x54(%rbp)
callq 0x4aac
movq %rax, %rbx
movss 0x2c94(%rip), %xmm0     # 0xb244
ucomiss -0x54(%rbp), %xmm0
jbe 0x8774
leaq 0x2caa(%rip), %rsi      # 0xb26b
leaq -0x258(%rbp), %rdi
leaq -0x50(%rbp), %rdx
callq 0x3120
leaq -0x258(%rbp), %rsi
movss 0x2c78(%rip), %xmm0     # 0xb258
movq %rbx, %rdi
callq 0x8f84
leaq -0x258(%rbp), %rdi
callq 0x3340
leaq 0x2c86(%rip), %rsi      # 0xb281
leaq -0x238(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x3120
leaq -0x50(%rbp), %rdi
leaq -0x238(%rbp), %rsi
callq 0x79ee
leaq 0x38(%r14), %rdi
leaq -0x50(%rbp), %rsi
callq 0x3180
leaq -0x50(%rbp), %rdi
callq 0x3340
leaq -0x238(%rbp), %rdi
callq 0x3340
jmp 0x887f
callq 0x4aac
movq %rax, %rbx
leaq 0x2c1a(%rip), %rsi      # 0xb26b
leaq -0x118(%rbp), %rdi
leaq -0x50(%rbp), %rdx
callq 0x3120
leaq -0x118(%rbp), %rsi
xorps %xmm0, %xmm0
movq %rbx, %rdi
callq 0x8f84
leaq -0x118(%rbp), %rdi
callq 0x3340
leaq 0x2c11(%rip), %rsi      # 0xb297
leaq -0xf8(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x3120
leaq -0x50(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x79ee
leaq 0x38(%r14), %rdi
leaq -0x50(%rbp), %rsi
callq 0x3180
leaq -0x50(%rbp), %rdi
callq 0x3340
leaq -0xf8(%rbp), %rdi
callq 0x3340
jmp 0x887f
movss %xmm0, -0x54(%rbp)
callq 0x4aac
movq %rax, %rbx
movss 0x2b62(%rip), %xmm0     # 0xb244
ucomiss -0x54(%rbp), %xmm0
jbe 0x87fc
leaq 0x2b78(%rip), %rsi      # 0xb26b
leaq -0x198(%rbp), %rdi
leaq -0x50(%rbp), %rdx
callq 0x3120
leaq -0x198(%rbp), %rsi
movss 0x2b3a(%rip), %xmm0     # 0xb24c
movq %rbx, %rdi
callq 0x8f84
leaq -0x198(%rbp), %rdi
callq 0x3340
leaq 0x2b48(%rip), %rsi      # 0xb275
leaq -0x178(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x3120
leaq -0x50(%rbp), %rdi
leaq -0x178(%rbp), %rsi
callq 0x79ee
leaq 0x38(%r14), %rdi
leaq -0x50(%rbp), %rsi
callq 0x3180
leaq -0x50(%rbp), %rdi
callq 0x3340
leaq -0x178(%rbp), %rdi
callq 0x3340
jmp 0x887f
leaq 0x2af0(%rip), %rsi      # 0xb26b
leaq -0x218(%rbp), %rdi
leaq -0x50(%rbp), %rdx
callq 0x3120
leaq -0x218(%rbp), %rsi
movss 0x2aba(%rip), %xmm0     # 0xb254
movq %rbx, %rdi
callq 0x8f84
leaq -0x218(%rbp), %rdi
callq 0x3340
leaq 0x2ad6(%rip), %rsi      # 0xb28b
leaq -0x1f8(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x3120
leaq -0x50(%rbp), %rdi
leaq -0x1f8(%rbp), %rsi
callq 0x79ee
leaq 0x38(%r14), %rdi
leaq -0x50(%rbp), %rsi
callq 0x3180
leaq -0x50(%rbp), %rdi
callq 0x3340
leaq -0x1f8(%rbp), %rdi
callq 0x3340
jmp 0x887f
leaq 0x2a68(%rip), %rsi      # 0xb26b
leaq -0x158(%rbp), %rdi
leaq -0x50(%rbp), %rdx
callq 0x3120
leaq -0x158(%rbp), %rsi
movss 0x2a26(%rip), %xmm0     # 0xb248
movq %rbx, %rdi
callq 0x8f84
leaq -0x158(%rbp), %rdi
callq 0x3340
leaq 0x2a4e(%rip), %rsi      # 0xb28b
leaq -0x138(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x3120
leaq -0x50(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x79ee
leaq 0x38(%r14), %rdi
leaq -0x50(%rbp), %rsi
callq 0x3180
leaq -0x50(%rbp), %rdi
callq 0x3340
leaq -0x138(%rbp), %rdi
callq 0x3340
xorl %r13d, %r13d
leaq -0x2b8(%rbp), %r12
movq 0x80(%r14), %rdi
callq 0x8c28
cmpq 0x8(%rax), %r13
jae 0x83a9
movl 0x18(%r14), %esi
movl 0x1c(%r14), %ebx
movq 0x80(%r14), %rdi
callq 0x7410
cmpl %eax, %ebx
jl 0x8989
movq 0x80(%r14), %rdi
movl 0x18(%r14), %esi
callq 0x7410
movl %eax, 0x1c(%r14)
movq 0x80(%r14), %r15
movl 0x18(%r14), %ebx
movq %r15, %rdi
movl %ebx, %esi
callq 0x7410
shlq $0x20, %rax
orq %rax, %rbx
movq %r15, %rdi
leaq -0x2d8(%rbp), %r15
movq %rbx, %rsi
pushq $0xa
popq %rdx
callq 0x7472
testb %al, %al
je 0x8989
callq 0x4aac
movq %r15, %rbx
movq %rax, %r15
movq %rbx, %rdi
leaq 0x2986(%rip), %rsi      # 0xb2a3
leaq -0x50(%rbp), %rdx
callq 0x3120
cvtsi2ssl 0x18(%r14), %xmm0
movq %r15, %rdi
movq %rbx, %rsi
callq 0x8f84
movq %rbx, %rdi
callq 0x3340
callq 0x4aac
movq %rax, %r15
movq %r12, %rbx
movq %r12, %rdi
leaq 0x2958(%rip), %rsi      # 0xb2ac
leaq -0x50(%rbp), %rdx
callq 0x3120
movq 0x80(%r14), %rdi
movl 0x18(%r14), %esi
callq 0x7410
cvtsi2ss %eax, %xmm0
movq %r15, %rdi
movq %rbx, %rsi
callq 0x8f84
movq %rbx, %rdi
callq 0x3340
movb $0x1, 0x30(%r14)
incq %r13
jmp 0x8889
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x3340
jmp 0x89dd
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x3340
jmp 0x8a07
movq %rax, %rbx
leaq -0x158(%rbp), %rdi
callq 0x3340
jmp 0x8bc1
movq %rax, %rbx
leaq -0x198(%rbp), %rdi
callq 0x3340
jmp 0x8bc1
jmp 0x8bbe
movq %rax, %rbx
leaq -0x138(%rbp), %rdi
callq 0x3340
jmp 0x8bc1
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x3340
jmp 0x8a88
jmp 0x8bbe
movq %rax, %rbx
leaq -0x178(%rbp), %rdi
callq 0x3340
jmp 0x8bc1
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x3340
jmp 0x8aaf
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x3340
jmp 0x8ac8
jmp 0x8bbe
movq %rax, %rbx
leaq -0x218(%rbp), %rdi
callq 0x3340
jmp 0x8bc1
jmp 0x8bbe
movq %rax, %rbx
leaq -0x258(%rbp), %rdi
callq 0x3340
jmp 0x8bc1
movq %rax, %rbx
leaq -0x1d8(%rbp), %rdi
callq 0x3340
jmp 0x8bc1
jmp 0x8bbe
movq %rax, %rbx
leaq -0x1f8(%rbp), %rdi
callq 0x3340
jmp 0x8bc1
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x3340
jmp 0x8b26
jmp 0x8bbe
movq %rax, %rbx
leaq -0x238(%rbp), %rdi
callq 0x3340
jmp 0x8bc1
jmp 0x8bbe
movq %rax, %rbx
leaq -0x1b8(%rbp), %rdi
callq 0x3340
jmp 0x8bc1
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x3340
jmp 0x8b3f
jmp 0x8bbe
movq %rax, %rbx
leaq -0x118(%rbp), %rdi
callq 0x3340
jmp 0x8bc1
jmp 0x8bbe
jmp 0x8bbe
movq %rax, %rbx
leaq -0x298(%rbp), %rdi
callq 0x3340
jmp 0x8bc1
jmp 0x8bbe
movq %rax, %rbx
leaq -0xf8(%rbp), %rdi
callq 0x3340
jmp 0x8bc1
jmp 0x8bbe
movq %rax, %rbx
leaq -0x278(%rbp), %rdi
callq 0x3340
jmp 0x8bc1
jmp 0x8bbe
jmp 0x8bbe
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
callq 0x3340
jmp 0x8bc1
movq %rax, %rbx
leaq -0x98(%rbp), %rdi
callq 0x3340
jmp 0x8bc1
movq %rax, %rbx
leaq -0x2d8(%rbp), %rdi
callq 0x3340
jmp 0x8bc1
jmp 0x8bbe
jmp 0x8bbe
jmp 0x8bbe
movq %rax, %rbx
leaq -0xb8(%rbp), %rdi
callq 0x3340
jmp 0x8bc1
jmp 0x8bbe
movq %rax, %rbx
leaq -0xd8(%rbp), %rdi
callq 0x3340
jmp 0x8bc1
movq %rax, %rbx
leaq -0x2b8(%rbp), %rdi
callq 0x3340
jmp 0x8bc1
jmp 0x8bbe
movq %rax, %rbx
movq %rbx, %rdi
callq 0x3450
movq %rax, %rdi
callq 0x3aae
nop