So i've been making a game with game maker but i have one problem:
This is at the start, the player is facing straight up. Notice the healthbar in the upper right corner.
I've moved the character now. Since its a planet game, the view rotates with the player. The healthbar rotates in the reverse direction though. That's not suppose to happen.
Since i'm using a custom circular healthbar script, this is not done easily, as i have basically no knowledge of trigonometry.
Here is the script (keep in mind that every point is on a coordinate grid):Hopefully the code is not too hard to interpret.Code:// ///////////////////////////////////////////// // DRAWS THE DESIRED HEALTHBAR // //-----------------------------------------// // When using this function use the form // // healthbar_draw( ID, x, y ); // // descriptions of each argument below. // ///////////////////////////////////////////// var ID, X, Y; ID = argument0; //ID of the healthbar to be drawn. X = argument1; //x position of healthbar Y = argument2; //y position of healthbar var x1, x2, x3, x4, y1, y2, y3, y4; var angle; //DRAW THE BACKGROUND if( global.back[ID] == 1 ) { angle = global.maxAngle[ID]; draw_set_color( global.colBack[ID] ); for( i=0; i<global.numt[ID]; i+=1 ) { x1 = X+cos( degtorad( (global.bottomAngle[ID]-angle)+(angle/global.numt[ID]*i) ) )*( global.outerRadius[ID]+1 ); y1 = Y-sin( degtorad( (global.bottomAngle[ID]-angle)+(angle/global.numt[ID]*i) ) )*( global.outerRadius[ID]+1 )*global.eccen[ID]; x2 = X+cos( degtorad( (global.bottomAngle[ID]-angle)+(angle/global.numt[ID]*(i+1)) ) )*( global.outerRadius[ID]+1 ); y2 = Y-sin( degtorad( (global.bottomAngle[ID]-angle)+(angle/global.numt[ID]*(i+1)) ) )*( global.outerRadius[ID]+1 )*global.eccen[ID]; x3 = X+cos( degtorad( (global.bottomAngle[ID]-angle)+(angle/global.numt[ID]*i) ) )*( global.innerRadius[ID]-1 ); y3 = Y-sin( degtorad( (global.bottomAngle[ID]-angle)+(angle/global.numt[ID]*i) ) )*( global.innerRadius[ID]-1 )*global.eccen[ID]; x4 = X+cos( degtorad( (global.bottomAngle[ID]-angle)+(angle/global.numt[ID]*(i+1)) ) )*( global.innerRadius[ID]-1 ); y4 = Y-sin( degtorad( (global.bottomAngle[ID]-angle)+(angle/global.numt[ID]*(i+1)) ) )*( global.innerRadius[ID]-1 )*global.eccen[ID]; draw_triangle( x1, y1, x2, y2, x3, y3, 0 ); draw_triangle( x2, y2, x3, y3, x4, y4, 0 ); } } //DRAW THE FILLED BAR angle = global.maxAngle[ID]*global.percent[ID]/100; draw_set_color( merge_color( global.colLow[ID], global.colHigh[ID], global.percent[ID]/100 ) ); for( i=0; i<global.numt[ID]; i+=1 ) { x1 = X+cos( degtorad( (global.bottomAngle[ID]-angle)+(angle/global.numt[ID]*i) ) )*global.outerRadius[ID]; y1 = Y-sin( degtorad( (global.bottomAngle[ID]-angle)+(angle/global.numt[ID]*i) ) )*global.outerRadius[ID]*global.eccen[ID]; x2 = X+cos( degtorad( (global.bottomAngle[ID]-angle)+(angle/global.numt[ID]*(i+1)) ) )*global.outerRadius[ID]; y2 = Y-sin( degtorad( (global.bottomAngle[ID]-angle)+(angle/global.numt[ID]*(i+1)) ) )*global.outerRadius[ID]*global.eccen[ID]; x3 = X+cos( degtorad( (global.bottomAngle[ID]-angle)+(angle/global.numt[ID]*i) ) )*global.innerRadius[ID]; y3 = Y-sin( degtorad( (global.bottomAngle[ID]-angle)+(angle/global.numt[ID]*i) ) )*global.innerRadius[ID]*global.eccen[ID]; x4 = X+cos( degtorad( (global.bottomAngle[ID]-angle)+(angle/global.numt[ID]*(i+1)) ) )*global.innerRadius[ID]; y4 = Y-sin( degtorad( (global.bottomAngle[ID]-angle)+(angle/global.numt[ID]*(i+1)) ) )*global.innerRadius[ID]*global.eccen[ID]; draw_triangle( x1, y1, x2, y2, x3, y3, 0 ); draw_triangle( x2, y2, x3, y3, x4, y4, 0 ); }
Thanks!
//global.back[ID] = argument5;
//global.colBack[ID] = c_dkgray;


LinkBack URL
About LinkBacks

