Warum soviel Prozessorauslastung?

Übersicht BlitzMax, BlitzMax NG Allgemein

Neue Antwort erstellen

DaysShadow

Betreff: Warum soviel Prozessorauslastung?

BeitragDi, Jun 23, 2009 5:52
Antworten mit Zitat
Benutzer-Profile anzeigen
Hi,

ich habe mir folgenden Code geschrieben und wundere mich über die Auslastung bei mir( 7-9%, schwankend, ohne Timer, mit Timer(auf 60 Ticks) sogar noch mehr)

BlitzMax: [AUSKLAPPEN]
SuperStrict 

Type TTextButton

Field font:TImageFont
Const idle:Int = 0 , mouseover:Int = 1


Field text:String , x:Float , y:Float , state:Int
Field tcolactive:Int[4], tcolinactive:Int[4]
Field MouseClick:Int()

Method setFont:Int(_Font:TImageFont)

font = _Font

EndMethod

Method getFont:TImageFont()

Return font

EndMethod

Method setMouseClickFunction:Int(MouseClickFunction:Int() )

MouseClick = MouseClickFunction

EndMethod

Method setColors(a_active:Int, r_active:Int, g_active:Int, b_active:Int, a_inactive:Int, r_inactive:Int, g_inactive:Int, b_inactive:Int)

tcolactive[0] = a_active
tcolactive[1] = r_active
tcolactive[2] = g_active
tcolactive[3] = b_active

tcolinactive[0] = a_inactive
tcolinactive[1] = r_inactive
tcolinactive[2] = g_inactive
tcolinactive[3] = b_inactive

EndMethod

Method CheckMouseOver:Int()

If MouseX() > x And MouseX() < x + TextWidth(text) And MouseY() > y And MouseY() < y + TextHeight(text)

Return True

Else

Return False

EndIf

EndMethod

Method Update()

If GetImageFont() <> font SetImageFont(font)

Select state

Case idle

If CheckMouseOver() state = mouseover

SetAlpha tcolinactive[0]
SetColor tcolinactive[1], tcolinactive[2], tcolinactive[3]

DrawText text, x, y

Case mouseover

If Not CheckMouseOver() state = idle

If MouseHit(MOUSE_LEFT) MouseClick()

SetAlpha tcolactive[0]
SetColor tcolactive[1], tcolactive[2], tcolactive[3]

DrawText text, x, y

EndSelect

SetAlpha 1
SetColor 255, 255, 255

EndMethod

Function Create:TTextButton(text:String, x:Float, y:Float)

Local ttb:TTextButton = New TTextButton

ttb.text = text
ttb.state = TTextButton.idle
ttb.x = x
ttb.y = y

Return ttb

EndFunction

EndType

Graphics 800, 600, 0, 60

SetBlend ALPHABLEND

Function TTextButton_Function1:Int()

SetClsColor Rand(0, 255), Rand(0, 255), Rand(0, 255)

EndFunction

Global TextButton:TTextButton = TTextButton.Create("Ändere die Hintergrundfarbe :)", 50, 100)

TextButton.setFont(LoadImageFont(getenv_("WINDIR") + "\Fonts\Tahoma.ttf", 24) )

TextButton.setColors(1, 255, 255, 255, 1, 150, 150, 150)

TextButton.setMouseClickFunction(TTextButton_Function1)

Repeat

Cls

TextButton.Update()

Flip

Until KeyHit(KEY_ESCAPE) Or AppTerminate()


Vielleicht mag ja mal jemand durchgehen und mir erklären warum das soviel Prozessorauslastung verursacht, an sich ist das doch keine komplexe Sache sodass es gerechtfertigt wäre?

Kleiner Nachtrag: Selber Code läuft jetzt mit 0-3% Prozessorleistung, wie kann denn so etwas sein? Mein Rechner und dementsprechend Windows wurde einfach nur heruntergefahren und dann später wieder angeschaltet.

Danke
MfG DaysShadow
Blessed is the mind too small for doubt
  • Zuletzt bearbeitet von DaysShadow am Di, Jun 23, 2009 18:52, insgesamt einmal bearbeitet

Lastmayday

BeitragDi, Jun 23, 2009 10:55
Antworten mit Zitat
Benutzer-Profile anzeigen
wooops hab was überlessen sry Sad

Neue Antwort erstellen


Übersicht BlitzMax, BlitzMax NG Allgemein

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group