• ELECTRO8888

    Hello everybody! I was wondering if it is possible to make a code generator that generates the code with an app where you drag and drop lines or curves to make a maze game for blender armory3d. I don’t need to know how to import it, just how to make the generator and app

    posted in Pythonista read more
  • ELECTRO8888

    Hello everybody! Is it okay if this can be a place where we can all ask questions about making pythonista games and chat about them too? If not then pls tell me and I will delete this.

    (I just think that there should be a single spot where we can all just chat about pythonista games we have made or seen, please tell me if this is okay)

    Edit: and I understand that we can already do that, but I just think that there should be one spot where we can all just talk and not have to search for questions everywhere on the internet

    posted in General Discussion read more
  • ELECTRO8888

    Thank you that is very helpful, I will try to use it now 😄

    posted in Pythonista read more
  • ELECTRO8888

    Hey, so I did a post like this before, but does anybody know how to make an expandable list with 3 numbers: 0 1 and 2, create a 3D game level? And if so, please explain how so people like me can understand it

    Edit: and how to make 0 an empty space 1 a block and 2 A coin or something that opens the next file which is the next game when walked into?

    Ex:# 1 = wall, 0 = empty 2=finish
    level = [[1,1,1,1,1,1,1,1],
    [1,1,1,2,0,0,1,1],
    [1,1,1,1,1,0,0,1],
    [1,1,1,0,0,1,0,1],
    [1,1,1,0,0,1,0,1],
    [1,1,1,0,1,1,0,1],
    [1,1,1,0,0,0,0,1],
    [1,1,1,1,1,1,1,1]]

    posted in Pythonista read more
  • ELECTRO8888

    @SmartGoat Thx! That means a lot

    posted in Pythonista read more
  • ELECTRO8888

    @cvp Thx and okay and Thx!

    posted in Pythonista read more
  • ELECTRO8888

    @cvp I do have one more question though... sorry.. I found some code while researching, and I can’t understand most of it XD are you okay with maybe putting some comments in it explaining it? Also could you please make it to where I can place a 2 in the level list for the finish as well as making it to where I can give it a different texture? I am so sorry for all of this, I don’t know much with Pythonista or this website, anyways, here is the code: ```

    RayCast

    Simple raycasting based renderer

    Touch the left part to rotate, and touch the right part to move forward

    Coded in a few hours during my holidays, July 2014, straight from my iPhone - thanks Pythonista !!!

    Feel free to upgrade !

    Enjoy !

    Emmanuel ICART

    eicart@momorprods.com

    from scene import *
    from math import *

    rendering step - 1=best(slower)

    RENDERING_STEP=1

    level data

    1 = wall, 0 = empty

    level = [[1,1,1,1,1,1,1,1],
    [1,1,1,1,0,0,1,1],
    [1,1,1,1,1,0,0,1],
    [1,1,1,0,0,1,0,1],
    [1,1,1,0,0,1,0,1],
    [1,1,1,0,1,1,0,1],
    [1,1,1,0,0,0,0,1],
    [1,1,1,1,1,1,1,1]]
    LX=len(level[0])
    LZ=len(level)
    LN=len(level[2])

    CellSize=107
    scan=10

    player

    xo=CellSizeLX/2
    zo=CellSize
    LZ/2
    no=CellSize*LN/2
    angle=45.0
    fov=80

    class RayCastScene (Scene):
    def setup(self):
    # preload the texture
    self.texture='plf:Ground_StoneMid'
    self.texture1='plf:Tile_DoorOpen_mid'
    self.screenWidth=int(self.size.w)
    self.screenHeight=int(self.size.h)
    self.xTouchStart=0
    self.yTouchStart=0
    load_image(self.texture)
    load_image(self.texture1)
    pass

    def draw(self):
        global angle
        global xo
        global zo
        global no
        # This will be called for every frame (typically 60 times per second).
    
        # clear background 
        background(0, 0, 0)
    
        focale=0.5*self.screenWidth/tan(radians(fov/2))
    
        # compute each screen column
        for column in range(0,self.screenWidth,RENDERING_STEP):
            scan_angle=angle+((float(column)-self.screenWidth/2)*fov)/self.screenWidth
            c=cos(radians(scan_angle))
            s=sin(radians(scan_angle))
            if abs(c)<0.001:
                if c>0:
                    c=0.001
                else:
                    c=-0.001
    
            if abs(s)<0.001:
                if s>0:
                    s=0.001
                else:
                    s=-0.001
    
            t2=s/c
            t1=c/s
            ok1=True
            ok2=True
    
            #Initialization of ray casting
            pz1=t2*CellSize
            if c>0:
                px1=CellSize
                ini=0
            else:
                px1=-CellSize
                pz1=-pz1
                ini=CellSize-1
    
            xp1=ini+(((int)(xo/CellSize))*CellSize)
            zp1=zo+((xp1-xo)*pz1)/px1
            np1=ini+(((int)(xo/CellSize))*CellSize)
    
            px2=t1*CellSize
            if s>0:
                pz2=CellSize
                ini=0
            else:
                pz2=-CellSize
                px2=-px2
                ini=CellSize-1
    
            zp2=ini+(((int)(zo/CellSize))*CellSize)
            xp2=xo+((zp2-zo)*px2)/pz2
            np2=xo+((zp2-zo)*px2)/pz2
    
            #****** cast a ray for z walls ******
            compteur=0
            while True:
                xp1+=px1
                zp1+=pz1
                np1+=px1
                compteur+=1
                xd=(int)(xp1/CellSize) % LX
                zd=(int)(zp1/CellSize) % LZ
                nd=(int)(np1/CellSize) % LN
                if (xd<0): xd=0
                if (zd<0): zd=0
    
                if level[xd][zd] !=0 or compteur>=scan:
                    break
    
            if (compteur==scan):ok1=False
            distance1=(xp1-xo)/c
            col1=(zp1 % CellSize)
            if (px1<=0): col1=CellSize-1-col1
    
            #****** cast a ray for x walls ****** 
            compteur=0
            while True:
                xp2+=px2
                zp2+=pz2
                compteur+=1
                xd=(int)(xp2/CellSize) % LX
                zd=(int)(zp2/CellSize) % LZ
                nd=(int)(np2/CellSize) % LN
                if (xd<0):xd=0
                if (zd<0):zd=0
                if level[xd][zd]!=0 or compteur>=scan: break
    
            if (compteur==scan): ok2=False
            distance2=(zp2-zo)/s
            col2=(xp2 % CellSize)
            if (pz2>=0):col2=CellSize-1-col2
    
            #Choose the nearest wall (x or z)
            if (distance1<distance2):
                distance=1+(distance1)
                colonne=col1
            else:
                distance=1+(distance2)
                colonne=col2
    
            if ok1 or ok2:
                # fix the fishbowl effect
                distance=distance*cos(radians(angle-scan_angle))
    
                #compute the wall screen height
                hauteur = ((CellSize*focale)/distance)
    
            # draw the column
            ximage=(colonne*128)/CellSize # 101 x 171 tile
            image(self.texture,column,(self.screenHeight-hauteur)/2,RENDERING_STEP,hauteur,ximage,0,RENDERING_STEP,171)
    
    
        # display fingers
        fill(1, 0, 0)
        for touch in list(self.touches.values()):
            ellipse(touch.location.x - 50, touch.location.y - 50, 100, 100)
    
            # rotation control
            if (touch.location.x<self.screenWidth/2):
                angle += 0.04*(touch.location.x-self.xTouchStart)
            else:
            # displacement control
                speed=(touch.location.y-self.yTouchStart)*0.04
                dx=speed*cos(radians(angle))
                dz=speed*sin(radians(angle))
                if level[int((xo+dx)/CellSize)][int(zo/CellSize)]!=0:dx=0
                if level[int(xo/CellSize)][int((zo+dz)/CellSize)]!=0:dz=0
                xo+=dx
                zo+=dz
    
    def touch_began(self, touch):
        global angle
        self.angleStart=angle
        if touch.location.x<self.screenWidth/2:self.xTouchStart=touch.location.x
        else:
            self.yTouchStart=touch.location.y
        pass
    
    def touch_moved(self, touch):
        pass
    
    def touch_ended(self, touch):
        pass
    

    run(RayCastScene(),LANDSCAPE)

    * list item

    posted in Pythonista read more
  • ELECTRO8888

    @cvp That is fine

    posted in Pythonista read more
  • ELECTRO8888

    @brumm Hey, if you can, could you please check this thread and see what I said to the creator and try to achieve that? I don’t think he uses this website anymore considering that last time he was on here was three months ago...

    (NO OFFENSE creator if you are reading this!)

    posted in Pythonista read more
  • ELECTRO8888

    @momorprods Hey, I have been messing with this code for about a week and can’t figure out how to add another wall, like for the finish for the level, I added the number 2 to the level numbers, and replicated some stuff, but I am not skilled enough yet... could you please give me a script to do that? And also could you please tell me how to make the level bigger? I tried that too, but I got an error, sorry for bothering you when ya probs have much better things to do...

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!