Random Cube Position - OpenGL with PyOpenGL Python and PyGame - 5

preview_player
Показать описание
In this OpenGL programming tutorial with Python and PyOpenGL we cover how to start our cube in a random position instead of always having the cube coming from the center.

Рекомендации по теме
Комментарии
Автор

4:28 "Hehe, That was very fast..." Thats what she said

haavardhnable
Автор

For some reason, the line "for x in range(10):" doesn't reset the camera position. How could I fix this?

crazyjplayz
Автор

An easier way for smooth controls:


def control_check():
keys_pressed = pygame.key.get_pressed()

if keys_pressed[pygame.K_w]:
glTranslatef(0.0, -0.1, 0.0)

if keys_pressed[pygame.K_s]:
glTranslatef(0.0, 0.1, 0.0)

if keys_pressed[pygame.K_d]:
glTranslatef(-0.1, 0.0, 0.0)

if keys_pressed[pygame.K_a]:
glTranslatef(0.1, 0.0, 0.0)

lonelyapples
Автор

This key press and hold method is not currently working. I am on 3.6.1.
No errors are thrown, but no action is taking place.
I have tried adding a
keys = pygame.keys.get_pressed() along with a keys[K_UP] call with no results either...

Any suggestions?

thrillacious
Автор

I have a question: Is the same thing to use glTranslatef(x, y, z) Vs the varialbes x and y move?

alvarosuarez
Автор

HEELP!

Sorry to post on nearly every video but this time this error pops up.

File "projectcode_1.py", line 91
object_passed = False
^
SyntaxError: invalid syntax

what do I do?

KimHyungJuniamboss
Автор

I get an error for the "if event.type == pygame.KEYDOWN:" line and "main()" line when I pass 2 objects right after I added the randomness of the cube spawn position

drakefruit
Автор

hey, I really like your videos.Could u help me with my game(pygame /3d) which is my homework at my school? ^^

danasaba
Автор

Hi everyone. Copied the full code from pythonprogramming.net, simply does not work. First cube works perfectly, then the program just ends. I know for sure that pygame & pyopengl are installed correctly on my computer. Seems like a lot of people are having issues on this one, just continue on to the next one if you are guys, the next tutorials work ok for me anyway. btw sentdex if you see this maybe correct whatever it is that is wrong with the code on pythonprogramming.net, its v confusing when the code just doesn't work lol

bruckeundkeinzweck
Автор

I HATE MY COMPUTER! REALLY! I WANNA THROW IT OUT OF MY WINDOW!

I can press my a button (because i cannot use arrow keys...) as hard as i can, and the cube does not wanna move, Even with your sample code. I do not know if i should continue with PyOpenGL and PyGame. (Yes, i had part of the problem in PyGame too, but the press-and-hold worked.) Because if something that mayor like controlls do not work, it really makes not much sense to do it.

BUT WHY????
I blame Acer (They made my Computer), Samsung (My Keyboard) and Microsoft (for Windows). Thats all.

Bye Py. I will come back when i solved the problems...

(No, restarting the Computer does not help. Reinstalling Python, Pygame and PyOpenGL does not fix it.)

leberkassemmel
visit shbcf.ru