From: Zbigniew <ze...@in...> - 2004-05-08 09:02:49
|
Hello. I'm new to python at all. Currently on studies we are learning python and I've invented for myself subject to write 3d snake game with visual. It should be there: http://free.art.pl/zeeball/snake3d.tar.bz2 or http://zeeball.w.interia.pl/bin/snake3d.tar.bz2 It's almost ready so now I ask more advanced users for betatesting, bugfixing, optimising and so on... There is also strange bug I'm looking for in the game maybe somebody could help. Thanks in advance. Zbigniew Trzcionkowski <ze...@in...> |
From: Zbigniew <ze...@in...> - 2004-05-13 07:50:00
|
Hello I have fixed my game little bit, now its playable however there stills bug I'm looking for. The game: http://zeeball.w.interia.pl/bin/snake3d.tar.bz2 Am I on wrong maillist? Zbigniew Trzcionkowski <ze...@in...> |
From: Bruce S. <Bru...@nc...> - 2004-05-13 13:55:04
|
I tried to run the program, which has some very nice visual effects. However, there are no instructions on how to play the game, so I don't know what to do with it. In the program file there is this comment: # bugs: due to unknown reasons sometimes # box in the middle of snake's body seem # to disappear and some other strange things # happen I've not seen a snake (since I don't know how to play the game), and this bug description isn't adequate for knowing what to look for. If you would like help in debugging this promising program, please explain how to play the game, and also give more details on what bugs you see. Bruce Sherwood Zbigniew wrote: > Hello > > I have fixed my game little bit, > now its playable however > there stills bug I'm looking for. > The game: > http://zeeball.w.interia.pl/bin/snake3d.tar.bz2 > Am I on wrong maillist? > > Zbigniew Trzcionkowski <ze...@in...> > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: SourceForge.net Broadband > Sign-up now for SourceForge Broadband and get the fastest > 6.0/768 connection for only $19.95/mo for the first 3 months! > http://ads.osdn.com/?ad_id=2562&alloc_id=6184&op=click > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users |
From: Zbigniew <ze...@in...> - 2004-05-13 16:18:50
|
> I tried to run the program, which has some very nice visual effects. > However, there are no instructions on how to play the game, so I don't > know what to do with it. Thanks for contating I was afraid my mails doesn't reach the list. Snake game is known as box that we can control on 2d space and it "eats" randomly appearing boxes. This causes it growing and the game becomes more and more difficult as if the head of the snake hits itself or bound of the screen the game ends. In this version it is done in 3d space so the flashing box has to eat green box. It is quite difficult to learn controls in 3d space, but I couldn't invent anything better :( The snake always moves from the depth of screen in user's direction, and the space is rotated so that the direction of snake moving changes. The problem is that sometimes in the snake is missing box. The other problem is that sometimes snake does not eat the box (the collision isn't detected). I know it will take some time to learn how it is done, but of course I have two scrollers for thanks :) The game can be of course exaple for python as after getting mark I will not need it anymore. regards and thanks Zbigniew Trzcionkowski ze...@in... |
From: Andrew D. <dou...@la...> - 2004-05-13 17:00:05
|
On Thu, 13 May 2004, Zbigniew wrote: > I know it will take some time to learn how it is done, > but of course I have two scrollers for thanks :) > The game can be of course exaple for python > as after getting mark I will not need it anymore. It's worth noting that the program requires a "Matrix" module, which is not part of a normal VPython Linux installation. -- Andy Dougherty dou...@la... Dept. of Physics Lafayette College, Easton PA 18042 |
From: Zbigniew <ze...@in...> - 2004-05-13 20:12:51
|
> It's worth noting that the program requires a "Matrix" module, which > is not part of a normal VPython Linux installation. I didn't know. Anybody could send me small matrix multiplication routine in python? Zbigniew Trzcionkowski <ze...@in...> |
From: Zbigniew <ze...@in...> - 2004-05-14 10:04:37
|
Primarily, thank You all for patience. Even people watching me playing had problems to play snake3d themselves. Seems I made not playable game, therefore now I will ask more detailed questions which may point me to improve the game anyway: 1. I have question concerning Linux. The best scores of the game are kept in a text file (it's enough to eat one green box to check this). Is there any problem with creation/accessing the hi-score file? 2. The game do require to rotate objects. During making of the game I noticed that rotate method doesn't affect the pos field. Matrix module is used for hand written rotation routines for the snake and green box. Maybe there is better solution for this? 3. The collision detection is done with the pos field. The rotations of the playfield are 90 degree (split in phases to animate). Pos coordinates of the boxes are used to detect collisions and should be integer numbers (I assumed that 90 degree rotations transform integer into integer). I'm aware of the floats during roations therefore I do float->int conversion. I do it but sometimes the snake runs through the green box and collision is not detected. Code looks ok. Thats the major problem I cannot solve and I came here with. 4. The other problem is that sometimes after many rotations there is missing box inside snake body. Other questions: 1. Is there chance for sound module for python? 2. Is there chance for bitmap graphics support (I imagine it as a layer on the top of the 3d display). That would be also useful for teaching of the computer graphics (drawing lines, filtering images etc.) Zbigniew Trzcionkowski <ze...@in...> |
From: Jonathan B. <jbr...@ea...> - 2004-05-14 12:53:48
|
On Fri, 2004-05-14 at 06:04, Zbigniew wrote: caveat, I haven't looked at any of your code. > 3. > The collision detection is done with > the pos field. The rotations of the > playfield are 90 degree (split in > phases to animate). > Pos coordinates of the boxes are used > to detect collisions and should be > integer numbers > (I assumed that 90 degree rotations transform > integer into integer). This is probably not a valid assumption if you are using the built-in rotate() function. > I'm aware of the floats during roations therefore > I do float->int conversion. > I do it but sometimes the snake runs through > the green box and collision is not detected. > Code looks ok. Thats the major problem > I cannot solve and I came here with. All vectors are always floating-point values in VPython. If you need to truncate the precision to an integer type, you will probably need to write your own round-to-nearest conversion routine since Python only directly supports truncation of the decimal part. See math.modf() for some help here. > 2. Is there chance for bitmap graphics support > (I imagine it as a layer on the top of the 3d display). > That would be also useful for teaching of the computer > graphics (drawing lines, filtering images etc.) VPython doesn't support anything in screen coordinates except for portions of the text object. I'm doing some experiments with OpenGL textures that may yield fruit in this area, but its way too early to tell right now. HTH, Jonathan Brandmeyer |
From: Andrew W. <an...@ph...> - 2004-05-14 13:28:20
|
On Fri, 14 May 2004 08:53:45 -0400, Jonathan Brandmeyer wrote: >All vectors are always floating-point values in VPython. If you need to >truncate the precision to an integer type, you will probably need to >write your own round-to-nearest conversion routine since Python only >directly supports truncation of the decimal part. See math.modf() for >some help here. I'd have thought the 'round' builtin would do just that. It returns a float, but rounded to the specified number of decimal places (if the optional number of decimal places is omitted), so int(round(x)) should always be the nearest integer. Still, I'd test for collision by specifying a tolerance a bit more explicitly - if pos2 and pos1 are both vectors, this is short and very readable: if abs(pos2 - pos1) < 0.01: handle_collision() Andrew |
From: Zbigniew <ze...@in...> - 2004-05-14 18:36:55
|
> optional number of decimal places is omitted), so int(round(x)) should > always be the nearest integer. that's it! I didn't notice how exactly int() function does work. Thank you all for the effort and please forgive me the problems I had with describing the problem I had. >if abs(pos2 - pos1) < 0.01: > handle_collision() thats also very good The fixed game should be there: http://zeeball.w.interia.pl/bin/snake3d.tar.bz2 I have added in comments short description of the game. Let me know if anyone managed to play that game with or without this description: # there is 3D space with green box and flashing box # the green box is the food for the snake # and the flashing box is head of the snake # the snake is always moving in in Z direction # therefore to navigate the snake we have to rotate # the whole space with arrow keys till the snake # collides with food Once again big thanks! Zbigniew Trzcionkowski <ze...@in...> |
From: Jonathan B. <jbr...@ea...> - 2004-05-15 03:03:32
|
On Fri, 2004-05-14 at 09:28, Andrew Williams wrote: > On Fri, 14 May 2004 08:53:45 -0400, Jonathan Brandmeyer wrote: > > >All vectors are always floating-point values in VPython. If you need to > >truncate the precision to an integer type, you will probably need to > >write your own round-to-nearest conversion routine since Python only > >directly supports truncation of the decimal part. See math.modf() for > >some help here. > > I'd have thought the 'round' builtin would do just that. It returns a > float, but rounded to the specified number of decimal places (if the > optional number of decimal places is omitted), so int(round(x)) should > always be the nearest integer. > > Still, I'd test for collision by specifying a tolerance a bit more > explicitly - if pos2 and pos1 are both vectors, this is short and very > readable: > > if abs(pos2 - pos1) < 0.01: > handle_collision() > > Andrew Of course, a built-in function. I was only looking in the math module. Thanks for clearing this up. -Jonathan Brandmeyer |
From: Bruce S. <Bru...@nc...> - 2004-05-16 01:36:02
|
I don't understand this syntax. If pos2 and pos1 are intended to stand for something like box1.pos and box2.pos, positions of VPython objects, then what you need is mag(pos2-pos1), not abs(pos2-pos1). Bruce Sherwood Jonathan Brandmeyer wrote: > On Fri, 2004-05-14 at 09:28, Andrew Williams wrote: > >>On Fri, 14 May 2004 08:53:45 -0400, Jonathan Brandmeyer wrote: >> >> >>>All vectors are always floating-point values in VPython. If you need to >>>truncate the precision to an integer type, you will probably need to >>>write your own round-to-nearest conversion routine since Python only >>>directly supports truncation of the decimal part. See math.modf() for >>>some help here. >> >>I'd have thought the 'round' builtin would do just that. It returns a >>float, but rounded to the specified number of decimal places (if the >>optional number of decimal places is omitted), so int(round(x)) should >>always be the nearest integer. >> >>Still, I'd test for collision by specifying a tolerance a bit more >>explicitly - if pos2 and pos1 are both vectors, this is short and very >>readable: >> >>if abs(pos2 - pos1) < 0.01: >> handle_collision() >> >>Andrew > > > > Of course, a built-in function. I was only looking in the math module. > Thanks for clearing this up. > > -Jonathan Brandmeyer > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: SourceForge.net Broadband > Sign-up now for SourceForge Broadband and get the fastest > 6.0/768 connection for only $19.95/mo for the first 3 months! > http://ads.osdn.com/?ad_id=2562&alloc_id=6184&op=click > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users |
From: Andrew W. <an...@ph...> - 2004-05-16 03:37:24
|
On Sat, 15 May 2004 21:36:07 -0400, Bruce Sherwood wrote: >I don't understand this syntax. If pos2 and pos1 are intended to stand >for something like box1.pos and box2.pos, positions of VPython objects, >then what you need is mag(pos2-pos1), not abs(pos2-pos1). > >> On Fri, 2004-05-14 at 09:28, Andrew Williams wrote: >>> >>>if abs(pos2 - pos1) < 0.01: >>> handle_collision() The 'abs' builtin does return the magnitude of a vector - I checked before posting the email. It doesn't work for tuples, only visual's vector types. I'd actually forgotten about the 'mag' function, but I assume that _would_ work for tuples, as it'd auto-convert them into vectors like all the other visual functions. Andrew |
From: Jonathan B. <jbr...@ea...> - 2004-05-16 20:21:05
|
On Sat, 2004-05-15 at 23:37, Andrew Williams wrote: > On Sat, 15 May 2004 21:36:07 -0400, Bruce Sherwood wrote: > > >I don't understand this syntax. If pos2 and pos1 are intended to stand > >for something like box1.pos and box2.pos, positions of VPython objects, > >then what you need is mag(pos2-pos1), not abs(pos2-pos1). > > > >> On Fri, 2004-05-14 at 09:28, Andrew Williams wrote: > >>> > >>>if abs(pos2 - pos1) < 0.01: > >>> handle_collision() > > The 'abs' builtin does return the magnitude of a vector - I checked > before posting the email. This is undocumented behavior and should not be relied upon in the future. -Jonathan Brandmeyer |
From: Zbigniew <ze...@in...> - 2004-05-14 18:36:52
|
> All vectors are always floating-point values in VPython. If you need to > truncate the precision to an integer type, you will probably need to > write your own round-to-nearest conversion routine since Python only > directly supports truncation of the decimal part. See math.modf() for > some help here. Yes! That was the reason. I even don't need the Matrix module now. I can give it as example for Vpython. Let me know what to change in the "shape" of the code. > VPython doesn't support anything in screen coordinates except for > portions of the text object. I'm doing some experiments with OpenGL > textures that may yield fruit in this area, but its way too early to > tell right now. Nice to know. Zbigniew Trzcionkowski <ze...@in...> |
From: Bruce S. <Bru...@nc...> - 2004-05-16 20:57:36
|
I think the question below wasn't addressed by anyone, so I'll give it a shot. There is an extremely extensive set of modules for Python, to do almost anything. This includes dealing with sound. In fact, I think the creator of Python, Guido van Rossum, himself contributed to the sound capabilities. I haven't used this machinery myself, though. In the Python documentation, see section 14 (multimedia) of the "Library Reference" document. Bruce Sherwood Zbigniew wrote: > Other questions: > 1. Is there chance for sound module for python? |
From: Zbigniew <ze...@in...> - 2004-05-17 16:02:11
|
> almost anything. This includes dealing with sound. In fact, I think the > creator of Python, Guido van Rossum, himself contributed to the sound > capabilities. I haven't used this machinery myself, though. > In the Python documentation, see section 14 (multimedia) of the "Library > Reference" document. yes. there is somekind of support for OSS but this is system specific feature :( I will look if something external exists. when I am on subject of system specials: label object can have font specified. Names like Arial or Helvetica are system specific. Support for names known from CSS -- monospace, serif, sans-serif would be interesting feature. Windows question: how to get rid of that black useless window behind visual display (also Tkinter). I know py2exe can generate non dos exe, but how to achieve that on script level? regards Zbigniew Trzcionkowski <ze...@in...> |
From: Jonathan B. <jbr...@ea...> - 2004-05-18 02:06:05
|
On Mon, 2004-05-17 at 11:26, Zbigniew wrote: > Windows question: > how to get rid of that black useless window > behind visual display (also Tkinter). > I know py2exe can generate non dos exe, > but how to achieve that on script level? > > regards > Try using the pythonw.exe executable rather than python.exe. HTH, Jonathan Brandmeyer |
From: Zbigniew <ze...@in...> - 2004-06-03 16:29:04
|
I wanted to thank You all for help. At the following location You can find mini page devoted to python including the snake3d game: http://www.zeeball.friko.pl/python/ regards Zbigniew Trzcionkowski <ze...@in...> |
From: Zbigniew <ze...@in...> - 2004-05-13 20:09:51
|
Below is code for 2d snake I wrote at the beginning. This code was ok, but might be useful to find out how the snake games are done. In the 3d version I'm looking for somekind of bug with collision detection. --- # snake 2d # wersja 3.5.2004 from visual import * from string import * from random import * skrin=display(width=640, height=480, range=30) pozycjaX=0 pozycjaY=0 bok=15 kierunek=0 snake=[] snake.append(box(pos=[pozycjaX,pozycjaY,0], width=0.8, height=0.8, length=0.8)) klocX=0 klocY=0 while klocX==pozycjaX: klocX=randrange(-bok,bok) while klocY==pozycjaY: klocY=randrange(-bok,bok) kloc=box(pos=[klocX,klocY,0], width=0.8, height=0.8, length=0.8) box(pos=[-bok-1,0,0],width=0.8, height=2*(bok+2), length=0.8) box(pos=[bok+1,0,0], width=0.8, height=2*(bok+2), length=0.8) box(pos=[0,bok+1,0], width=0.8, height=0.8, length=2*(bok+2)) box(pos=[0,-bok-1,0], width=0.8, height=0.8, length=2*(bok+2)) while 1: for i in range(0,10): rate(50) snake[len(snake)-1].color=[0.5+random(),0.5+random(),0.5+random()] if skrin.kb.keys: s = skrin.kb.getkey() if s=="right": kierunek=0 if s=="left": kierunek=1 if s=="up": kierunek=2 if s=="down": kierunek=3 break if kierunek==0: pozycjaX=pozycjaX+1 if pozycjaX>bok: break if kierunek==1: pozycjaX=pozycjaX-1 if pozycjaX<-bok: break if kierunek==2: pozycjaY=pozycjaY+1 if pozycjaY>bok: break if kierunek==3: pozycjaY=pozycjaY-1 if pozycjaY<-bok: break crash=0 for i in range(0,len(snake)): if snake[i].pos[0]==pozycjaX and snake[i].pos[1]==pozycjaY: crash=1 if crash==1: break snake.append(box(pos=[pozycjaX,pozycjaY,0], width=0.8, height=0.8, length=0.8)) temp=snake.pop(0) temp.visible=0 if pozycjaX==klocX and pozycjaY==klocY: while klocX==pozycjaX: klocX=randrange(-bok,bok) while klocY==pozycjaY: klocY=randrange(-bok,bok) kloc.pos=[klocX,klocY,0] snake.append(box(pos=[pozycjaX,pozycjaY,0], width=0.8, height=0.8, length=0.8)) label(text="game over") Zbigniew Trzcionkowski <ze...@in...> |