Posted: Thu Dec 30, 2004 7:05 am
Joined: 30 Dec 2004
Posts: 2
does anyone kow how to make objects be randomly generated in a designated area like in tetris where the peices are randomly appeared in the box where they drop down?
Posted: Fri Dec 31, 2004 3:39 am
Joined: 31 Jul 2003
Posts: 413
i take it you are talking about the game engine????
i guess the best thing to do would be to go read some code of other tetris games made in java or C, ive seen some writen in assembly, but that wont be much help. visual basic or even old Qbasic should help as well.
Posted: Fri Dec 31, 2004 4:54 pm
Joined: 17 Mar 2004
Posts: 250
there's a Tetris clone made in Python (using Pygame i.e. SDL) at
http://people.jyu.fi/~shang/pytris/ (it's listed on the pygame projects page, under
http://www.pygame.org)
~Toni
Posted: Fri Dec 31, 2004 4:58 pm
Joined: 17 Mar 2004
Posts: 250
oh well i guess i could answer the question too, even though this is no Elysiun:
| Code: |
import random
boxwidth = 10
xpos = random.randint(1, boxwidth)
|
.. assuming the first pos is 1 in your system. you probably want some grid for the box (there are plenty of Python Grid classes around, and it's simple to do yourself). oh and supposing you know your way around setting the positions etc.
hoping those helped,
~Toni
Posted: Fri Dec 31, 2004 6:14 pm
Joined: 17 Mar 2004
Posts: 250
reading about something totally unrelated, happened to see this too:
http://archives.seul.org/pygame/users/Jan-2004/msg00074.html [pygame] learning to program tetris which goes into more detail about the data structures.
~Toni
Posted: Wed Jan 05, 2005 5:05 am
Joined: 30 Dec 2004
Posts: 2
thanks, i'll check into those info's when i get a chance, i dont know anything about programming, but i think it would be a good little project to help me learn a bit about it.