コード例 #1
0
ファイル: my_cars.py プロジェクト: jonag-code/python
from car_module import Car
from electric_car_module import ElectricCar
#from electric_car_module import ElectricCar, Car

my_beetle = Car('volkswagen', 'beetle', 2016)
print(my_beetle.get_descriptive_name())

my_tesla = ElectricCar('tesla', 'roadster', 2016)
print(my_tesla.get_descriptive_name())

#Note: ElectricCar() is a child class that uses the
#	parent class Car() in it's definition. The module
#	"electric_car_module" uses Car() by importing
#	car_module as well!
#Use the commented out line 3 and remove lines 1 and
#	2 to show this.
コード例 #2
0
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *

from car_module import Car

width, height = 600, 600
MS_PER_FRAME = 10
viewer = [60, 8]  # rotation around z and height

millis = 0
mouse = [0, 0]
wireframe = False

car = Car((1, 0, 0))
car.set_wheel_rotation_speed(0.1)  # rotations per second


def draw_axis():
    glBegin(GL_LINES)
    for v in [(1, 0, 0), (0, 1, 0), (0, 0, 1)]:
        glColor3fv(v)
        glVertex3f(0, 0, 0)
        glVertex3fv(v)
    glEnd()


def draw_grid():
    """ draws a grid of 100x100 on the x-z plane with 1 unit increments """
    glPushAttrib(GL_LIGHTING_BIT)
コード例 #3
0
from car_module import Car

my_new_car = Car('audi', 'a4', 2019)
print(my_new_car.get_descriptive_name())

my_new_car.odometer_reading = 23
my_new_car.read_odometer()
コード例 #4
0
ファイル: car_use.py プロジェクト: Kyle-han-git/python-ex
#import car_module
from car_module import Car

if __name__ == "__main__":
    my_car = Car()
    my_car.start()
    my_car.accelerate()
    print("속도:", my_car.get_speed())
    my_car.stop()
    print("속도:", my_car.get_speed())
コード例 #5
0
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *

from car_module import Car

width, height = 600, 600
MS_PER_FRAME = 10
viewer = [60, 8]  # rotation around z and height

millis = 0
mouse = [0, 0]
wireframe = False

car = Car((1, 0, 0))


def draw_axis():
    glBegin(GL_LINES)
    for v in [(1, 0, 0), (0, 1, 0), (0, 0, 1)]:
        glColor3fv(v)
        glVertex3f(0, 0, 0)
        glVertex3fv(v)
    glEnd()


def display():
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
    glLoadIdentity()

    gluLookAt(0, viewer[1], 3, 0, 0, 0, 0, 1, 0)
コード例 #6
0
from random import random
import math

from car_module import Car

width, height = 600, 600
MS_PER_FRAME = 10
viewer = [60, 20]  # rotation around z and height

millis = 0
mouse = [0, 0]
wireframe = False

car_spread = 50
car_speed = 4
all_cars = [Car((random(), random(), random())) for i in range(100)]
for c in all_cars:
    c.set_wheel_rotation_speed((random() + 0.2) * car_speed)
    c.set_orientation(random() * 360.0)
    c.set_position(
        (car_spread * (2 * random() - 1), 0, car_spread * (2 * random() - 1)))

    # give the cars a target orientation variable which they'll use to turn
    c.target_orientation = random() * 360


def draw_axis():
    glBegin(GL_LINES)
    for v in [(1, 0, 0), (0, 1, 0), (0, 0, 1)]:
        glColor3fv(v)
        glVertex3f(0, 0, 0)