Today we have added some of the content on the display to make our game easier to understand. For example, we added the display of the blood bar, and used the color zone to separate our characters, other people's characters and monsters. As shown in.
At the bottom of the screen is a purple purple thing is the experience bar, will be upgraded after full.
I'll explain the implementation of each module individually.
The first is the blood bar:
Own blood strips:
glcolor3f (0.210.10.0250.10.0250.05 0.085); // Show Blood Strips
Other players ' blood strips:
GLCOLOR3F (0.2,1,0.2);Charbuf[ -];sprintf (buf,"lv:%d", LV); GLRASTERPOS2F (WX-0.02, WY + Mapmax/40.0+0.05);d rawstring (BUF); sprintf (buf,"%.0LF/%.0LF", HP, MAXHP); GLRASTERPOS2F (WX-0.025, WY + Mapmax/40.0+0.01);d rawstring (BUF); GLRECTF (WX-0.025, WY +0.1, WX-0.025+ (HP/MAXHP) *0.05, WY +0.085);//Show Blood Strips
The middle is the level and the name of the display, is the previous.
Monster's Blood Bar:
GLCOLOR3F (1,0.2,0.2);Charbuf[ -];sprintf (buf,"%.0LF/%.0LF", HP, MAXHP); GLRASTERPOS2F (WX-0.025, WY + Mapmax/40.0+0.01);d rawstring (BUF); GLRECTF (WX-0.025, WY +0.1, WX-0.025+ (HP/MAXHP) *0.05, WY +0.085);//Show Blood Strips
The principle is to draw a rectangle that is related to the percentage of the amount of blood. Using OpenGL's GLRECTF () function is a good implementation.
The following is a more complex experience strip implementation:
/*below is the show Experience bar module*///calculates the x, Y value of the experience barDoublex, Y;x=Wx;y=WY;if(x<1) x=1;Else if(X>mapmax-1) x= Mapmax-1;if(Y <1) y=1;Else if(Y>mapmax-1) y= Mapmax-1;//Show Experience BoxGLCOLOR3F (0.8,0.8,0.8); Glbegin (Gl_polygon); glvertex2f (x-1, Y-0.982); glvertex2f (x+1, Y-0.982); glvertex2f (x+1, Y-1); glvertex2f (x-1, Y-1); Glend (); glcolor3f (0.6,0.2,1); GLRECTF (x-1, Y-0.985, X-1+ ((Double) Exp/(Double) maxexp) *2, Y-0.998);//Show Experience Bar/*show the XP strip module ends here.*/
The first paragraph calculates the perspective position of the experience bar. This is the most difficult, because our game is the user moves on a large map, the reason why the players see their own perspective rather than the entire map because of the use of OpenGL perspective conversion. What we're doing is putting slimes right in the middle of the screen. However, as the player approached the boundary of the map, it was normal to understand that the slime could not be kept in the middle, because a large black screen would appear. This needs to be judged whether it is near the border. Then the actual drawing of the experience of the process is very easy, just physical labor, 1.1 points to try out the best position, size and color. Finally, as shown in the first picture.
This is done today to prepare for the subsequent user interface.
The second chapter of software engineering iterative development