Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rapt pygame program runs EXTREMELY slow. #80

Closed
Pololot64 opened this issue Sep 10, 2017 · 25 comments
Closed

Rapt pygame program runs EXTREMELY slow. #80

Pololot64 opened this issue Sep 10, 2017 · 25 comments

Comments

@Pololot64
Copy link

My program runs extremely slow

@mclaughlinconnor
Copy link

Can you link to your code. Share an APK. Anything?

"My code runs slow" is not helpful to anyone.

@Pololot64
Copy link
Author

Pololot64 commented Sep 14, 2017

Here is the apk: https://www.dropbox.com/s/0eta3pkv3hpd927/Jeweled-1.7-release.apk?dl=0. I removed many features to make it faster but it is still slow. Since I removed some features it is a little buggy so you might have to launch it several times to make it work. Here is the draw grid function. It draws lines and the background though I commented out the line. There is some leftover non-working code:
`def draw_grid(canvas):
global WIDTH, HEIGHT, s_num, mode_text, blits, full_button, speed_mode, back_num, pause_image, level, background, mode_rect, score_text, score_rect, time_text, time_rect, smooth, eras, mode_old, time_old, score_old, multiple, orientation, gem_size, grid_pos, cell_size, gem_offset, dark, logob, light_size, score, seconds, mode, lighter
fillo = canvas.fill((0, 0, 0))
blits.append(fillo)
if orientation == "landscape":
grid_height = HEIGHT - 2 * (HEIGHT / multiple)
grid_width = grid_height
grid_size = [grid_width, grid_height]
cell_width = (grid_size[0] / multiple)
cell_height = (grid_size[1] / multiple)
grid_pos = [(0.50 * WIDTH), (cell_height + cell_height) / 2]

        if True:
            while (cell_height + grid_height) > HEIGHT:
                cell_height *= 0.99
                grid_width = grid_height
                grid_size = [grid_width, grid_height]
                cell_width = (grid_size[0] / multiple)
                cell_height = (grid_size[1] / multiple)
            grid_pos = [(0.50 * WIDTH) - cell_width, (HEIGHT - grid_size[1]) / 2]
                
            grid_pos = [(0.50 * WIDTH), (HEIGHT - grid_size[1]) / 2]
            logo_pos = [0, grid_pos[1] - cell_size[1]]
            while grid_pos[0] + grid_size[0] >= WIDTH:
                grid_pos[0] -= 1
        
        score_board_size = [ WIDTH - int(WIDTH - grid_pos[0]), HEIGHT]
        score_board_pos = (0, 0)
        logo_size = [score_board_size[0], score_board_size[0] / 3]
        logo = pygame.transform.scale(logob, logo_size)
        score_box_size = [int(score_board_size[0]) - int(score_board_size[0] /3), int(HEIGHT / 2)]
        #################
        score_box_pos = [cell_size[0], int(HEIGHT / 2) - int(score_box_size[1] / 2)]
        score_pos = [score_box_pos[0], score_box_pos[1] + 20]
        
        seconds_pos = [score_pos[0], score_pos[1] + 35]
        mode_pos = [score_pos[0], seconds_pos[1] + 35]
        
        #score_pos = [0, score_box_pos[1] + 30]
        lighter_pos = [score_board_size[0], 0]
    if orientation == "portrait":
        grid_height = WIDTH
        grid_width = grid_height
        grid_size = [grid_width, grid_height] 
        cell_width = (grid_size[0] / multiple)
        cell_height = cell_width
        v = 2
        grid_pos = [0, (v * (cell_height))]
        #print grid_width
        
        if (v * cell_height + grid_size[1]) > HEIGHT - 5:
            #print "recal"
            v = 2
            cell_height -= 1
            cell_width = cell_height
            grid_height = WIDTH - 2 * (HEIGHT / multiple)
            grid_width = grid_height
            grid_size = [grid_width, grid_height]
            cell_width = (grid_size[0] / multiple)
            cell_height = (grid_size[1] / multiple)
        
        cell_width = (grid_size[0] / multiple)
        cell_height = cell_width
        cell_size = [cell_width, cell_height]
        grid_pos = [((WIDTH / 2) - (grid_size[0]) / 2), v * (cell_height)]
        #print WIDTH - grid_size[0]
        lv = v
        
        logo_size = [3 * (lv * (cell_height)), int(lv * (cell_height))]
        logo = pygame.transform.scale(logob, logo_size)
        logo_pos = [(WIDTH - logo_size[0]) / 2, 0]
        
    
        
    dark_size = [cell_width, cell_height]
    cell_size = [cell_width, cell_height]
    gem_size = [int(cell_width - (0.3 * cell_width)), int(cell_height - (0.3 * cell_height))]
    gem_offset = 0.5 * (0.3 * cell_width)
    grid_size = [grid_width, grid_height]
    
    cube_list = [(grid_pos[0], grid_pos[1]),
                 (grid_pos[0] + (multiple * cell_size[0]), grid_pos[1]),
                 (grid_pos[0] + (multiple * cell_size[0]), (grid_pos[1] + (multiple * cell_size[1]))),
                 (grid_pos[0], (grid_pos[1] + (multiple * cell_size[1])))]
    
        
    
    score_bar = [(grid_pos[0], (grid_pos[1] + (multiple * cell_size[1]) + 5)), (grid_pos[0] + (seconds/60) * grid_size[0], (grid_pos[1] + (multiple * cell_size[1]) + 5))]
    #print WIDTH
    
    #elif WIDTH < 350:
        #text_size = 12
    #else:
        #text_size = 24
    if mode == "normal":
        mode1 = str(mode) + ": " + str(level)
    else:
        mode1 = str(mode)
    seconds1 = "Time: " + str(seconds)
    if mode == "normal":
        score1 = "Score: " + str(score)
    else:
        score1 = "Score: " + str(score)
    #print "done"
    white = (255, 255, 255)
    black = (0, 0, 0)
    if mode1 != mode_old:
        mode_text = eras.render(str(mode1), True, white)
        mode_rect = score_text.get_rect()
        mode_old = mode1
    if score1 != score_old:
        score_text = eras.render(str(score1), True, white)
        score_rect = score_text.get_rect()
        score_old = score1
    if seconds1 != time_old:
        time_text = eras.render(str(seconds1), True, white)
        time_rect = time_text.get_rect()
        time_old = seconds1
    

        
    
    
    if False == True:
        areas = (grid_pos[0], grid_pos[1], grid_pos[0] + grid_size[0], grid_pos[1] + grid_size[1])
        if back_num == 0:
            #print len(smooth), s_num
            
            if s_num < len(smooth):
                canvas.blit(smooth[s_num], (0, 0))
            else:
                s_num = 0
                canvas.blit(smooth[s_num], (0, 0))
        else:
            canvas.blit(background, (0, 0))
            
    #print grid_size, ((multiple * cell_size[0]), (multiple * cell_size[1])),
    if orientation == "landscape":
        dark = pygame.transform.scale(dark, ((multiple * cell_size[0]), (multiple * cell_size[1])))
        cube2 = [(grid_pos[0] + (multiple * cell_size[0]), (grid_pos[1] + (multiple * cell_size[1]))),
             (grid_pos[0] + (multiple * cell_size[0]), (grid_pos[1] + (multiple * cell_size[1])) + 10),
             (grid_pos[0], (grid_pos[1] + (multiple * cell_size[1]) + 10)),
             (grid_pos[0], (grid_pos[1] + (multiple * cell_size[1])))]
    elif orientation == "portrait":
        dark = pygame.transform.scale(dark, (cell_width * multiple, cell_height * multiple))
        #print grid_pos[0], grid_size[0] - WIDTH, WIDTH
        #pygame.draw.line(canvas, (65, 65, 65), (grid_pos[0] + grid_size[0], grid_pos[1]), (grid_pos[0] + grid_size[0], (grid_pos[1] + grid_size[1])), 1)
        #pygame.draw.line(canvas, (65, 65, 65), (grid_pos[0], (grid_pos[1] + grid_size[1])), (grid_pos[0] + grid_size[0], (grid_pos[1] + grid_size[1])), 1)
        #print "w" + str(WIDTH)
        grid_pos[0] = (WIDTH / 2) - cell_width * 4
        cube2 = [(grid_pos[0] + (multiple * cell_size[0]), (grid_pos[1] + (multiple * cell_size[1]))),
             (grid_pos[0] + (multiple * cell_size[0]), (grid_pos[1] + (multiple * cell_size[1])) + 10),
             (grid_pos[0], (grid_pos[1] + (multiple * cell_size[1]) + 10)),
             (grid_pos[0], (grid_pos[1] + (multiple * cell_size[1])))]
    
        
    darki = canvas.blit(dark, grid_pos)
    blits.append(darki)
    if mode == "speed":
        cubist1 = [grid_pos[0], (grid_pos[1] + (multiple * cell_size[1]) + 5)]
        cubist2 = [grid_pos[0] + (float(seconds) / 60.0) * grid_size[0], (grid_pos[1] + (multiple * cell_size[1]) + 5)]
        
            
    elif mode == "normal":
        cubist1 = [grid_pos[0], (grid_pos[1] + (multiple * cell_size[1]) + 5)]
        cubist2 = [grid_pos[0] + (float(score) / (level * 500)) * grid_size[0], (grid_pos[1] + (multiple * cell_size[1]) + 5)]
        
    
    if mode == "normal":
        goal = level * 500
        if score == 0:
            sc = 1
        if score > 0:
            sc = score
        #print sc,  goal
        score_color = int((float(sc) / float(goal)) * 255)
        if score_color > 255:
            score_color = 255
        color = [255 - score_color, 0, int(score_color)]
        #print score_color
        if cubist2[0] - cubist1[0] > 10 and cubist2[0] - cubist1[0] < grid_size[0]:
            lineo = pygame.draw.lines(canvas, (65, 65, 65), True, cube2, 1)
            linna = pygame.draw.line(canvas, color, cubist1, cubist2, 9)
        
    if mode == "speed":
        if seconds > 10:
            color = [10, 150, 10]
            
        if seconds <= 10:
            color = [150, 10, 10]
        if not lost:
            linno = pygame.draw.lines(canvas, (65, 65, 65), True, cube2, 1)
            linna = pygame.draw.line(canvas, color, cubist1, cubist2, 9)
        
    if orientation != "square":
        
        
        if orientation != "portrait":
            #s = pygame.Surface(score_board_size)  
            #s.set_alpha(128)                
            #s.fill((255,255,255))           
            #canvas.blit(s, (0,0)) 
            #dark = pygame.transform.scale(dark, score_board_size)
            #canvas.blit(dark, score_board_pos)
            #dark = pygame.transform.scale(dark, score_box_size)
            #canvas.blit(dark, score_box_pos)
            lina = pygame.draw.line(canvas, (65, 65, 65), [grid_pos[0], 0], [grid_pos[0], HEIGHT], 1)
            blits.append(lina)
            #score
            score_rect.topleft = score_pos
            scoro = canvas.blit(score_text, score_rect)
            blits.append(scoro)
            time_rect.topleft = seconds_pos
            timeo = canvas.blit(time_text, time_rect)
            blits.append(timeo)
        
            mode_rect.topleft = mode_pos
            modeo = canvas.blit(mode_text, mode_rect)
            blits.append(modeo)
            #lighter = pygame.transform.scale(lighter, (WIDTH - lighter_pos[0], HEIGHT))
            #canvas.blit(lighter, lighter_pos)
            
        if orientation == "portrait":
            #s = pygame.Surface(score_board_size)  
            #s.set_alpha(128)                
            #s.fill((255,255,255))           
            #canvas.blit(s, (0,0)) 
            #dark = pygame.transform.scale(dark, score_board_size)
            #canvas.blit(dark, score_board_pos)
            #dark = pygame.transform.scale(dark, score_box_size)
            #canvas.blit(dark, score_box_pos)
            #pygame.draw.line(canvas, (65, 65, 65), [grid_pos[0], 0], [grid_pos[0], HEIGHT], 1)
            #score
            text_height = grid_pos[1] - score_text.get_height() - 5
            score_rect.topleft = [10, text_height]
            scoro = canvas.blit(score_text, score_rect)
            blits.append(scoro)
            
            time_rect.topleft = [(WIDTH / 2) - (time_text.get_width() / 2), text_height]
            timeo = canvas.blit(time_text, time_rect)
            blits.append(timeo)
            mode_rect.topleft = [WIDTH - mode_text.get_width() - 10, text_height]
            modeo = canvas.blit(mode_text, mode_rect)
            blits.append(modeo)
            #lighter = pygame.transform.scale(lighter, (WIDTH - lighter_pos[0], HEIGHT))
            #canvas.blit(lighter, lighter_pos)
            
        loog = canvas.blit(logo, logo_pos)
        blits.append(loog)
    #print dark.get_width(), dark.get_height()
    if orientation == "landscape":
        current_width = grid_pos[0]
        for w in range(multiple + 1):
            lineo = pygame.draw.line(canvas, (65, 65, 65), [current_width, grid_pos[1]], [current_width, grid_pos[1] + (cell_height * multiple)], 1)
            current_width += (grid_size[0] / multiple)
            blits.append(lineo)
        current_height = grid_pos[1]
        for h in range(multiple + 1):
            lineo = pygame.draw.line(canvas, (65, 65, 65), [grid_pos[0], current_height], [grid_pos[0] + (cell_width * multiple), current_height], 1)
            current_height += grid_size[1] / multiple
            blits.append(lineo)
    if orientation == "portrait":
        current_width = grid_pos[0]
        for w in range(multiple + 1):
            lineo = pygame.draw.line(canvas, (65, 65, 65), [current_width, grid_pos[1]], [current_width, grid_pos[1] + multiple * cell_width], 1)
            current_width += dark.get_width() / multiple
            blits.append(lineo)
        current_height = grid_pos[1]
        for h in range(multiple + 1):
            lineo = pygame.draw.line(canvas, (65, 65, 65), [grid_pos[0], current_height], [grid_pos[0] + cell_height * multiple, current_height], 1)
            current_height += cell_height
            blits.append(lineo)`

@Pololot64
Copy link
Author

Draw gem function. Draws gems:
`def draw_gems(canvas, gem_board):

    global gem_size, grid_pos, WIDTH, HEIGHT, multiple, one, two, three, four, five, six, cell_size, gem_offset, old_board, blits
    #print "draw gems"
    pos = [0, 0]
    #draw_grid(canvas)
    grid_pos2 = [(grid_pos[0]) + gem_offset, (grid_pos[1]) + gem_offset]
    for h in range(multiple):
        for w in range(multiple):
            #canvas.blit(five, pos)
            if h == 0:
                pos[1] = grid_pos2[1]
            if w == 0:
                pos[0] = grid_pos2[0]

            if h == 1:
                pos[1] = grid_pos2[1] + cell_size[1]
            if w == 1:
                pos[0] = grid_pos2[0] + cell_size[0]
                
            if h == 2:
                pos[1] = grid_pos2[1] + 2 * cell_size[1]
            if w == 2:
                pos[0] = grid_pos2[0] + 2 * cell_size[0]
                
            if h == 3:
                pos[1] = grid_pos2[1] + 3 * cell_size[1]
            if w == 3:
                pos[0] = grid_pos2[0] + 3 * cell_size[0]

            if h == 4:
                pos[1] = grid_pos2[1] + 4 * cell_size[1]
            if w == 4:
                pos[0] = grid_pos2[0] + 4 * cell_size[0]

            if h == 5:
                pos[1] = grid_pos2[1] + 5 * cell_size[1]
            if w == 5:
                pos[0] = grid_pos2[0] + 5 * cell_size[0]
                
            if h == 6:
                pos[1] = grid_pos2[1] + 6 * cell_size[1]
            if w == 6:
                pos[0] = grid_pos2[0] + 6 * cell_size[0]
                
            if h == 7:
                pos[1] = grid_pos2[1] + 7 * cell_size[1]
            if w == 7:
                pos[0] = grid_pos2[0] + 7 * cell_size[0]
            #if (old_board[h])[w] != (gem_board[h])[w]:    
            if (gem_board[h])[w] == "1":
                gemo = canvas.blit(one, pos)
            elif (gem_board[h])[w] == "2":
                gemo = canvas.blit(two, pos)
            elif (gem_board[h])[w] == "3":
                gemo = canvas.blit(three, pos)
            elif (gem_board[h])[w] == "4":
                gemo = canvas.blit(four, pos)
            elif (gem_board[h])[w] == "5":
                gemo = canvas.blit(five, pos)
            elif (gem_board[h])[w] == "6":
                gemo = canvas.blit(six, pos)`

@Pololot64
Copy link
Author

Gem fall function. The program is slow when the gems are falling:
`def fall(temp_board, first):
global gem_board, canvas, gems, FPS, fall_tick, SFX, speed_mode, blits
temp_board = copy.deepcopy(temp_board)
inside = True
did = 0
gemed = False
#print "fall"
while inside == True:
#print "bb"
for h in (range(len(temp_board))):
if temp_board[h].count("n") > 0:
for w in range(len(temp_board)):
#print w, h
if (temp_board[h])[w] == "n" and h != 0:
#print "ya!"
(temp_board[h])[w] = (temp_board[h - 1])[w]
(temp_board[h - 1])[w] = "n"
did += 1
if not first and did > 5 and SFX:
pass
if first == False:
#w = 0
#h = 0

                            canvas.fill((0, 0, 0))
                            if True:
                                
                                draw_grid(canvas)
                                gemed = True
                                draw_gems(canvas, temp_board)
                                pygame.display.flip()
                    
                    if h == 0 and (temp_board[h])[w] == "n":
                        (temp_board[h])[w] = random.choice(gems)
                        #canvas.fill((0, 0, 0))
                        if gemed == False:
                            draw_grid(canvas)
                            draw_gems(canvas, temp_board)
                            pygame.display.flip()
                            gemed = True
        if first == False:
             #time.sleep(0.2)
             draw_grid(canvas)
             draw_gems(canvas, temp_board)
             #time.sleep(0.2)

        inside = False                
        for i in temp_board:
            if i.count("n") > 0:
                inside = True
    
    gem_board = copy.deepcopy(temp_board)
   # draw_grid(canvas)
    #draw_gems(canvas, gem_board)
    check_screen(gem_board, True)`

@Pololot64
Copy link
Author

Finally my main loop. Still a lot of commented, uncleaned code. If you need more, tell me. My game runs fine on windows, mac etc.:
`while True:
for event in pygame.event.get():

        if game and not menu and not lost:
            if event.type == MOUSEBUTTONDOWN:
                if event.button == 1:
                    mousex, mousey = event.pos
                    #print "nt"
                    mousex, mousey = event.pos
                    old = event.pos
                    ###click(event.pos, canvas)

            if event.type == MOUSEBUTTONUP:
                if event.button == 1 and get_click_area([mousex, mousey], event.pos) == True:
                    get_click_area([mousex, mousey], event.pos)
                    #print "nt"
                    mousex, mousey = event.pos
                    click(event.pos, canvas)
                    
                elif event.button == 1 and get_click_area([mousex, mousey], event.pos) == False:
                    click([mousex, mousey], canvas)
                    new = event.pos
                    get_click_area([mousex, mousey], event.pos)
                    #print "nt"
                    #left
                    up = False
                    down = False
                    left = False
                    right = False
                    
                    if old[0] > new[0]:
                        left = True
                    if old[1] > new[1]:
                        up = True
                    if old[1] < new[1]:
                        down = True
                    if old[0] < new[0]:
                        right = True
                    #print right, left, up, down
                    direction = ""
                    if right == True:
                        rdiff = new[0] - old[0]
                        if up == True:
                            udiff = old[1] - new[1]
                            if rdiff < udiff:
                                #print "up"
                                direction = "up"
                            elif rdiff > udiff:
                                #print "right"
                                direction = "right"
                            print rdiff, udiff
                            
                        elif down == True:
                            ddiff = new[1] - old[1]
                            if rdiff < ddiff:
                                #print "down"
                                direction = "down"
                            elif rdiff > ddiff:
                                #print "right"
                                direction = "right"
                            #print rdiff, ddiff
                        else:
                            direction = "right"
                        
                    elif left == True:
                        ldiff = old[0] - new[0]
                        if up == True:
                            udiff = old[1] - new[1]
                            if ldiff < udiff:
                                #print "up"
                                direction = "up"
                            elif ldiff > udiff:
                                #print "left"
                                direction = "left"
                            #print rdiff, udiff
                            
                        elif down == True:
                            ddiff = new[1] - old[1]
                            if ldiff < ddiff:
                                #print "down"
                                direction = "down"
                            elif ldiff > ddiff:
                                #print "left"
                                direction = "left"
                            #print ldiff, ddiff
                        else:
                            direction = "left"
                    if up == True and left == False and right == False:
                        direction = "up"
                    elif down == True and left == False and right == False:
                        direction = "down"
                    print direction
                    #actual click
                    if direction == "right":
                        click([old[0] + cell_size[0] + 1, old[1]], canvas)
                    if direction == "left":
                        click([old[0] - cell_size[0] + 1, old[1]], canvas)
                        
                    if direction == "up":
                        click([old[0], old[1] - cell_size[1]], canvas)
                    if direction == "down":
                        click([old[0], old[1] + cell_size[1]], canvas)
                        
                    mousex, mousey = event.pos
                    
                    state = 0
                    up = False
                    down = False
                    left = False
                    right = False
        if lost:
            if event.type == MOUSEBUTTONDOWN:
                    if event.button == 1:
                        mousex, mousey = event.pos
                        #print event.pos
                        mousex, mousey = event.pos
                        click_end(event.pos)
        if event.type == MOUSEBUTTONDOWN:
                if event.button == 1:
                    if event.pos[0] < WIDTH and event.pos[0] > WIDTH - pause_image.get_width() - 20:
                        if event.pos[1] > 0 and event.pos[1] < pause_image.get_height() + 20 and not paused and not lost:
                            active = False
                            lost = True
                            paused = True
                            pygame.mixer.music.pause()
    
    
    
    #canvas.fill([0, 0, 0])        
    #Background Check :-)
    if game == True:
        orient()
        draw_grid(canvas)
        if paused and mode == "speed":
            pass
        else:
            draw_gems(canvas, gem_board)
    if lost:
        display_game_end(state_game)
    if not lost:
        pause_h = 0
    pauso = canvas.blit(pause_image, (WIDTH - pause_image.get_width() - 10, 10))
    #canvas.blit(full_button, (WIDTH - full_button.get_width() - pause_image.get_width() - 20, 10))
    #blits.append(pauso)
    """
    if MUSIC == True:
        MUSIC = False
        pygame.mixer.music.stop()
    else:
        MUSIC = True
        pygame.mixer.music.play()"""
    
    #pygame.display.update(blits)
    pygame.display.flip()
    
    
    wait += 1
    seperate = 3
    if wait == seperate + 1:
        wait = 0
    if wait == seperate:
        s_num += 1
        
        if s_num == 23:
            s_num = 0
    blits = []`

@Pololot64
Copy link
Author

Sorry it did not publish all of my code correctly.

@mclaughlinconnor
Copy link

mclaughlinconnor commented Sep 17, 2017

I get that you want to keep your code private, but it is extracted to /data. That's not accessable to a normal user, but someone that's rooted can just read the code.

The game seems to run fine on my phone, I can't compare it to a computer though.

In a few days I might get hold of a rooted phone though, so I'll have a better look then.

@Pololot64
Copy link
Author

Pololot64 commented Sep 17, 2017 via email

@Pololot64
Copy link
Author

Pololot64 commented Sep 17, 2017 via email

@mclaughlinconnor
Copy link

Could I get the fullest, fanciest version please.

@Pololot64
Copy link
Author

Pololot64 commented Sep 17, 2017 via email

@mclaughlinconnor
Copy link

Here's a recording. Don't judge, it needs practice.

https://github.com/Connor124/Connor124.github.io/blob/master/TRIM_20170917_180731.mp4?raw=true.

@Pololot64
Copy link
Author

Pololot64 commented Sep 17, 2017 via email

@mclaughlinconnor
Copy link

  • Get rid of that link above.
  • Encrypt the code then decrypt to variable then exec
  • Use the bytecode (.pyc) as a library with a small script to get it going.

@Pololot64
Copy link
Author

Pololot64 commented Sep 17, 2017 via email

@mclaughlinconnor
Copy link

I thought the slowness was a fancy animation. :)

@Pololot64
Copy link
Author

Pololot64 commented Sep 17, 2017 via email

@Pololot64
Copy link
Author

Pololot64 commented Oct 19, 2017 via email

@bitcraft
Copy link

@powewal this thread contains some insight:
#36

In general, pygame_sdl2 is slower with software rendering, like drawing lines and blitting surfaces. For a real improvement in speed, you should first create surfaces of each image graphic (the gems) (i can't tell if you do that or not....seems like they are drawn using the software draw API), then you need to cache other things like the background, lines, text, etc. These eventually need to be moved the the SDL2 render API.

Basically, all the software/manual drawing is not optimised in SDL2, and you need to utilize the hardware GPU using the render API, and cache all your draws. This is typical of all modern games.

@Pololot64
Copy link
Author

Pololot64 commented Jan 10, 2018 via email

@bitcraft
Copy link

bitcraft commented Jan 10, 2018 via email

@Pololot64
Copy link
Author

Pololot64 commented Jan 10, 2018 via email

@bitcraft
Copy link

bitcraft commented Jan 10, 2018 via email

@Pololot64
Copy link
Author

Pololot64 commented Jan 10, 2018 via email

@Pololot64
Copy link
Author

BTW what does it mean to cache drawing and lock surfaces?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants