Mekire's Profile User Rating: -----

Reputation: 117 Stalwart
Group:
Active Members
Active Posts:
217 (0.31 per day)
Joined:
11-January 13
Profile Views:
15,230
Last Active:
User is offline Dec 18 2014 03:09 AM
Currently:
Offline

Previous Fields

Country:
Who Cares
OS Preference:
Who Cares
Favorite Browser:
Who Cares
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Who Cares
Your Car:
Who Cares
Dream Kudos:
0
Icon   Mekire has not set their status

Posts I've Made

  1. In Topic: pygame tkinter mouse freezing

    Posted 16 Dec 2014

    Although it is possible to use pygame and tkinter together, they really don't play nicely. If you are just trying to get user text input you would be better off just using pygame.
    https://github.com/M.../pygame-textbox

    If you are set on using tkinter, please supply a short runnable example that recreates your problem and I'll see if I can help.

    -Mek
  2. In Topic: 'click' event in pygame isn't working

    Posted 14 Dec 2014

    I don't much like pygbutton (nor should you expect pygame programmers to use or even be aware of it) but anyway.

    This is a minimal example that shows that the button is working as expected.
    Does this work for you?

    import sys
    import pygame as pg
    import pygbutton
    
    
    pg.init()
    screen = pg.display.set_mode((500,500))
    clock = pg.time.Clock()
    
    button = pygbutton.PygButton((200, 200, 100, 30), "Register")
    
    done = False
    while not done:
        for event in pg.event.get():
            if event.type == pg.QUIT:
                done = True
            elif 'click' in button.handleEvent(event):
                print("Button pressed.")
    
        screen.fill(pg.Color("darkslategray"))
        button.draw(screen)
        pg.display.update()
        clock.tick(60)
    
    pg.quit()
    sys.exit()
    
  3. In Topic: Need help implementing a health bar to my game (PYGAME)

    Posted 28 Nov 2014

    There are a couple things here that may prevent you from getting assistance.
    You haven't provided any of the graphics which your program relies on.
    You are also using some modules that are not a standard part of pygame.
    People need to be able to run your program in order to provide assistance.

    Also, I know you don't want to hear this but, it is either time to go learn about classes; or at the very least, time to learn how to write good functions. When you stuff so much in a single function you completely defeat the point of even having one. You have probably heard, "don't use global variables," before. Well, when you have large functions you are still using global variables. If I put a function around my entire program it isn't avoiding any of the issues that you would have if they were actually global.

    If you can get a runnable example up (most preferably in git repo form) I will try and work with the code you have. But, you are going to hit a point very soon where your program is just too complex and convoluted to continue with this approach. I think your time would be better served by stepping back and learning about classes.

    You can find some basic pygame examples that use classes in my repo here:
    My pygame samples.
    If you start with this one you can see what a really simple pygame with classes would look like:
    Color change.
    Specifically note the length of each function.

    -Mek
  4. In Topic: Structure of a game - pygame

    Posted 2 Jul 2014

    To cleanly implement a game with multiple scenes you will need some sort of scene manager. This can be implemented as a FSM or PDA, but knowing about that isn't really critical at this point.

    Here is a fairly bare bones scene manager example:
    https://github.com/M...late-with-movie
    Be aware that this is probably quite a jump from your current level.

    As for your current code, I still think you need to really get yourself used to how rects work. Play around with them in the interactive interpreter until you are really comfortable with them. Understanding them really is key to working with pygame. Also I'm not sure why you are defining your classes inside another function. Typically the only time you would do this would be if the function was a class factory, and in your case it is not. Also, you should work on getting your main loop out of the global namespace.

    -Mek
  5. In Topic: Sprites collision

    Posted 30 Jun 2014

    Quote

    Without x and y how can I specify position of the sprite?

    The rect is the position of your sprite.
    >>> import pygame as pg
    >>> a = pg.Rect(0, 0, 50, 50)
    >>> a
    <rect(0, 0, 50, 50)>
    >>> a.topleft
    (0, 0)
    >>> a.x += 10
    >>> a
    <rect(10, 0, 50, 50)>
    >>> a.y += 15
    >>> a
    <rect(10, 15, 50, 50)>
    >>> a.topleft = (25, 25)
    >>> a
    <rect(25, 25, 50, 50)>
    

    The reason it is only working in the top corner is because your rects have the coordinates (0,0), because as I said, you never move it.

    -Mek

My Information

Member Title:
D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Location:
Amakusa, Japan

Contact Information

E-mail:
Private

Comments

Page 1 of 1
  1. Photo

    RetroGamer Icon

    13 Dec 2013 - 10:48
    Thanks man for the help awesome work!
Page 1 of 1