o jogo (m k d i r ) Crie um arquivo g a m e . r b r e q u i r e ' g o s u ' c l a s s G a m e < G o s u : : W i n d o w d e f i n i t i a l i z e s u p e r ( 6 0 0 , 6 0 0 , f a l s e ) e n d e n d g a m e = G a m e . n e w g a m e . s h o w 3 / 19
@ b a c k g r o u n d = G o s u : : I m a g e . n e w ( s e l f , " i m a g e s / b g . p n g " , t r u e ) s e l f Referência ao seu objeto, instância de Game. Cada imagem no Gosu deve estar relacionada com uma Janela (Window). d e f i n i t i a l i z e s u p e r ( 6 0 0 , 6 0 0 , f a l s e ) s e l f . c a p t i o n = ' S k y C l e a n u p ' @ b a c k g r o u n d = G o s u : : I m a g e . n e w ( s e l f , " i m a g e s / b g . p n g " , t r u e ) e n d 9 / 19
i r e _ r e l a t i v e ' p l a n e ' c l a s s P l a n e d e f i n i t i a l i z e ( g a m e ) @ g a m e = g a m e @ x = 1 0 0 @ y = 1 0 0 @ s p r i t e = G o s u : : I m a g e . l o a d _ t i l e s ( g a m e , " i m a g e s / p l a n e s . p n g " , 6 6 , 6 7 , t r u e ) [ 0 . . 2 ] e n d d e f d r a w s p r i t e = @ s p r i t e [ G o s u : : m i l l i s e c o n d s / 1 0 0 % @ s p r i t e . s i z e ] s p r i t e . d r a w _ r o t ( @ x , @ y , 1 , 0 ) e n d e n d gist 12 / 19
t i a l i z e s u p e r ( 6 0 0 , 6 0 0 , f a l s e ) # . . . @ p l a n e = P l a n e . n e w ( s e l f ) e n d d e f d r a w @ p l a n e . d r a w @ b a c k g r o u n d . d r a w ( 0 , 0 , 0 ) e n d 13 / 19
e f u p d a t e @ p l a n e . l e f t i f b u t t o n _ d o w n ? G o s u : : K b L e f t @ p l a n e . r i g h t i f b u t t o n _ d o w n ? G o s u : : K b R i g h t e n d 15 / 19
t e r o i d d e f i n i t i a l i z e ( g a m e ) @ s p r i t e = G o s u : : I m a g e . l o a d _ t i l e s ( g a m e , " i m a g e s / a s t e r o i d s . p n g " , 3 2 0 / 5 , 3 8 4 / 6 , t r u e ) @ x , @ y = 1 0 0 , 1 0 0 e n d d e f u p d a t e e n d d e f d r a w s p r i t e = @ s p r i t e [ G o s u : : m i l l i s e c o n d s / 5 0 % @ s p r i t e . s i z e ] s p r i t e . d r a w _ r o t ( @ x , @ y , 3 , 0 ) e n d e n d Alterando a classe Game: d e f i n i t i a l i z e @ a s t e r o i d = A s t e r o i d . n e w ( s e l f ) e n d d e f u p d a t e @ a s t e r o i d . u p d a t e e n d d e f d r a w @ a s t e r o i d . d r a w e n d 17 / 19
numa posição randômica, utilizando Gosu.random(?, ?) Ao sair da tela, deve voltar para o topo em outra posição. Colisão! Exemplo: Gosu::distance(a.x, a.y, b.x, b.y) < distance Verificar durante udpate Adicionar um asteróide a cada 10 segundos Gosu::milliseconds 18 / 19