game development i - cognitive sciencedestem/gamedev/p1.pdf · be open and honest. talk with your...
TRANSCRIPT
Render LoopGame Logic
Player updateSense player inputComputer restrictionsUpdate player state
World updatePassive elements
Pre-select active zone for engine useLogic-based elements
Sort according to relevanceExecute control mechanismUpdate state
AI based elementsSort according to relevanceSense internal state and goalsSense restrictionsDecision engineUpdate world
End
Presentation World presentation Select visible subset Clip Cull Occlude Select Resolution Pack geometry Render world geometry Select audible sound sources Pack audio data Send to audio hardware NPC presentation Select visible subset Animate Pack Render NPC data Player presentation Animate Pack RenderEnd
• import statements
• class definitions
• create initial objects
• main while loop
• tick clock
• process events (keypresses, etc.)
• update objects (collision detection, etc.)
• draw objects
• display screen
MainThread
AnimationThread
DynamicsThread
RenderingThread
HID
Update GameObjects
Kick off Animation
Post AnimationGame Object Update
Kick Dynamics Sim
Ragdoll Physics
Finalize Animation
Finalize Collision
Other Processing(AI Planning, Audio
Work, etc.)
Kick Redering(for next frame)
Sleep
PoseBlending
Sleep
Sleep
RagdollSkinning
Global PoseCalculation
Skin MatrixPalette
Calculation
Sleep
Simulateand
Integrate
Sleep
Sleep
Broad PhaseColl.
Narrow Phase Coll.
ResolveConstraints Wait for V-
Blank
Wait forGPU
VisibilityDetermination
Sort
SubmitPrimitives
Full-ScreenEffects
Swap Buffers
Initialization
import pygame
pygame.init()
screen = pygame.display.set_mode(size)
• size is a tuple, common sizes are (800, 600) and (1024, 768)
Events
• pygame.event.get() - gets a list of all events since the last call. Call once per frame
• event.type:QUIT! ! ! noneKEYDOWN! ! unicode, key, mod (use pygame.locals, for comparison)KEYUP! ! ! key, modMOUSEMOTION ! pos, rel, buttonsMOUSEBUTTONUP! pos, buttonMOUSEBUTTONDOWN pos, button
Time• pygame.time.Clock() Creates a Clock object
• Clock.tick() Returns number of milliseconds since last call
• Call once per frame to lock the frame rate. Clock.tick(50) = 50FPS
• pygame.time.get_ticks() Returns the number of milliseconds passed since pygame.init() was called
Surfaces
• an image, stored in memory
• surf = pygame.Surface(size)
• surf = pygame.image.load(filename)
• PNG recommended
Surface Methods
• Surface.fill(color) Fills surface with a solid color. Argument is a tuple of RGB values
• Surface.convert() Changes pixel format of the Surface’s image to the format used by the main display. Makes things faster. Use it.
• Surface.convert_alpha() Same as above, but when the Surface’s image has alpha transparency values to deal with.
Blit
• From “BitBLT”, for “Bit Block Transfer”
• copies pixels from one surface to another
surface.blit(sourceSurface,destPos, [sourcePos])
Rects• Position and dimension
• Rect.move(x, y) Returns a Rect moved x pixels horizontally and y pixels vertically Rect.move_ip(x, y) Moves the Rect x pixels horizontally and y pixels vertically
• Attributes include: top left bottom right topleft bottomleft
topright bottomright midtop midleft midbottom midright
center centerx centery size width height
More Surface Methods
• Surface.get_rect() Returns a Rect that will tell you the dimensions and location of the surface.
• pygame.transform.rotate(Surface, angle) Rotates Surface counterclockwise by degrees
• pygame.transform.scale(Surface, (width, height)) Resizes Surface to new resolution
Fonts
•f = pygame.font.Font(None, 32)
• Creates a font object of size 32 using the default font. If you know where the .TTF file of the font you want to use is located, you can use the filename as the first argument
•surf = f.render(“Hello”, 1, (255,0,255), (255,255,0))
Audio
kaboom = pygame.mixer.Sound(filename) ! ! must be an uncompressed WAV or OGGkaboom.play(loops=0, maxtime=0)kaboom.stop()
pygame.mixer.music.load(filename)pygame.mixer.music.play(loops=0) !! set loops to number of times to repeat after first run-through, -1 ! ! ! ! ! ! ! to repeat indefinitelypygame.mixer.music.stop()
Collision Detection
Rect.contains(Rect): return True or FalseRect.collidepoint(x, y): return True or FalseRect.colliderect(Rect): return True or FalseRect.collidelist(list): return index (-1 if none)
• import statements
• class definitions
• create initial objects
• main while loop
• tick clock
• process events (keypresses, etc.)
• update objects (collision detection, etc.)
• draw objects
• pygame.display.flip()
Meet people properly. It all starts with the introduction. Then, exchange contact information, and make sure you know how to pronounce everyone’s names. Exchange phone numbers, and find out during what hours are acceptable to call
Find things you have in common. You can almost always find something in common with another person, and starting from that baseline, it’s much easier to then address issues where you have differences.
Make meeting conditions good. Have a large surface to write on, make sure the room is quiet and warm enough, and that there aren’t lots of distractions. Make sure no one is hungry, cold, or tired. Meet over a meal if you can – food softens a meeting.
Let everyone talk, even if you think what they’re saying is stupid. Cutting someone off is rude, and not worth whatever small time gain you might make. Don’t finish someone’s sentences for him or her; they can do it for themselves.
Check your egos at the door. When you discuss ideas, immediately label them and write them down. The labels should be descriptive of the idea, not the originator: “the troll bridge story,” not “Rob’s story.”
Praise each other. Find something nice to say, even if it’s a stretch. Even the worst of ideas has a silver lining inside it, if you just look hard enough. Focus on the good, praise it, and then raise any objections or concerns you have about the rest of it.
Put it in writing. Always write down who is responsible for what, by when. Be concrete. Arrange meetings by email, and establish accountability. Never assume that someone’s roommate will deliver a phone message. Also, remember that “politics is when you have more than 2 people.” With that in mind, always CC any piece of email within the group, or to either of us, to all members of the group.
Be open and honest. Talk with your group members if there’s a problem, and talk with us if you think you need help. The whole point of this course is that it’s tough to work across cultures. If we all go into it knowing that’s an issue, we should be comfortable discussing problems when they arise – after all, that’s what it’s really about. Be forgiving when people make mistakes, but don’t be afraid to raise the issues when they come up.
Phrase alternatives as questions. Instead of “I think we should do A, not B,” try “What if we did A, instead of B?” That allows people to offer comments, rather than defend one choice.
Avoid conflict at all costs. When stress occurs and tempers flare, take a short break. Clear your heads, apologize, and take another stab at it. Apologize for upsetting your peers, even if you think someone else was primarily at fault – the goal is to work together, not start a legal battle over whose transgressions were worse. It takes two to have an argument, so be the peacemaker.
Team 1Kevin ChangDennis Co
Victor CortesKelly DeBarrChris Wise
Team 2Sebastian DalbyDaniel Newton
Nathan PaloAnthony Szymczyk
Ashley Tanski
Team 3Alex BurkholderJavier Camino
Kevin HendricksIan Ooi
Matthew McMullan
Team 4Matthew Chapman
Tif EntwhistleGerald Franklin
Nick LewisAndrew Ryther
Team 5Andrew LeingMichael Maris
Themos PanotopoulosJeffrey Steel
Kai VanDrunen
Team 6Sebastian Basch
Chris DeBartolomeoJulian Eden
Michael LechnerJames McCarthy
Team 7PJ Castracucco
Mitchell CooperGeo KerseyJames Ross
Gabriel Violette
Team 8Nicholas Cesare
Jay LeeGrace Rhee
Robert Stewart
Team 9Marcus Baker
Vincent KocherHarrison Krug
Chayut NapombejaraTom Weithers
Assignment #1• Aesthetics:
• Choose a visual style that fits with your game
• In your writeup, include the motivations for your choices and how it helps the game experience. These include the images, colors, fonts, and other visual decisions
• Do the elements fit together in a coherent visual look? for example, if you're going for a 16-bit retro style, then everything should fit with that look; similarly, the UI elements like on-screen text, score, meters, menus, should all fit with the game's look.