Jump to content

Distraction


TheDoctor
 Share

Recommended Posts

Aki Dazrold

Ok, really. You aren't supposed to use force to take the dangéd cookie. I overlooked it a lot recently but now it seems like all you do now is smack somebody and steal it. This kinda kills the game.

And I beleive that long-winded explanation was a sufficient distraction in itself, so... *Yoink*

Link to comment
Share on other sites

is it okay to re-use an old distraction technique?

import pygame

from pygame.locals import *

import math


from input import button,drag_button

def dist(rect_a,rect_b):

    '''rect_a == top block to snap to

rect_b == bottom block to check'''

    return math.sqrt(((rect_a.midbottom[0]-rect_b.midtop[0])**2)+((rect_a.midbottom[1]-rect_b.midtop[1])**2))

class menu(object):

    def __init__(self):


        self.font = pygame.font.Font(None,48)


        self.clickable =[ (button((300,160)

                                ,self.font.render('start game',True,(0,0,255)).convert_alpha()

                                ,self.font.render('start game',True,(255,0,00)).convert_alpha()

                                ,self.font.render('start game',True,(0,255,0)).convert_alpha()

                                )

                            ,self.start

                         ),

                         (button((300,240)

                                ,self.font.render('credits',True,(0,0,255)).convert_alpha()

                                ,self.font.render('credits',True,(255,0,0)).convert_alpha()

                                ,self.font.render('credits',True,(0,255,0)).convert_alpha()

                                )

                            ,self.credits

                         )

                         ]

        self.dragable = [(drag_button((300,300)

                                ,self.font.render('drag me',True,(0,0,255)).convert_alpha()

                                ,self.font.render('drag me',True,(255,0,0)).convert_alpha()

                                ,self.font.render('drag me',True,(0,255,0)).convert_alpha()

                                )

                         )

                         ]

        self.receptical = []




        self.hub_img = self.font.render('mount me',True,(0,0,255)).convert_alpha()

        self.hub_rect = self.hub_img.get_rect()

        self.hub_rect.topleft = (500,200)



        self.surf = pygame.Surface((800, 600))

    def add_click_btn(self, btn, func):

        self.clickable.append(btn)


    def add_drag_btn(self, btn):

        self.dragable.append(btn)


    def add_receptical_btn(self,btn):

        self.receptical.append(btn)


    def events(self,events):

        for btn,func in self.clickable:

            var = btn.events(events)

            if var:

                func(btn)

        for btn in self.dragable:

            if btn.events(events):

                self.dragged(btn)

        for event in events:

            if event.type == MOUSEBUTTONUP and event.button == 1:

                print event.pos


    def draw(self,screen):

        for btn,func in self.clickable:

            btn.draw(screen)


        for btn in self.dragable:

            btn.draw(screen)


        screen.blit(self.hub_img,self.hub_rect)

        pygame.draw.rect(screen, (255,255,255), self.hub_rect, 1)



    def start(self,btn):

        print 'start clicked'

    def credits(self,btn):

        print 'credits clicked'

    def dragged(self,btn):

        print 'button dragged'


        d = dist(self.hub_rect,btn.rect)#find distance between midtop and midbottom

        print d

        if d < 15:

            btn.rect.midtop=self.hub_rect.midbottom



if __name__=='__main__':

    pygame.init()

    screen = pygame.display.set_mode((800, 600))


    me = menu()



    while True:

        pygame.time.wait(10)


        screen.fill((0, 0, 0))

        events = pygame.event.get()

        for event in events:

            if event.type == QUIT or (event.type == KEYDOWN and event.key == K_ESCAPE):

                pygame.quit()

                import sys

                sys.exit()

        me.events(events)

        me.draw(screen)


        pygame.display.flip()

*MINE*

Link to comment
Share on other sites

*punches Sonic for breaking the rule saying you can't controll other players*

*hits Zjean over the head with a shoe*

*takes cookie*

Link to comment
Share on other sites

*punches Sonic for breaking the rule saying you can't controll other players*

*hits Zjean over the head with a shoe*

*takes cookie*

You Just DON'T FUGGING GET IT, DO YOU?

The Rules State

The Cookie Is To Be Taken Through NON-VIOLENT MEANS!

GET IT?

Link to comment
Share on other sites

Erm, you can't use force... you must distract the person.

Anyway, Look an even bigger cookie over by the fountain! *grabs cookie out of your hand and runs*

As LZ said not but a few posts ago...

And Zephyr just said...

Oh and hey, a cookie.

Link to comment
Share on other sites

Aki Dazrold

I devour that Tabasco-cookie! And I do it in a very flashy manner!

Whilst you behold this spectacle, a shadow clone of me swipes the real cookie back.

Link to comment
Share on other sites

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.