[Release & Competition] Online Python Editor for Pokitto!


#261

CONFIRMED

removing all screen.blits from Level class makes game run

class Level:
    def __init__(self):
        self.w=0
        self.h=0
        self.map=0
        self.emeralds=0
        self.lvl_nmbr=0
        self.load(levels[self.lvl_nmbr])
        self.newlvl=True
        self.t_new=30

        
    def next(self):
        
        self.lvl_nmbr +=1
        if self.lvl_nmbr >= len(levels):
            global win
            global gameover
            global t_gameover
            
            win=True
            gameover=True
            t_gameover=300
            return
        
        self.load(levels[self.lvl_nmbr])
        
    def load(self,lvl):
        self.w=lvl[0]*spritesize
        self.h=lvl[1]*spritesize
        self.data=lvl[2]
        
        
        
        self.reload()
                
    def reload(self):
        
        self.newlvl=True
        self.t_new=30
        
        self.map=bytearray(self.data)
        global bots
        global balls
        global springs
        global missiles
        global spikes
        
        bots=[]
        balls=[]
        springs=[]
        spikes=[]
        missiles=[]
        self.emeralds=0
        
        wid=(self.w//spritesize)//2
        for j in range(0,self.h//spritesize):
            for i in range(0,(self.w//spritesize)//2):
                c1=self.map[j*wid+i]>>4
                c2=self.map[j*wid+i]&0xf
                
                global p1
                
                if c1 == 2:
                    p1.x=i*2*spritesize
                    p1.y=j*spritesize

                if c2 == 2:
                    p1.x=i*2*spritesize
                    p1.y=j*spritesize
                    
                

                if c1 == 5:
                    self.emeralds+=1
                if c2 == 5:
                    self.emeralds+=1
                
                #trackbot    
                if c1 == 0xa:
                    bots.append(Trackbot(i*2*spritesize,j*spritesize))
                if c2 == 0xa:
                    bots.append(Trackbot((1+i*2)*spritesize,j*spritesize))
                #steelball    
                if c1 == 3:
                    balls.append(Steelball(i*2*spritesize,j*spritesize))
                if c2 == 3:
                    balls.append(Steelball((1+i*2)*spritesize,j*spritesize))
                    
                #springs
                if c1 == 0xe:
                    springs.append(Spring(i*2*spritesize,j*spritesize))
                if c2 == 0xe:
                    springs.append(Spring((1+i*2)*spritesize,j*spritesize))
                    
                #missils
                if c1 == 0x6:
                    missiles.append(Missile(i*2*spritesize,j*spritesize))
                if c2 == 0x6:
                    missiles.append(Missile((1+i*2)*spritesize,j*spritesize))
                    
                #spikes
                if c1 == 0xf:
                    spikes.append(Spike(i*2*spritesize,j*spritesize))
                if c2 == 0xf:
                    spikes.append(Spike((1+i*2)*spritesize,j*spritesize))
                    
                i+=1
        
    def tile_at(self,x,y):
        if x <0 or y < 0 or x > self.w or y > self.h:
            return 7
        
        tile_x=x//spritesize
        tile_y=y//spritesize
        
        d=self.map[tile_y*(self.w//spritesize)//2+tile_x//2]
        if tile_x % 2 : return d&0xf
        else: return d>>4
        
    def set_tile(self,x,y,value):
        tile_x=x//spritesize
        tile_y=y//spritesize
        d=self.map[tile_y*(self.w//spritesize)//2+tile_x//2]
        if tile_x % 2 ==0 :
            self.map[tile_y*(self.w//spritesize)//2+tile_x//2]=((d&0x0f) | (value<<4))
        else:
            self.map[tile_y*(self.w//spritesize)//2+tile_x//2]=((d&0xf0) | value)
        
    def solid_at(self,x,y):
        t=self.tile_at(x,y)
        for s in solids:
            if t== s:
                return True
        return False   
         
    def ladder_at(self,x,y):
        t=self.tile_at(x,y)
        if t== 1:
            return True
        else:
            return False
            
    def collisionAtPosition(self,tile,xc, yc, wc, hc):
        if self.tile_at(xc, yc + hc-1) == tile:
            return True
        if self.tile_at(xc + wc-1, yc + hc-1) == tile:
            return True
        if self.tile_at(xc + wc-1, yc) == tile:
            return True
        if self.tile_at(xc, yc) == tile:
            return True
            
    def solidCollisionAtPosition(self,xc, yc, wc, hc):
        if self.solid_at(xc, yc + hc-1):
            return True
        if self.solid_at(xc + wc-1, yc + hc-1):
            return True
        if self.solid_at(xc + wc-1, yc):
            return True
        if self.solid_at(xc, yc):
            return True

            
    def draw(self):
        xmin=camerax//spritesize
        xmax=(scrwidth//spritesize+camerax//spritesize)+2
        
        ymin=cameray//spritesize
        ymax=(scrheight//spritesize+cameray//spritesize)+2
        wid=(self.w//2)//spritesize
        doordraw=False
        for j in range(ymin,ymax):
            for i in range((xmin-1)//2,(xmax+1)//2):
                if i<0 or j < 0 or i >= wid or j >= self.h//spritesize:
                    continue
                
                c1=self.map[j*wid+i]>>4
                c2=self.map[j*wid+i]&0xf
                if not c1==0:
                    #screen.blit(tiles[c1], i*2*spritesize-camerax,j*spritesize -cameray)
                    c1 = c1
                if not c2==0:
                    #screen.blit(tiles[c2], i*2*spritesize-camerax+spritesize,j*spritesize -cameray)
                    c1 = c1
                    
                if c1==0xb:
                    if not self.solid_at(i*2*spritesize,(j-1)*spritesize):
                        #screen.blit(sprites.spikesDown8, i*2*spritesize-camerax,j*spritesize -cameray)
                        c1 = c1
                    else:
                        #screen.blit(sprites.spikesUp8, i*2*spritesize-camerax,j*spritesize -cameray)
                        c1 = c1
                        
                if c2==0xb:
                    if not self.solid_at(i*2*spritesize+spritesize,(j-1)*spritesize):
                        #screen.blit(sprites.spikesDown8, i*2*spritesize-camerax+spritesize,j*spritesize -cameray)
                        c1 = c1
                    else:
                        #screen.blit(sprites.spikesUp8, i*2*spritesize-camerax+spritesize,j*spritesize -cameray)
                        c1 = c1
                    
                if c1==0xc and not doordraw:
                    doordraw=True
                    if self.emeralds== p1.emeralds:
                        #screen.blit(sprites.doorOpened, i*2*spritesize-camerax,j*spritesize -cameray)
                        c1 = c1
                    else:
                        #screen.blit(sprites.doorClosed, i*2*spritesize-camerax,j*spritesize -cameray)
                        c1 = c1
                if c2==0xc and not doordraw:
                    doordraw=True
                    if self.emeralds== p1.emeralds:
                        #screen.blit(sprites.doorOpened, i*2*spritesize-camerax+spritesize,j*spritesize -cameray)
                        c1 = c1
                    else:
                        #screen.blit(sprites.doorClosed, i*2*spritesize-camerax+spritesize,j*spritesize -cameray)
                        c1 = c1
                i=i+1

EDIT: camerax , cameray used but I see no declaration as global

NOPE, no effect


#262

This looks fishy:

tiles=[0,sprites.ladder8,2,3,sprites.coin8,sprites.emerald8,6,sprites.bricks8,sprites.fuel_big8,sprites.cobblestone8,10,11,12,sprites.emeraldEmpty8,14,15]

#263

Confirmed.

Replacing tiles[c1] with sprites.sball8 in screen.blit makes game run


#264

Fixed:
jetpack_v1(1).zip (57.4 KB)

Replaced the numbers (2,3,6, etc) with zero and in level.draw it doesn’t try to blit if a tile is zero.


#265

DAMN! You are always faster than me

And believe me, I tried :sweat_smile:


#266

:rofl: :rofl: :rofl:  


#267

Sorry my fault
thank you @jonne @FManga for fixing it.


#268

Our pleasure, its a great game. My 4-yr old is sitting right here, fascinated by it.


#269

Nice! I don’t understand most of the words, but it sounds so funny in Italian.

I plan to develop the code in future and make it easier to create your own whole new adventures.

Yeah, good job! It’s very challenging, but I get further with every try. My current record is level 6.


#270

Completed the puzzle! :slight_smile:


#271

I’m not 100% sure I got all of them but here is a collection of the entry’s
.
Spring 2019 Contest.zip (1.8 MB)

Contents
1q48_v0_2.bin
BigBlue.bin
boblo.bin
Bounce.bin
jetpack_v1_1.bin
kamerakatze.bin
Mandelbrot.bin
MrDriller.bin
Noggin.bin
rexitto.bin
scummpy-it.bin
scummpy.bin
tgg.bin
ufo.bin
vocfi.bin
YouShallNotPass.bin


#272

Just remove the import framebuf line, framebuf was deprecated and the import never did anything.


#273

Your scummpy is an Italian version, but it is good for studying the language :wink:


#274

I think there is one more coming from @dir3kt


#275

Done and added.

English version added.


#276

Um… Pls add? nudge :wink:


#277

Will publish tonight,before midnight my time. Hope this is fine. Went through lot of issues related to RAM usage. Now they are fixed but… The game lags. The snake eating its own tail haha.


#278

No worries, we are eagerly waiting for your entry. Its good that you live in Tuvalu. Plenty of time.


#279


#280

I misspelled. I meant Anchorage