Python Forum
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
candy crush game
#1
hello i was previously trying to make a candy crush game in python here is the code, for some reason it is not working properly.

def initializegrid(board) :
    for i in range(8) :
        for j in range(8) :
            board[i][j] = choice(['q', "r", "s", 'u', "t"])

def initialize(board) :
    initializegrid(board)
    global score
    score = 0
    global turn
    turn = 1

def continuegame(current_score, goal_core = 100) :
    if (current_score >= goal_score):
        return False
    else:
        return True
def drawboard(board):
    linetodraw=""
    print("\n\n\n")
    print("----------------------------------")
    for i in range(7,-1,-1):
        linetodraw=""
        for j in range(8):
            linetodraw += " | " + board[i][j]
        linetodraw+= " |"
        print("line to draw")
        print("----------------------------------")
def getmove():
    print("getting move")
    return"blu"
def Update(board, move):
    print("updating board")
def doround(board):
    drawboard(board)
    move = getmove()
    Update(board, move)
    global turn
    turn += 1
score = 100
turn = 100
goalscore = 100
board = [[0, 0, 0, 0, 0, 0, 0, 0],
         [0, 0, 0, 0, 0, 0, 0, 0],
         [0, 0, 0, 0, 0, 0, 0, 0],
         [0, 0, 0, 0, 0, 0, 0, 0],
         [0, 0, 0, 0, 0, 0, 0, 0],
         [0, 0, 0, 0, 0, 0, 0, 0],
         [0, 0, 0, 0, 0, 0, 0, 0],
         [0, 0, 0, 0, 0, 0, 0, 0]]
def initializegrid(board) :
    print("initializing grid")
def drawboard(board) :
    print("drawing board")



def doround() :
    print("hello")
for i in range(100):
    i+=1
    print(i)
Reply
#2
(Aug-02-2018, 04:46 PM)asaa12345 Wrote: for some reason it is not working properly
Could you be more specific? Is there a traceback you can provide, or behavior that you can describe precisely?
Reply
#3
yes you see the objective of the program was to draw a grid which would ideally have letters in it the letters would then exchange places when we would click them,however the code won't function, all it does is count to 100 and then stop all of a sudden
Reply
#4
All your code does is define functions and count to 100. You don't call any of your functions. You need to call them.

As a comment on your process - as a new programmer, you should be testing very line or every few lines of code. Writing tens of lines and having it not work often makes it a pain to diagnose problems, in particular identifying where a problem is. If you add a line or so of code and a problem pops up, you know it's either the new code or somewhere that that code interacts with.
Reply
#5
All it does is counts to 100. Angry
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020