Raised This Month: $ Target: $400
 0% 

Sprite math [advanced users]


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 11-07-2011 , 16:03   Re: Sprite math [advanced users]
Reply With Quote #6

That code looks horrible.
This is how you do rotation:
PHP Code:
#include <amxmodx>

new Float:g_rotation_matrix[2][2]
new 
Float:g_vec[3] = {70.00.00.0}


public 
plugin_init() {
    
rotation_init(10.0)
    
set_task(0.1"rotate"4373__"b")
}


public 
rotation_init(Float:degrees_step){
    
g_rotation_matrix[0][0] = g_rotation_matrix[1][1] = floatcos(degrees_stepdegrees
    
g_rotation_matrix[1][0] = -(g_rotation_matrix[0][1] = -floatsin(degrees_stepdegrees))
}


public 
rotate(){
    new 
Float:xFloat:y
    x 
g_vec[0]*g_rotation_matrix[0][0] + g_vec[1]*g_rotation_matrix[0][1]
    
g_vec[0]*g_rotation_matrix[1][0] + g_vec[1]*g_rotation_matrix[1][1]
    
    
display()
    
    
g_vec[0] = x
    g_vec
[1] = y
}


public 
display(){
    static 
players[32], pnumorigin[3]
    
get_players(playerspnum)
    for(new 
ii<pnumi++){
        
get_user_origin(players[i], origin)
        
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
        
write_byte(TE_SPARKS)
        
write_coordfloatround(g_vec[0] + origin[0]) )
        
write_coordfloatround(g_vec[1] + origin[1]) )
        
write_coordfloatround(g_vec[2] + origin[2]) )
        
message_end()
    }

__________________
Impossible is Nothing
Sylwester is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:46.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode