Netzwerk Beispiel

Previous topic - Next topic

Baggi

Hi,

ich habe ein kleines "Netzwerkspiel" für 2 Spieler programmiert. Es ist kein wirkliches Spiel (Pong ohne Ball ;)), es soll halt nur ein prinzipielles Beispiel sein.

Habe keine richtige Anleitung dazu, aber der Quelltext ist ein bischen kommentiert.

Funktioniert alles gut, außer das Erstellen für Linux, da bekomme ich einen haufen Fehler???

Download:
//www.iup.physik.uni-bremen.de/~mieruch/NetzwerkBeispiel.7z


Baggi

WPShadow

Super!

Das Beispiel muß ich mir unbedingt durch schauen!!!! =)
AMD X2 4600, 2 GB Ram, ATI X1950 XTX, XP PRO SP2: GLB Premium 10.beta_dingsi, <(´.´<) Kirby Dance (>`.`)>
http://lostrevenant.blogspot.com
alea iacta est

Moru

I'm sorry I don't know much german so I will answer in english :-)

Nice to see that network is actually working, I haven't gotten that far yet in testing :-)

I tried this running both client and server on the same computer. This will make the server lock up while you have the focus on the client window. If you add the command "AUTOPAUSE FALSE" in the beginning of the program it won't pause when it looses focus.

Also, when I connect a client I can move the clients square and it updates in realtime in the servers window, but if I move the servers square it takes 1-2 seconds for the client to react. Not sure why?

Baggi

Please download an English version:

//www.iup.physik.uni-bremen.de/~mieruch/NetworkExample.7z

Thanks for your comments. I've tried the AUTOPAUSE FALSE command and ran the game in two windows on one computer, but then I controlled both with the keyboard at the same time. So it was not possible to  run the one as host and the other as client. Or maybe I did not really get the command?

I tested the game with two computers and I also noticed that time delay between the server  square on the server window and client window.  I have no idea where the problem is.

trucidare

Das ist gut. Jedoch stell ich morgen ein sample online mit UDP verbindung die klappt ein bisschen besser. Vielleicht solltest du dein spiel dann noch ein wenig verbessern ok?
MacBook Pro 2,2 GHz Core 2 Duo, 4 GB RAM, 160 GB HDD, 8600M GT
Core i3 - 3,07 GHz, 8 GB Ram, 2.5 TB HDD, Geforce GTX 260+ OC

Baggi

UDP geht auch? Ich dachte es geht nur TCP.
Was wäre der Vorteil von UDP?

trucidare

an UDP sitzt der gernot gerade dran und ich helf ihm ein bisschen. der unterschied ist das die verbindung nicht zwangsläufig stehen muss. udp sendet den kram einfach ins universum und wenn jemand da ist der bekommt die dann. sehr gut für spiele. ich lege eine kleine demo bei die momentan leider nur lokal läuft. woran es genau liegt weiß ich noch nicht aber das bekomm ich auch noch raus oder gernot.
MacBook Pro 2,2 GHz Core 2 Duo, 4 GB RAM, 160 GB HDD, 8600M GT
Core i3 - 3,07 GHz, 8 GB Ram, 2.5 TB HDD, Geforce GTX 260+ OC

Kosta

Quote from: BaggiUDP geht auch? Ich dachte es geht nur TCP.
Was wäre der Vorteil von UDP?
UDP ist deutlich schneller, da weniger Overhead erzeugt wird.
(z.B. faellt am Anfang (Verbindungsaufbau) der Handshake weg (im Vergleich zu TCP)),
ausserdem müsen die Pakete nicht in einer bestimmten Reihenfolge ankommen und müssen auch nicht quittiert werden, d.h. UDP sendet einfach drauf los, über die Pakete die ankommen, darf man sich freuen, die die nicht ankommen (tja, Pech gehabt) (-> im Gegensatz zu TCP die sie dann erneut sendet, wenn die Quittierung nicht erfolgt ist)
Intel QuadCore, Geforce8600GT,512MB,4GB Ram, 26" TFT
HP nw8440 Schläppy
GP2X Mk2 (Firmware 3.0)

GLBASIC Blog:
http://www.glbasic.com/forum/index.php?blog=51.0

trucidare

Der Handshake erfolgt trotzdem in einer gewissen Form. Und zwar sobald ein Client akzeptiert wird.
MacBook Pro 2,2 GHz Core 2 Duo, 4 GB RAM, 160 GB HDD, 8600M GT
Core i3 - 3,07 GHz, 8 GB Ram, 2.5 TB HDD, Geforce GTX 260+ OC

Kitty Hello

Aber genial - Baggi hat das erste Netzwerkspiel gemacht!
Ja, UDP kommt bald. Dazu eben der komplette Netzwerk Socket Wrapper -> Damit hat man quasi unbegrenzten Zugriff auf alles im Netzwerk.

trucidare

vielleicht macht baggi ja eine UDP und TCP version. Damit man den unterschied von der bedienbarkeit mitbekommt
MacBook Pro 2,2 GHz Core 2 Duo, 4 GB RAM, 160 GB HDD, 8600M GT
Core i3 - 3,07 GHz, 8 GB Ram, 2.5 TB HDD, Geforce GTX 260+ OC

Baggi

Mach ich gerne, sobald ihr UDP implementiert habt und mir verratet wie's geht ;).

trucidare

hehe siehst du alles im sample ich lads gegen abend hoch muss noch was für die gui tun.
MacBook Pro 2,2 GHz Core 2 Duo, 4 GB RAM, 160 GB HDD, 8600M GT
Core i3 - 3,07 GHz, 8 GB Ram, 2.5 TB HDD, Geforce GTX 260+ OC

Baggi

Ich hab nochmal über TCP und UDP nachgedacht. Ich muss dazu sagen, dass ich davon echt Null Ahnung habe, aber ich denke beides ist gut und es hängt von der Anwendung ab, welches man benutzen sollte. Bei einem Actionspiel (z.B. Shooter) ist wahrscheinlich UDP besser, (weil schneller?). Wenn ich aber z.B. eine Art Würfelspiel habe, dann darf auf keinen Fall was verloren gehen und TCP wäre besser. Oder?

trucidare

sagen wir es mal so:
UDP für spiele
TCP für client server anwendungen bei denen eine verbindung expliziet stehen muss.

TCP ist z.b. im internet surfen, icq, irc, und sonstiges
MacBook Pro 2,2 GHz Core 2 Duo, 4 GB RAM, 160 GB HDD, 8600M GT
Core i3 - 3,07 GHz, 8 GB Ram, 2.5 TB HDD, Geforce GTX 260+ OC