EEL 3705 / 3705L Digital Logic Design Spring 2007 Instructor: Dr. Michael Frank Modules #90-99 (Extra Slides): Design Examples Module #93: Animated VGA Graphics– Ping-Pong Video Game 11/10/2018 M. Frank, EEL3705 Digital Logic, Fall 2006
Ping-Pong Videogame Example Dynamic Display Generation, Layered Graphics, Controlled Paddle Motion 11/10/2018 M. Frank, EEL3705 Digital Logic, Fall 2006
Real-World Ping-Pong Table Image credit: Wikipedia 11/10/2018 M. Frank, EEL3705 Digital Logic, Fall 2006
Ping-Pong Game Display Mocked-up here as a Powerpoint animation Ball Left paddle Right paddle “Midline” “Net” 11/10/2018 M. Frank, EEL3705 Digital Logic, Fall 2006
M. Frank, EEL3705 Digital Logic, Fall 2006 Plan for Game Controls Left pushbutton FLEX_PB1 will control left player’s paddle Held down = move down, released = move up Right button controls right paddle similarly 11/10/2018 M. Frank, EEL3705 Digital Logic, Fall 2006
Plan for game’s “physics” When the ball hits a wall, it bounces elastically Horizontal or vertical velocity will change sign When the ball hits a paddle… Its vertical velocity (vy) will increase or decrease depending on which direction paddle is moving Paddle moving up vertical velocity decreases Paddle moving down vertical velocity increases Its horizontal velocity (vx) will change sign (bounce) Its absolute value will increase if the ball hits near the center of the paddle (a “good hit”) Its absolute value will decrease if the ball hits near the edge of the paddle (a “glancing blow”) 11/10/2018 M. Frank, EEL3705 Digital Logic, Fall 2006
Prioritized Color Layer Combiner Allows one graphics object to override another… 11/10/2018 M. Frank, EEL3705 Digital Logic, Fall 2006
Table Surface Stipple Color Layer Generator Pure green makes for an overly bright table surface, so instead we use an XOR gate to create a green-on-black checkerboard stipple pattern implemented by this circuit 11/10/2018 M. Frank, EEL3705 Digital Logic, Fall 2006
Game Display Generator (top half) Note we use two instances of the color_mixer module to combine the outputs of the table, midline, and net renderers 11/10/2018 M. Frank, EEL3705 Digital Logic, Fall 2006
Paddle Renderer (only left paddle so far) Left paddle is rendered as a 10×50 pixel blue rectangle starting at y coordinate lpy (input) 11/10/2018 M. Frank, EEL3705 Digital Logic, Fall 2006
Entire Ping-Pong Display Renderer (so far) Altogether we’re using three of our color_mixer modules in order to correctly combine the graphics on the playing surface, midline, net, and paddle layers. (default black background) green stipple Increasing graphics layer priority white midline black net blue paddle 11/10/2018 M. Frank, EEL3705 Digital Logic, Fall 2006
Left Paddle Controller Circuit Comparator allows paddle y to be updated iff its new value is in the range [0,480−50] = [0,430] Adder increments/ decrements paddle y coordinate in direction determined by pushbutton #1 11/10/2018 M. Frank, EEL3705 Digital Logic, Fall 2006
Top-Level Circuit for Ping-Pong Game (so far) 11/10/2018 M. Frank, EEL3705 Digital Logic, Fall 2006
Demonstration of Game Display (so far) We can hook up the board directly to the lecture hall video projector in order to demonstrate the left paddle’s live functionality to the class… 11/10/2018 M. Frank, EEL3705 Digital Logic, Fall 2006
Ping-Pong Ball Sprite Design Planning the bitmap 1 Approx. on-screen appearance DEPTH = 10; WIDTH = 10; ADDRESS_RADIX = HEX; DATA_RADIX = BIN; CONTENT BEGIN 0 : 0001111000; 1 : 0111111110; 2 : 0111111110; 3 : 1111111111; 4 : 1111111111; 5 : 1111111111; 6 : 1111111111; 7 : 0111111110; 8 : 0111111110; 9 : 0001111000; END; ball_sprite.mif 11/10/2018 M. Frank, EEL3705 Digital Logic, Fall 2006
Still to do on ping-pong game… You might like to try some of these yourself! Add 2nd, red paddle on right, controlled by PB2 Create a ball object, implement game physics Adjust movement speeds for best playability Add a scoreboard using the 7-segment display Hook up an external speaker to the expansion bus and generate “beep” sounds when the ball bounces off a wall or a paddle or goes out of bounds Done except for red paddle movement 11/10/2018 M. Frank, EEL3705 Digital Logic, Fall 2006