-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAttempt_1
62 lines (49 loc) · 2.38 KB
/
Attempt_1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#
# First Attempt At 3D Game Creation in Python
# NAME:
# Start Date:Oct 3nd 2017
# Finish/GiveUp Date:
# Purpose: Testing out the Pyglet Module
# Video Tutorial From: https://www.youtube.com/watch?v=Wyv5TnkFuxE
# Thanks Man!
#
from pyglet.gl import *
class Triangle:
def __init__(self):
self.Vertices = pyglet.graphics.vertex_list(3, ('v3f', [-0.5, -0.5, 0.0, 0.5, -0.5, 0.0, 0.0, 0.5, 0.0]),
('c3B',[100,200,220, 200,110,100, 100,250,100]))
class MyWindow(pyglet.window.Window):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.set_minimum_size(400, 300)
glClearColor(0.2,0.3,0.2,1.0)
self.triangle = Triangle()
def on_draw(self):
self.clear()
self.triangle.vertices.draw(GL_TRIANGLES)
def on_resize (self, width, height):
glViewport(0, 0, width, height)
if __name__ == "__main__":
window = MyWindow(1280, 1024, "My Pyglet Window", resizable=True)
pyglet.app.run()
#Also NOTE: "self" In mine is Defaulted White and not Grey Like in Video
#Python v3.6.2
# Error Message that i am getting
# Traceback (most recent call last):
# File "C:\Users\KawaiiKuramaDesktop\Desktop\PythonGames\pygletTut.py", line 37, in <module>
# pyglet.app.run()
# File "C:\Users\KawaiiKuramaDesktop\Desktop\PythonGames\pyglet\app\__init__.py", line 143, in run
# event_loop.run()
# File "C:\Users\KawaiiKuramaDesktop\Desktop\PythonGames\pyglet\app\base.py", line 136, in run
# self._run_estimated()
# File "C:\Users\KawaiiKuramaDesktop\Desktop\PythonGames\pyglet\app\base.py", line 165, in _run_estimated
# timeout = self.idle()
# File "C:\Users\KawaiiKuramaDesktop\Desktop\PythonGames\pyglet\app\base.py", line 280, in idle
# window.dispatch_event('on_draw')
# File "C:\Users\KawaiiKuramaDesktop\Desktop\PythonGames\pyglet\window\__init__.py", line 1154, in dispatch_event
# if EventDispatcher.dispatch_event(self, *args) != False:
# File "C:\Users\KawaiiKuramaDesktop\Desktop\PythonGames\pyglet\event.py", line 365, in dispatch_event
# if getattr(self, event_type)(*args):
# File "C:\Users\KawaiiKuramaDesktop\Desktop\PythonGames\pygletTut.py", line 29, in on_draw
# self.triangle.vertices.draw(GL_TRIANGLES)
# AttributeError: 'Triangle' object has no attribute 'vertices'