Ein Online-Pointing-System

Übersicht BlitzBasic Codearchiv

Neue Antwort erstellen

BtbN

Betreff: Ein Online-Pointing-System

BeitragSo, Jun 26, 2005 16:03
Antworten mit Zitat
Benutzer-Profile anzeigen
Durch dieses Script ist es möglich, über das Internet auf einem Bild einen Punkt zu zeigen. Is ne kleine Spielerei von mir(jaaaaaa, dafür brauche ich auch die Pack 2 Varis in eine Funktion ^^)

BlitzBasic: [AUSKLAPPEN]
Function twoinone(var1,var2)

var1 = var1 * 65536
da = var1 + var2
Return(da)

End Function


Function twofromone(var,what)

var2 = var And 65535
var1 = (var-var2)/65536
If what = 1 Then
Return var1
Else
Return var2
EndIf

End Function


file = ReadFile(\"sys.conf\")
ReadLine(file)
gix = ReadLine(file)
ReadLine(file)
giy = ReadLine(file)
ReadLine(file)
apptit$ = ReadLine(file)
ReadLine(file)
bildname$ = ReadLine(file)
ReadLine(file)
soundname$ = ReadFile(file)
CloseFile(file)

AppTitle(apptit$)
Graphics gix,giy,32,2

varr$ = Input(\"Gegen sie 1 ein um zu hosten, zum Joinen etwas anderes: \")

If varr$ = 1 Then
game = HostNetGame(\"game\")
Else
varr$ = Input(\"IP: \")
game = JoinNetGame(\"game\",varr$)
EndIf

If Not game Then
Print \"Error!\"
Print \"Die Sitzung wird beendet...\"
Delay(5000)
End
EndIf

Global spieler = CreateNetPlayer(\"player\")


bild = LoadImage(bildname$)
If soundname$ <> \"x\" Then
sound = LoadSound(soundname$)
EndIf

SetBuffer BackBuffer()

Repeat

Cls

DrawBlock(bild,0,0)

If Not aktiv Then
x = MouseX()
y = MouseY()
If MouseHit(1) Then
hit = 1
aktiv = 1
timer = MilliSecs()
packet = twoinone(x,y)
SendNetMsg(1,packet,spieler)
ElseIf MouseHit(2) Then
hit = 2
aktiv = 1
timer = MilliSecs()
packet = twoinone(x,y)
SendNetMsg(2,packet,spieler)
EndIf
Else
If timer + 3000 >= MilliSecs() Then
If hit = 1 Then
Color(255,255,255)
Else
Color(0,0,0)
EndIf
Rect(x-6,y,13,1)
Rect(x,y-6,1,13)
Else
aktiv = 0
FlushMouse
EndIf
EndIf


If Not aktivr Then
If RecvNetMsg() Then
typer = NetMsgType()
If typer <= 99 Then
msg = NetMsgData()
xr = twofromone(msg,1)
yr = twofromone(msg,2)
timerr = MilliSecs()
aktivr = 1
If soundname$ <> \"x\" Then
PlaySound(sound)
EndIf
EndIf
EndIf
Else
If timerr + 3000 >= MilliSecs() Then
If typer = 1 Then
Color(255,255,255)
Else
Color(0,0,0)
EndIf
Rect(xr-6,yr,13,1)
Rect(xr,yr-6,1,13)
Else
aktivr = 0
EndIf
EndIf

Flip
Until KeyHit(1)

End


Dazu braucht man noch die Datei sys.conf .
Dies ist eine normale Textdatei, die man mit dem Editor bearbeiten kann.
Hier ein Bespiel:

Code: [AUSKLAPPEN]
;x-groesse des Bildes:
200
;y-groesse des Bildes:
250
;Titel des Programms
Ich bin ein Programm
;Dateiname des Bildes:
bild.jpg
;Dateiname das "neue Nachricht" Sounds( x wenn kein Sound):
x


Und dann braucht man natürlich noch ein belibiges Bild ^^
Ürigens: Die Kommentarzeilen in der sys.conf sollten da bleiben!
Denn wenn man sie weg macht, ließt das Programm die Datei falsch aus.


BORNtobeNAMELESS

Neue Antwort erstellen


Übersicht BlitzBasic Codearchiv

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group