Logika potworów w grze
Ostatnio zmodyfikowano 2024-09-04 22:05
tBane Temat założony przez niniejszego użytkownika |
» 2024-05-24 00:43:00 Chodzi mi raczej o to, skąd wiedzieć ile i jakie if'y napisać. |
|
tBane Temat założony przez niniejszego użytkownika |
» 2024-06-02 18:07:19 void idle( float dt ) { calculateCurrentFrame( dt ); sprite.setTexture( * idleTextures[ direction * 4 + frame ]->texture ); }
void walk( float dt ) { calculateCurrentFrame( dt ); sprite.setTexture( * walkTextures[ direction * 4 + frame ]->texture ); }
void attack( float dt ) { if( cooldown <= 0.0f ) { player->takeDamage( 10 ); cooldown = attackTime; frame = 0; } else frame =( attackTime - cooldown ) / attackTime * 4.0f; if( frame < 0 ) frame = 0; if( frame >= 4 ) frame = 3; sprite.setTexture( * attackTextures[ direction * 4 + frame ]->texture ); }
virtual void update( float dt ) { mouseOvering(); if( playerInActionRange() ) { state = states::attack; } else { state = states::idle; } if( state == states::idle ) idle( dt ); else if( state == states::walk ) walk( dt ); else if( state == states::attack ) attack( dt ); if( cooldown > 0.0f ) cooldown -= dt; sprite.setPosition( position ); collider.setPosition( position ); viewRangeArea.setPosition( position ); actionRangeArea.setPosition( position ); setPanelHP(); textname.setPosition( position.x, position.y - height - 30 ); }
|
|
tBane Temat założony przez niniejszego użytkownika |
» 2024-09-04 22:05:59 |
|
1 2 « 3 » |