November 29, 2020, 05:06:54 PM

Author Topic: Scoring system  (Read 1061 times)

Offline Yue

  • Hero Member
  • *****
  • Posts: 579
    • YiHosting Your Hosting Free
Scoring system
« on: January 24, 2018, 04:51:14 PM »

Any ideas on how to create a scoring system, when the player crosses the last checkpoint, and the five scores are shown on screen in consecutive order of the best time at the worst time?

Code: [Select]
; ---------------------------------------------
; Proyecto : TestPace X.
; Programador : Yue Rexie.
; Sitio Web : http://www.iris3dgames.ga
; fichero : TPuntos.bb
; ---------------------------------------------
; Nota : Tipo TPuntos
;    Objeto Puntos.
; ---------------------------------------------

Local tablero.TPuntos = Null


Type TPuntos



Field puntos$[5]



End Type



Function Init_Puntos.TPuntos()

Local puntos.TPuntos = New TPuntos





Return ( puntos.TPuntos )

End Function


Function DrawPuntos( self.TPuntos )



DrawRoundRect (GraphicsWidth()/2-200,GraphicsHeight()/2-150, 400,300, 29 , 5, ARGB(0.7 ,0,0,0))




For x  = 1 To 5
self\puntos[x] = reloj$
DrawText(self\puntos[x], 250, 200)
Next




End Function


Offline RemiD

  • Hero Member
  • *****
  • Posts: 1077
Re: Scoring system
« Reply #1 on: January 24, 2018, 08:03:23 PM »
Do you want to have the scores on the same screen (render) ? 1st at the top, below it the 2nd, below it the 3rd, like this :
Code: [Select]
|1st DriverName 00m00s|
|2nd DriverName 00m00s|
|3rd DriverName 00m00s|
if yes, you could use images that your program remake (following a procedure which considers the drivername, his position at the end of the race, his time)
then draw one image below another. (use the pixels height to know where to draw)
example :
Code: [Select]
Graphics(640,480,32,2)

Global TitleStatsImage

Dim DriverStatsImage(10)

;before the race :

;create the TitleStats image
TitleStatsImage = CreateImage(500,1+16+1) ;assuming we use a font with a height of 16

;create each DriverStats image
For I% = 1 To 10 Step 1
 DriverStatsImage(I) = CreateImage(500,1+16+1)
Next

;after the race :

;remake the TitleStats image :
SetBuffer(ImageBuffer(TitleStatsImage))
Color(125,125,125) : Rect(0,0,500,1+16+1,True)
TStr$ = "Drivers stats for this race : " : PX% = 500/2-StringWidth(TStr)/2 : PY% = 1
Color(255,255,255) : CText(TStr,PX,PY)

;remake each DriverStats image :
For I% = 1 To 10 Step 1
 SetBuffer(ImageBuffer(DriverStatsImage(I)))
 ClsColor(Rand(025,125),Rand(025,125),Rand(025,125)) : Cls()
 TStr$ = Str(00)+" "+"XName"+" "+"00m00s" : PX% = ImageWidth(DriverStatsImage(I))/2-StringWidth(TStr)/2 : PY% = 1
 Color(255,255,255) : CText(TStr,PX,PY)
Next

SetBuffer(BackBuffer())

;draw the TitleStats image
DrawImage(TitleStatsImage,GraphicsWidth()/2-ImageWidth(TitleStatsImage)/2,3)
;draw each DriverStats image, one below the other
For I% = 1 To 10 Step 1
 DrawImage(DriverStatsImage(I), GraphicsWidth()/2-ImageWidth(DriverStatsImage(I))/2, 3+1+16+1+3+((I-1)*(3+1+16+1)) )
Next

Flip()

WaitKey()

End()

Function CText(XStr$,PX%,PY%)
 
 Text(PX,PY,XStr,False,False)

End Function
Of course you can improve the drawing of images procedure until it is centered horizontaly and verticaly... And you can order the drawing by position or by time... It depends on what you want... try it, tweak it !

(this code example uses dim arrays, but you can use a custom type...)
DualCore AMD E-450, 1646 MHz - 6 Go DDR3 1333 SDRAM - AMD Radeon HD 6320 Graphics (384 Mo) - Windows 7 Home Premium - DirectX 11.0

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal