Wednesday, February 16, 2011

Color Tower Defense 2.11

This update will be pretty much all bug fixes. Thanks to all the people who have tested Color Tower Defense 2.0 I have got a lot of feedback. Heres some of the issues that have showed up.


Incorrect map loading
Infinite money glitch *see bellow
Infinite game loop depth *see bellow
balancing issues


all of which will be fixed in the 2.11


-----*Infinite money glitch-----
I think this is pretty funny :) I never thought I would have this happen to me. Generally speaking, infinite money glitches are very sought after and result in a lot of google searches. It's because this is a glitch that people like. I mean, I think its cool! After you go play and experience everything the game has to offer, you search infinite money glitch and it opens up all this crazy new stuff.


this glitch happens if you sell a tower more than one time. Heres the code before I fixed the glitch:

elif event.key in [pygame.K_4, pygame.K_s]:
    if not placing_tower:
        if turret_selected:
            turret_selected.sell(player)
                game_map.set_collision(turret_selected.rect.center, 'open') # open the tile


And here is after I fixed the glitch






elif event.key in [pygame.K_4, pygame.K_s]:
    if not placing_tower:
        if turret_selected:
            turret_selected.sell(player)
            turret_selected = None
                game_map.set_collision(turret_selected.rect.center, 'open') # open the tile


As you can see, the only change is that turret_selected is set to none. Before I fixed it, You could basically sell the same tower multiple times. But obviously, it was a pretty easy fix.


-----*infinite game loop depth-----


this is how I used to set up the menu hierarchy


def start_game():
    def pick_map():


        def start_gameplay():


            # main loop stuff


            if user_wants_to_pick_map:
                pick_map()


            if user_wants_to_start_over:
                start_game()


        start_gameplay()
    pick_map()
start_game()


so theoretically, you could play the game, pick a new map, continue to play the game, pick a new map, continue to play the game, pick a new map... You get the idea.


The bottom line is, that this way worked, but It was a terrible way to do it. Here is an example of an error you could get.


-------------------------------------------------------------------



Traceback (most recent call last):
  File "/Users/student/Desktop/Color Tower Defense/Scripts/Color Tower Defense.py", line 722, in <module>
    main()
  File "/Users/student/Desktop/Color Tower Defense/Scripts/Color Tower Defense.py", line 715, in main
    start_main_menu()
  File "/Users/student/Desktop/Color Tower Defense/Scripts/Color Tower Defense.py", line 713, in start_main_menu
    start_map_select()
  File "/Users/student/Desktop/Color Tower Defense/Scripts/Color Tower Defense.py", line 678, in start_map_select
    start_main_menu()
  File "/Users/student/Desktop/Color Tower Defense/Scripts/Color Tower Defense.py", line 713, in start_main_menu
    start_map_select()
  File "/Users/student/Desktop/Color Tower Defense/Scripts/Color Tower Defense.py", line 678, in start_map_select
    start_main_menu()
  File "/Users/student/Desktop/Color Tower Defense/Scripts/Color Tower Defense.py", line 713, in start_main_menu
    start_map_select()
  File "/Users/student/Desktop/Color Tower Defense/Scripts/Color Tower Defense.py", line 575, in start_map_select
    info_bar.display_info(build_turret_button.turret_type, 'upgrade info', False)
  File "/Users/student/Desktop/Color Tower Defense/Scripts/HUDs.py", line 69, in display_info
    if self.displaying_message == False: # if nothing is already displaying, then we can display something new
AttributeError: 'Info_Bar' object has no attribute 'displaying_message'


-------------------------------------------------------------------

This error message basically says:

*in a intelligent voice, robot like voice.
inside of the main game, inside of the main menu, inside of the map selection screen, inside of the main menu, inside of the map selection screen, inside of the main menu, inside of the map selection screen, there is an error on line 69 of the HUD module.

Haha, Thats really ridiculous.

Anyways the new way i'm doing it involves while loops


running_program = True
running_map_selection = True
running_main_loop = True

while running_program:
    while running_map_selection:
        while running_main_loop:
          
            #main loop stuff
            if user_wants_to_pick_map:
                running_main_loop = False
              
            if user_wants_to_start_over:
                running_main_loop = False
                running_map_selection = False
          
            if user_quits:





                running_main_loop = False
                running_map_selection = False
                running_program = False


It actually works very well, and was easy to change all my code over to fit this new model. Im happy with it.

ANYWAYS.

Color Tower Defense 2.11 is coming out soon. Stay tuned!

1 comment:

  1. Josh, it cracks me up to get a glimpse of programming humor!:)

    ReplyDelete