On 23 Zář, 23:07, "Drew Smathers" <[EMAIL PROTECTED]> wrote:
> On Tue, Sep 23, 2008 at 12:20 PM, Dany0 <[EMAIL PROTECTED]> wrote:
>
> > this is da images:
> >http://www.wikiupload.com/download_page.php?id=61430
> > this is da code:
>
> > from pyglet import window
> > from pyglet import image
>
> > win = window.Window()
>
> > win.set_mouse_visible(False)
>
> > @win.event
> > def set_fullscreen(self, fullscreen=True, screen=None):
> >       pass
>
> > class background:
> >    img = image.load('background.bmp')
>
> > class gun:
> >    gun_img = image.load('gun.bmp')
> >    x = 0
> >    y = 0
>
> > class bullet:
> >    img = image.load('bullet.bmp')
> >    x = gun.x+10
> >    y = gun.y
>
> > @win.event
> > def on_mouse_motion(x, y, dx, dy):
> >     gun.x = x
> >     gun.y = y-22
>
> > @win.event
> > def on_mouse_release(x, y, button, modifiers):
> >    bullet.img.blit(bullet.x, bullet.y)
>
> > while not win.has_exit:
> >    win.dispatch_events()
> >    win.clear()
> >    background.img.blit(1,1)
> >    gun.gun_img.blit(gun.x, gun.y)
> >    win.flip()
>
> There are so many problems with your code, but I'll focus only on the
> mechanical issues:
>
> 1.  You blit a bullet on mouse release - why?  This means you will
> never see the bullet - the event occurs in dispatch_events() which is
> before clearing, redrawing and flipping the display.
>
> 2. Though I'm not sure, I have the suspicion you're assuming there is
> an invariant relation between the position of the bullet and the
> position of the gun.  There is no such thing.  Lucky for me, Python
> isn't that mind-warping.  You likely want to set the bullet's position
> in on_mouse_release.
>
> Finally, you should read more about 
> classes:http://docs.python.org/tut/node11.html.  Currently you're using
> classes simply for global state - you don't need classes to do that.
aha, so. what am I supposed to do?:(
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pyglet-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to