oop - draw new object onto existing canvas in Scheme using paint-callback -


In some background, I am creating Space Invaders as a project in a CS class. Currently I am working on making the player ship shoot projectile, I am not worried about conflicts, just creating projectiles.

  (define projectile% (class object% (init-field [image (make-bitmap 10) 10 x 10] [x 100] [or 100] [speed1]) ( Defined / public (image) (defined / private (move-up) (set! Y (- y motion))) (define / translate DC (+ x (/ w2)) (+ (send to dd) (Presenting DC (DC) ((W (send image received-width)) (H (image get-height send) DC dot-bitmap image (- (/ (2/22)) (- (/ H2 )) Send (DC Translation (- (+ (X (/ 2W)) (- (+ Y (/ h2)))) Define (player-ship%) (class-object% (init-field [image (make-bitmap 30 25)] [x 400] [y 300] [speed 3]) (defined) / Public (received-image) image (defined / public (X-X) x) (defined / public (received-y) y) (defined / private (project) projectile (defined here / public (presenting to DC) ) (Let's send (image received-width) (H (image get-height send)) (Send DC translation (+ x (/ w2)) (+ Y ( / H2))) (DC Draw-BitM Send AP Image (- (/ (2/2/2)) (- (/ h2)) (DC translate (- (+ (x (/ 2 air)) (- (+ y (/ h2))))) (defined / public (key-down key-code) (cond ((equals? Key-code 'left) (move-left)) ((equals? Key-code' right) (move-right)) ((equals? Key-code 'up) (shoot)))) (super-new)) )   

These are both relevant classes, some unsuccessful code to throw some throwers.

How do I pull the window and stuff:

P>

  (My Game Canvas * (New Game Canvas% [Parents * Game-Window * ] Define [color-callback (lambda (canvas DC) (get started (send my ship) (send key-code key-code) (if () (DC) is not (equivalent? Key-code 'release) ) (Send my-ship key-down key-code)))))) (Define * My timer * (New timer% [Notify-callback (lambda (send * My- MEMSHIP * REFRESH)))) (Send-ship-projectile * Send-image) * Create a projectile so that they are working or not (send make-ship) * Mai-ship * Receive-image))   

Make-Ship and make-ship-projectile functions work as follows:

  (define SHIP-projectile bitmap - Target (DC (new bitmap-DC% [bitmap bitmap-target]) (Send DC set-brush (May Object brush% "black" 'solid)) (send DC draw-lipress 0 10 10)))   

The problem occurs when I have a I try to throw new, it just does not work. I am currently under the impression that this is not working due to the new project, is not in the paint-callback of my game canvas However, I do not know how to update that feature. Am I delivering it from the wrong direction?

Yes, if the throwing drawing is not triggered color-callback (Or again called another function / method), it will not be displayed in canvas if fresh in canvas.

There is a possibility that a list is present in the projectile (possibly player-ship% is a feature), and trigger the color-callback (possibly A different method in player-ship% 's render method, or player-ship% in render-projectile Through the call from the paint-callback ) the display of all these projectiles in the canvas. When a new throwing ship is shot, then it should be added to the list of existing projectiles and when the throwing hits or hits the board, it should be removed from the list.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -