版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、<p><b> 外 文 翻 譯</b></p><p> 原文1:Flying Buddha Memory Game</p><p> 譯文1:飛行佛存儲(chǔ)游戲</p><p> 原文2:Blender Basic Network setup - Boil it down to the basics</p>&l
2、t;p> 譯文2:Blender基本網(wǎng)絡(luò)設(shè)置,將其概括為基礎(chǔ)</p><p> Flying Buddha Memory Game</p><p> "Flying Buddha" is a game designed by Freid Lachnowicz (artwork, models, textures) and me (Carsten Wartma
3、nn, Python and game logic). The goal of the game is to find pairs of gongs, like in the good old "Memory" game. </p><p> Besides that, it also includes some action elements, like the dragonfly whi
4、ch will become angry (note the indicator on the top-right) if you jump too high. Also it requires some good timing for the controls of the Buddha. The Buddha's goal, reaching "Zen" is completed when he has
5、found all pairs. For competitions the time needed to solve will be displayed on screen. </p><p> Load the game Games/FlyingBuddha.blend from the DVD and have fun playing it! </p><p> Accessing
6、 game objects </p><p> Accessing individual objects from Blenders game engine is not trivial. In the "Flying Buddha" game, I needed a possibility of randomly shuffling the gongs at game start. <
7、;/p><p> Generally speaking, it is a good thing to have as much game logic as possible contained on the object that needs that logic. This helps when re-using this object in the same or even different (Blender
8、) scenes. So my first idea was to let the gongs choose a new position themselves. But this soon turned out to be too complicated, because of synchronizing problems and complex logic in the gongs. </p><p> I
9、 then decided to use an object to control the shuffling process, and have the information about the other objects including their positions is gathered by a Near Sensor. This approach has many advantages. For example we
10、can filter out whole groups of objects with the "Property:" field, we are not bound to a fixed number of objects etc. </p><p> LogicBricks </p><p> Load the file Tutorials/FlyingBudd
11、ha/FlyingBuddha_simple.blend from the DVD. It contains a simpler version of the "Flying Buddha" game, which does not contain all the intro scenes but is fully functional (press CTRL-LEFT for a full screen view)
12、. Use this file to explore the Game Logic. </p><p> The difference in the full game and this tutorial file are build-in debugging and testing logic. Most notably is that you can test the re-shuffling of the
13、 gongs every time by pressing SPACE. The logic for this is on the "Flamethrower" object (on layer 4). </p><p> Have a look at Figure [fb-lbs] the interesting parts in this context are the Sensors
14、"mixitbaby" and "near". Both are connected to a Python Controller, which is then connected to a Message Actuator. Also note the "shuffle" Property, this controls the number of swapped pairs.
15、 The other Bricks are not related to the shuffling, they are needed for other game parts. </p><p> Figure [fb-lbs]. LogicBricks for shuffling the gongs</p><p> As you can see, the Near Sensor
16、only looks for objects carrying a Property with the name "num". Also make sure that the "Dist:" setting is high enough for the Near Sensor to cover all objects. </p><p> The Python Contr
17、oller will be called every frame by the Property Sensor as long the Property "num" is in the range from 1 to 1000. </p><p> Shuffle Python script </p><p> Open a Text Window (SHIFT-F
18、11) and choose the script "Shuffle.py" with the Menu Button. </p><p> # Shuffle script, swaps positions of two gongs</p><p> import GameLogic</p><p> def ranint(min,max
19、):</p><p> return(int(GameLogic.getRandomFloat()*(max+1-min)+min))</p><p> contr = GameLogic.getCurrentController()</p><p> owner = contr.getOwner()</p><p> key
20、= contr.getSensor("mixitbaby")</p><p> near = contr.getSensor("near")</p><p> mess = contr.getActuator("shuffled")</p><p> # collects all gongs<
21、;/p><p> objs=near.getHitObjectList()</p><p> if key.isTriggered() and len(objs)==20:</p><p> owner.shuffle = owner.shuffle - 1</p><p> if owner.shuffle<0:</
22、p><p> GameLogic.addActiveActuator(mess,1)</p><p><b> else:</b></p><p> g1 = ranint(0,19)</p><p> g2 = ranint(0,19)</p><p> pos1 = objs[g1].g
23、etPosition()</p><p> pos2 = objs[g2].getPosition()</p><p> objs[g1].setPosition(pos2)</p><p> objs[g2].setPosition(pos1)</p><p> Listing [fb-py]. Script to shuffle
24、the gongs</p><p> So lets have a look into the script. The lines 1 to 12 contain the usual initialization, and getting information about the Controller, Sensors, Actuators and the owner which is needed to a
25、ccess Properties. The definition of a new function in line 5 is used to make a random function which returns an integer number in a specified range. This will save us much typing later. </p><p> In line 15
26、the first important step is done, using the method getHitObjectList() of the "near" object, we collect all game objects within the Near Sensors range into the list "objs". </p><p> Line
27、17 tests if the Property Sensor ("key") is triggered and if all objects (the gongs) are collected in the "objs" list. This is necessary to avoid Python script errors due to uninitialized objects. <
28、/p><p> In line 18 we decrement the Property "shuffle" by one to keep track how many swaps we already did. </p><p> The if-block beginning in line 19 executes the Message Sensor connect
29、ed to the Python Controller if the Property "shuffle" is less then zero, the message can then be used to start the game. </p><p> The else-block is executed when "owner.shuffle" is bigge
30、r than zero. This means that gongs need to be swapped. </p><p> In lines 22-23 we get two random numbers into the variables "g1" and "g2". The numbers will be in a range from 0 to 19 bec
31、ause we have 4x5=20 gongs. "g1" and "g2" are the indices of the gongs we want to swap in the next lines. Note that lists in python start with the element "0". </p><p> In the l
32、ines 25-26 the script reads the positions of the gong-objects using the random indices. The method used here is getPosition(). You can insert a print pos1,pos2 statement after line 26 to actually see the gong positions w
33、hile running the game. </p><p> Python is an auto documenting language. Use a print dir(object) statement to find out what methods an object provides. </p><p> The final two lines then swap th
34、e positions of the two gongs. The first object indexed as objs[g1] is set to "pos2" which is the position of the first gong. Same for the other gong. You can see the shuffling process in the game itself by look
35、ing at the gongs from the backside. </p><p> In this tutorial I showed you how to use Python in the game engine to access and change objects in a scene. We used this approach to keep the game logic local on
36、 the objects. If you are used to non object-oriented programming languages or systems, this may appear strange to you at first. But this approach has many advantages. For example, you don't need to change the logic w
37、hile editing your scenes or adding objects, the script will even work when adding objects while running the game. Also, re-</p><p><b> 飛行佛存儲(chǔ)游戲</b></p><p> “飛行佛”是Freid Lachnowicz和我設(shè)
38、計(jì)的一個(gè)游戲Freid Lachnowic 負(fù)責(zé)(藝術(shù)品、模型、紋理)而我負(fù)責(zé)(Carsten Wartmann,Python腳本和游戲邏輯)。這款游戲的目標(biāo)是找到雙鑼,就像在過去的美好的存儲(chǔ)游戲。</p><p> 除此之外,它還包括一些動(dòng)作元素,例如,如果你跳太高了,蜻蜓將變得憤怒(注意指示器右上角)。還需要注意控制佛陀的時(shí)機(jī)。佛陀的目標(biāo),是發(fā)現(xiàn)所有對(duì)“禪”。對(duì)于完成比賽所需的時(shí)間將顯示在屏幕上。</
39、p><p><b> 訪問游戲?qū)ο?lt;/b></p><p> 從Blender游戲引擎中訪問單個(gè)對(duì)象是很重要的。 在“飛行佛”的游戲里,在游戲開始時(shí),我需要一個(gè)隨機(jī)打亂的鑼鼓。</p><p> 一般來說,這是一件好事,游戲邏輯上盡可能地包含需要這種邏輯的對(duì)象。這有助于當(dāng)重用這個(gè)對(duì)象在相同的或甚至不同(Blender)的場(chǎng)景。所以我第一個(gè)想法
40、是讓鑼選擇一個(gè)新的位置。但這很快被證明過于復(fù)雜,因?yàn)橥絾栴}和復(fù)雜的邏輯。</p><p> 然后我決定使用一個(gè)對(duì)象來控制隨機(jī)的過程,并包含其他對(duì)象的信息,包括他們的位置是聚集在附近的傳感器。這種方法有許多優(yōu)點(diǎn)。例如我們可以過濾掉整個(gè)對(duì)象組與“屬性:”字段,我們不是綁定到一個(gè)固定的對(duì)象數(shù)量等。</p><p><b> 邏輯塊</b></p><
41、;p> 從DVD里加載文件 Tutorials/FlyingBuddha/FlyingBuddha_simple.blend。它包含一個(gè)簡(jiǎn)單版本的“飛行佛”的游戲,它不包含所有介紹的場(chǎng)景,但功能齊全(按CTRL-LEFT進(jìn)入全屏視圖)。使用這個(gè)文件來探索游戲邏輯。</p><p> 完整的游戲和本教程文件的區(qū)別是內(nèi)置的調(diào)試和測(cè)試邏輯。最明顯的是,您可以按SPACE測(cè)試變換鑼的空間位置。這個(gè)邏輯是在“Fl
42、amethrower”對(duì)象(第4層)。</p><p> 看一看圖[fb-lbs]有趣的部分是傳感器”mixitbaby”和“near”。兩者都是連接到一個(gè)Python控制器,然后連接到一個(gè)消息執(zhí)行機(jī)構(gòu)。還請(qǐng)注意“重置”屬性,它控制對(duì)數(shù)量的交換。其他和洗牌不相關(guān)的塊,是游戲的其他部分所需要的。</p><p> 正如您可以看到的, Near傳感器只尋找攜帶一個(gè)屬性名稱“num”的對(duì)象。
43、同時(shí)確保" Dist:“設(shè)置足夠高的值以保證Near傳感器覆蓋所有對(duì)象。</p><p> 當(dāng)屬性傳感器的"num"值為1到1000時(shí),Python控制器的每一幀都會(huì)被調(diào)用。</p><p> 圖[fb-lbs] 重置鑼鼓的邏輯塊</p><p> 重置的Python腳本</p><p> 打開一個(gè)文本窗
44、口(SHIFT-F11)然后選擇菜單按鈕里的腳本"Shuffle.py"。</p><p> # Shuffle script, swaps positions of two gongs</p><p> import GameLogic</p><p> def ranint(min,max):</p><p>
45、 return(int(GameLogic.getRandomFloat()*(max+1-min)+min))</p><p> contr = GameLogic.getCurrentController()</p><p> owner = contr.getOwner()</p><p> key = contr.getSensor("
46、mixitbaby")</p><p> near = contr.getSensor("near")</p><p> mess = contr.getActuator("shuffled")</p><p> # collects all gongs</p><p> objs
47、=near.getHitObjectList()</p><p> if key.isTriggered() and len(objs)==20:</p><p> owner.shuffle = owner.shuffle - 1</p><p> if owner.shuffle<0:</p><p> GameLo
48、gic.addActiveActuator(mess,1)</p><p><b> else:</b></p><p> g1 = ranint(0,19)</p><p> g2 = ranint(0,19)</p><p> pos1 = objs[g1].getPosition()</p>
49、<p> pos2 = objs[g2].getPosition()</p><p> objs[g1].setPosition(pos2)</p><p> 清單[fb-py] 重置鑼鼓的腳本</p><p> 所以讓我們看看腳本。行1到12包含通常的初始化和獲取信息的控制器、傳感器、執(zhí)行器和使用者需要用它來訪問屬性。一個(gè)新函數(shù)的定義在第5行是用
50、來制造一個(gè)隨機(jī)函數(shù),該函數(shù)返回一個(gè)在指定范圍內(nèi)的整數(shù)。這將為我們之后節(jié)省大量的輸入。</p><p> 在第15行第一個(gè)重要步驟完成之后,使用“near”對(duì)象的方法getHitObjectList(),我們收集在Near傳感器范圍內(nèi)的所有游戲物體到列表”objs”。</p><p> 第17行測(cè)試如果屬性傳感器(“key”)被觸發(fā),如果所有對(duì)象(鑼)收集在“objs”列表。這是必要的,
51、以避免Python腳本由于未初始化的對(duì)象而產(chǎn)生錯(cuò)誤。</p><p> 在第18行我們用一個(gè)跟蹤我們已經(jīng)參與了多少互換的變量來遞減屬性“shuffle”。</p><p> 這個(gè)if塊開始在第19行執(zhí)行消息傳感器連接到Python控制器如果屬性“shuffle”是少于零,消息可以用來啟動(dòng)游戲。</p><p> 當(dāng)"owner.shuffle&quo
52、t;大于零時(shí),else塊被執(zhí)行。這意味著鑼需要交換。</p><p> 在22行到23行我們有 “g1”和“g2”兩個(gè)隨機(jī)變量。這些數(shù)字的取值將在0到19的范圍內(nèi),因?yàn)槲覀冇? x5 = 20鑼?!癵1”和“g2”是我們想在下一行交換的鑼的指數(shù)。注意,列表在python中開始元素“0”。</p><p> 在25 – 26行,該腳本讀取鑼位置使用隨機(jī)指標(biāo)。此處使用的方法是getPosi
53、tion()。你可以插入一個(gè)打印pos1,pos2語(yǔ)句之后,第26行實(shí)際上運(yùn)行游戲時(shí)能看到鑼的位置。</p><p> Python是一種自動(dòng)記錄語(yǔ)言。使用一個(gè)打印dir(對(duì)象)語(yǔ)句來找出一個(gè)對(duì)象提供了方法。</p><p> 最后的兩行是交換兩個(gè)鑼的位置。第一個(gè)對(duì)象索引作為objs[g1]設(shè)置為“pos2”位置的第一個(gè)鑼。對(duì)于其他鑼也一樣。從鑼鼓的后面你可以看到重置的過程。</
54、p><p> 在本教程中,我向您展示了如何使用Python的游戲引擎在一個(gè)場(chǎng)景中訪問和更改對(duì)象。我們使用這種方法來使游戲邏輯作用在本地對(duì)象上。如果你是用于非面向?qū)ο蟮木幊陶Z(yǔ)言或系統(tǒng),對(duì)你來說一開始這可能顯得很奇怪。但是這種方法有許多優(yōu)點(diǎn)。例如,您不需要更改邏輯而編輯你的場(chǎng)景或添加對(duì)象,甚至在游戲運(yùn)行時(shí)該腳本也能正常工作添加對(duì)象。同時(shí),該邏輯重用在其他場(chǎng)景也容易得多。</p><p> Bl
55、ender Basic Network setup - Boil it down to the basics</p><p> by “Old Jim” Coulter</p><p> Making games and playing them is a lot of fun, but it is even more fun if you can make games to play
56、together with your friends. I will show you how to “cook” a basic network setup in blender. SinceBlenders game engine has no build in network support we have to do it in Python, for this you need a matching Python inst
57、allation for Blender. Take a close look at the terminal or dos-box output whenBlender starts, it will tell you which version it needs and if the import worked. </p><p> Ingredients </p><p> I
58、P: Unique Computer name</p><p> LAN IP: Only accessible inside the local network</p><p> Internet IP: Accessible form all over the world (when routers and firewalls allows it)</p><p
59、> Port: Access line to a specific communication</p><p> Socket: Transmitting and receiving station.</p><p> Libraries: Importing cookbooks (modules) from the Python Library gives blender i
60、nfo on how toprepare a special meal</p><p> Logic Bricks: central switching station of the Blender game engine.</p><p> Objects: We will use 2 cubes which we can move around and these movemen
61、ts we will send over the Network.</p><p> If you load the file BasicNetwork.blend you can find 2 scripts in there which are relevant to our network setup. (Server.py and Client.py). These scripts show what
62、you get if you boil a network down to its basics. So what do they do? </p><p> Server.py</p><p><b> Script </b></p><p> #------------SETUP--------------#</p>
63、<p> from GameLogic import *</p><p> from socket import *</p><p> from cPickle import *</p><p> cont = GameLogic.getCurrentController()</p><p> obj = cont.get
64、Owner()</p><p> if obj.OneTime == 0:</p><p> ServerIP = GameLogic.IP</p><p> Serverport = 10000</p><p> Clientname =</p><p> ClientPort = 10001</p&
65、gt;<p> GameLogic.sClient = socket(AF_INET,SOCK_DGRAM)</p><p> GameLogic.sClient.bind((Clientname,ClientPort))</p><p> GameLogic.host = (ServerIP,Serverport)</p><p> Game
66、Logic.sClient.setblocking(0)</p><p> obj.OneTime = 1</p><p> PosYou = obj.getPosition()</p><p> scene = getCurrentScene()</p><p> Server = scene.getObjectList()[&qu
67、ot;OBServer"]</p><p> PosServer = [0,0,0]</p><p> #------------RECEIVE/SEND--------------#</p><p> Data = dumps((PosYou))</p><p> GameLogic.sClient.sendto(Data
68、,GameLogic.host)</p><p><b> try:</b></p><p> Data, SRIP = GameLogic.sClient.recvfrom(1024)</p><p> UPData = loads(Data)</p><p> PosServer = [UPData[0],U
69、PData[1],UPData[2]]</p><p> Server.setPosition(PosServer)</p><p> Server.setOrientation(OriServer)</p><p><b> except:</b></p><p><b> pass</b>
70、;</p><p> Explanation</p><p><b> 1: </b></p><p> from GameLogic import *</p><p> From the library we import the book (module) called GameLogic. By impo
71、rting this book we haveaccess to all the information about the blender game engine.</p><p><b> 2: </b></p><p> from socket import *</p><p> Gives us all the informat
72、ion about network socket setups.</p><p><b> 3:</b></p><p> from cPickle import *</p><p> Gives us information on how to pack data in to a container (similar to a zip
73、program).</p><p><b> 4:</b></p><p> cont = getCurrentController()</p><p> This command gets the Controller for the script and saves it to the variable cont. The logic
74、 brick we just made accessible, is the Controller that gave the order to execute the python script. </p><p><b> 5:</b></p><p> Obj = Cont.getOwner()</p><p> Gets us t
75、he owner of this script. That would be the object that owns the logic brick. </p><p><b> 6:</b></p><p> if Obj.OneTime == 0:</p><p><b> 12:</b></p>
76、<p> Obj.OneTime = 1</p><p> Line 6 calls up the property OneTime and if its value is equal to 0 it will execute the lines below that are indented. Line 12 will change the value of the property OneTi
77、me to 1. By changing the property we make sure that the indented lines below line 5 only run one time.</p><p><b> 7:</b></p><p><b> host = ''</b></p><
78、;p> Saves a empty text holder in to the variable host. The purpose of this empty text holder is to make a place where later the computer name can be written in to. So you may ask; why not write the computer name in t
79、o it right away? Well you could do that but then this script would only run on your own computer. So that’s why we leave it empty and let the socket fill it out later all by it self. You also would have the option to wri
80、te localhost between the ?“, that would say the script right a way t</p><p><b> 8: </b></p><p> ServerPort = 10000</p><p> Saves the value 10000 in to the variable Se
81、rverPort. This value will be the port number over witch the socket will communicate. That’s why you will have to make sure that your firewall and your router won’t block this and the other ports that will be added later.
82、 Information on how you can setup your firewall and router to forward information over this port, can be found in the manuals of your firewall and router. If any questions or problems come up then you can ask them in the
83、 gameblender.org </p><p><b> 9: </b></p><p> GameLogic.sServer = socket(AF_INET,SOCK_DGRAM)</p><p> This code will create a socket that uses the protocol that is defi
84、ned inside of the brackets and saves it to the global variable GameLogic.sServer. </p><p> AF_INET,SOCK_DGRAM is the definition for the UPD protocol. We will use this protocol because it is very fast and wi
85、ll keep on working even if it once can’t send or receive a packet. </p><p><b> 10: </b></p><p> GameLogic.sServer.bind((Host,ServerPort))</p><p> The code .bind((host
86、,Serverport)) is used to bind the information that we have saved in to variable host and Serverport to the socket. Now the socket knows on what computer and over witch port he should communicate. </p><p><
87、;b> 11:</b></p><p> GameLogic.sServer.setblocking(0)</p><p> The socket will already work with the lines above. But as I already mentioned by line 8 we would like to make sure that t
88、he script will keep on running even if the socket did not send or receive a packet. </p><p> This can happen very easy, if the connection having a problem, the client and server have different streaming rat
89、es the connection is temporary used by a other program… That’s why we will use the code .setblocking(0). The 0 in the brackets will tell the script that it should not block even if it did not send or receive anything. If
90、 you would put a 1 there, the script would try to receives/send a packet until it has had success. If you would do this everything would be as slow as the slowest clie</p><p><b> 13:</b></p&g
91、t;<p> PosYou = obj.getPosition()</p><p> Gets the position of servers cube (the server controls the blue cube) </p><p><b> 14:</b></p><p> scene = getCurrent
92、Scene()</p><p><b> 15:</b></p><p> Client = scene.getObjectList()["OBClient"]</p><p> The command getCurrenScene() will get all the elements of the current
93、scene in to the script. These elements will be saved in the variable scene. The variable scene contains all the elements of the current scene, now we would like to have access to all the Objects in the scene, this will h
94、appen by using the command .getObjectList(). In the square brackets we write the name of the object that we would like to save to the variable objPump1. Its important that you put the letters “OB” in front of t</p>
95、<p><b> 16:</b></p><p> PosClient = [0,0,0]</p><p> In the variable PosClient we provide a list with 3 elements. This list will be later filed with the coordinates of the p
96、layer. The 3 elements [0,0,0] stand for the X, Y and Z coordinates.</p><p><b> 17:</b></p><p><b> try:</b></p><p> Line 17 starts to try to execute the in
97、dented lines below if one of the lines fail lines 24 and 25 come in to action telling the script to just pass on. The only line below that actually can fail is the Line 18. It will fail when it tries to receive and there
98、 is no data there to receive. This can for example happen if no Client is sending any data.</p><p><b> 18:</b></p><p> Data, CLIP = GameLogic.sServer.recvfrom(1024)</p><
99、p> The variable GameLogic.sServer contains the information about the socket. The code .recvfrom commands the socket to receive data. (1024) defines the maximal size, that the buffer can receive at once. Every time we
100、 receive data we get 2 blocks. The first block contains the data and is saved in the variable Data. The second block contains sender address and is saved in the variable CLIP (=Client IP)</p><p> Blender基本網(wǎng)
101、絡(luò)設(shè)置,將其概括為基礎(chǔ)</p><p> 作者: “Old Jim” Coulter</p><p> 做游戲,和玩游戲是非常有趣的,但如果可以和朋友一起玩將更加有趣。我將向你展示如何在Blender里“煮”一個(gè)基本的網(wǎng)絡(luò)設(shè)置。因?yàn)锽lender游戲引擎沒有建立網(wǎng)絡(luò)支持我們要做的是用Python編寫一個(gè),對(duì)于這一點(diǎn),你需要一個(gè)和Blender匹配的Python。仔細(xì)看看終端或dos箱時(shí)
102、的輸出,Blender啟動(dòng)時(shí) ,如果工作被導(dǎo)入,它會(huì)告訴你需要哪個(gè)版本。</p><p><b> 成分</b></p><p> IP:獨(dú)特的計(jì)算機(jī)名稱</p><p> 局域網(wǎng)IP:只能在本地網(wǎng)絡(luò)</p><p> 互聯(lián)網(wǎng)IP:訪問世界各地的形式(當(dāng)路由器和防火墻允許它)</p><p&g
103、t; 端口:接入線路到一個(gè)特定的通信</p><p> 套接字:發(fā)送和接收站。</p><p> 庫(kù):導(dǎo)入食譜(模塊)從Python庫(kù)提供了blender信息如何</p><p><b> 準(zhǔn)備一頓特別的大餐</b></p><p> 邏輯磚:中央開關(guān)站的blender游戲引擎。</p><
104、p> 對(duì)象:我們將使用2維數(shù)據(jù)集,我們可以通過網(wǎng)絡(luò)移動(dòng)和這些動(dòng)作。</p><p> 如果你加載文件“BasicNetwork.blend”。 你能找到兩個(gè)和我們的網(wǎng)絡(luò)設(shè)置相關(guān)的腳本。(Server.py 和 Client.py)。這些腳本顯示如果你建立一個(gè)網(wǎng)絡(luò)你將得到什么。所以他們是做什么的?</p><p> Server.py 服務(wù)器</p><p&g
105、t;<b> Script 腳本</b></p><p> #------------SETUP--------------#</p><p> from GameLogic import *</p><p> from socket import *</p><p> from cPickle import
106、*</p><p> cont = GameLogic.getCurrentController()</p><p> obj = cont.getOwner()</p><p> if obj.OneTime == 0:</p><p> ServerIP = GameLogic.IP</p><p> S
107、erverport = 10000</p><p> Clientname =</p><p> ClientPort = 10001</p><p> GameLogic.sClient = socket(AF_INET,SOCK_DGRAM)</p><p> GameLogic.sClient.bind((Clientname,
108、ClientPort))</p><p> GameLogic.host = (ServerIP,Serverport)</p><p> GameLogic.sClient.setblocking(0)</p><p> obj.OneTime = 1</p><p> PosYou = obj.getPosition()</
109、p><p> scene = getCurrentScene()</p><p> Server = scene.getObjectList()["OBServer"]</p><p> PosServer = [0,0,0]</p><p> #------------RECEIVE/SEND------------
110、--#</p><p> Data = dumps((PosYou))</p><p> GameLogic.sClient.sendto(Data,GameLogic.host)</p><p><b> try:</b></p><p> Data, SRIP = GameLogic.sClient.recv
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 眾賞文庫(kù)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 計(jì)算機(jī)專業(yè)外文翻譯--計(jì)算機(jī)
- 計(jì)算機(jī)外文翻譯---計(jì)算機(jī)引論
- 計(jì)算機(jī)外文翻譯
- 計(jì)算機(jī)外文翻譯(5)
- 計(jì)算機(jī)外文資料翻譯
- 計(jì)算機(jī)科學(xué)外文翻譯
- 計(jì)算機(jī)外文翻譯(完整)
- 計(jì)算機(jī)外文翻譯1
- 計(jì)算機(jī)外文翻譯9
- 計(jì)算機(jī)外文翻譯63
- 計(jì)算機(jī)專業(yè)-外文翻譯
- 計(jì)算機(jī)外文翻譯.doc
- 外文翻譯---計(jì)算機(jī)程序
- 計(jì)算機(jī)外文翻譯 (2)
- 計(jì)算機(jī)專業(yè)外文翻譯(文獻(xiàn)翻譯)
- 計(jì)算機(jī)病毒外文翻譯
- 計(jì)算機(jī)控制外文翻譯
- 計(jì)算機(jī)相關(guān)專業(yè)外文翻譯
- 計(jì)算機(jī)編程類外文翻譯
- 計(jì)算機(jī)專業(yè)外文翻譯----計(jì)算機(jī)視覺中的學(xué)習(xí)
評(píng)論
0/150
提交評(píng)論