2nd game coming soon!

Hello im a newbie and did my first game
__but now my 2nd game is coming out soon!

If you want my code:

-- EpicA
currentlevel=0
enemydmg=0
enemyhp=0
Rcob=0
Rcob2=0
m=0
topx=0
topy=0
opx=0
opy=0
hp=10
dmg=2
maxhp=10
realenemyhp=0
realenemydmg=0
defense=0
timer=0
turn=1
renemy=0

s=true
attakp=false
defp=false
hpswitch=true
m2switch=true
m3switch=true
mswitch=true
timerturna=false
iib=false
textturn=""
function setup()
    displayMode(FULLSCREEN)
    music("A Hero's Quest:Hero's Triumph")
end
function draw()
if(iib==true)then
if(turn==1)then
textturn="your turn"
        end
        if(turn==2)then
        textturn="oppoment turn" 
        end
        if(timerturna==true)then
            textturn="oppoment turn" 
         
        end
    
    if(timerturna==false)then
        timer=60
    end
    if(timerturna==true)then
        if(timer>0)then
            timer = timer-1
        end
    end
        end
       print(DeltaTime)
    if(iib== false)then
    Rcob=Rcob+m
    
    if(Rcob==60)then
       Rcob2= math.random(1,10)
        Rcob = 0
            
    end
    if(Rcob2==10)then
        print("loo")
            iib = true
            topx = 0
            topy= 0
            renemy=math.random(1,3)
    end
        end
    if(currentlevel == 0)then   
        background(90, 173, 230, 255)
    sprite("Planet Cute:Enemy Bug",WIDTH/2,700)
        sprite("Platformer Art:Battor Dead",900,300,100)
        
        font("HelveticaNeue-BoldItalic")
        fontSize(100)
        textWrapWidth(800)
        fill(0, 0, 0, 255)
        text("EpicA",WIDTH/2,WIDTH/2-200)
        
        font("AmericanTypewriter-Light")
        fontSize(30)
        textWrapWidth(800)
        fill(0, 0, 0, 255)
        text("Tap to start",WIDTH/2,WIDTH/2-275)
    end
    if(currentlevel == 1)then
        if(iib== false)then
        background(47, 93, 31, 255)
        sprite("Planet Cute:Character Boy",WIDTH/2,WIDTH/2-50)
       if( mswitch == true )then
            music("Game Music One 2:Runner Blade")
            mswitch = false
        end
    end
        end
    if(currentlevel == 0)then
        if(CurrentTouch.state == BEGAN)then
            currentlevel = currentlevel+1
        end
        end
    if(iib==false)then
        if(currentlevel==1)then
        currentlevel1()
        end
        end
        if(iib==false)then
    if(CurrentTouch.state == BEGAN)then
            
    if(CurrentTouch.y <=200)then
        topy =  2.5
                m=1
    end
         if(CurrentTouch.y >=850)then
        topy = -2.5
                m=1
    end
         if(CurrentTouch.x <=200)then
        topx =  2.5
                m=1
    end
         if(CurrentTouch.x >=850)then
        topx = -2.5
                m=1
                    end
    end
        if(CurrentTouch.state ==ENDED)then
            topx=0
            topy=0
            m=0
        end
end
  if(iib == true)then
        if(s==true)then
        turn=1
            s=false
            end
        
    background(0, 0, 0, 255)
        fill(76, 76, 76, 255)
        ellipse(700,100,10000,700)
    sprite("Cargo Bot:Dialogue Box",300,300,250)
        sprite("Small World:Sword",300,300,15)
        sprite("Cargo Bot:Dialogue Box",1000,300,250)
        sprite("Cargo Bot:Title Large Crate 2",1000,300,90)
        fill(0, 0, 0, 255)
        font("AmericanTypewriter-Bold")
        fontSize(60)
        textWrapWidth(800)
        text("hp:",270,150)
        text(hp,350,150)
        text("dmg:",1000,150)
        text(textturn,650,120)
        fill(114, 31, 34, 255)
        text("enemyhp:",230,900)
        text(enemyhp,420,900)
         
        
        
    end
    --Battle
      if(iib==true)then
        if(maxhp<hp)then
            hp=maxhp
        end
             if(enemydmg<0)then
                        enemydmg=0
                    end

        if(defp==true)then
           if( m3switch==true)then
                enemydmg=enemydmg-1
                
            end
            defp=false
            if(hp<6)then
            hp =hp+1
                end
                 end
        if(m2switch==true)then
            music("Game Music One 2:Jungle Rampage")
            m2switch=false
        end
        if(turn==1)then
            --attak
            
            if(timerturna==false)then
            if(CurrentTouch.state==BEGAN)then
        if(CurrentTouch.y<350)then
                    if(CurrentTouch.y>250)then
                        if(CurrentTouch.x<400)then
                            if(CurrentTouch.x>250)then
                    timerturna=true
                attakp=true
                                                 end       
            end
                end
        end
                    end
                end
            if(timerturna==false)then
            if(CurrentTouch.state==BEGAN)then
                if(CurrentTouch.x>=850)then
                if(CurrentTouch.x<=1100)then
                if(CurrentTouch.y>=250)then
                if(CurrentTouch.y<=400)then
                defp=true
                                    timerturna=true
                                print("def")
              end  
            end
            end
            end
            end
            end
            end

                                if(timer==1)then
                    turn=2
                                         timerturna=false
                                        timer=60

                                    end
            if(turn==2)then
            hp=hp-enemydmg
            enemydmg = realenemydmg
                    if(enemyhp<=0)then
            iib =false
                Rcob2=0
                renemy=0
                hpswitch=true
                enemyhp=-1000
                m2switch=true
                m3switch=true
                music("Game Music One 2:Runner Blade")
        end     
            turn=1
                
        end
        
      
            
        if(attakp==true)then
            enemyhp=enemyhp-dmg
            attakp=false
            print("attaked")
        end
        if(currentlevel==1)then
            if(renemy==1)then
              sprite("Planet Cute:Enemy Bug",700,800)  
                if(hpswitch==true)then
                    enemydmg=1
                    enemyhp=3
                    hpswitch=false
                    realenemydmg=1
                    realenemyhp=3
                               end
            end
            if(currentlevel==1)then
            if(renemy==2)then
              sprite("Platformer Art:Battor Flap 1",700,800,100)  
                if(hpswitch==true)then
                    enemydmg=2
                    enemyhp=4
                    hpswitch=false
                    realenemydmg=2
                    realenemyhp=4
                               end
            end
                if(currentlevel==1)then
            if(renemy==3)then
              sprite("Planet Cute:Rock",700,800)  
                if(hpswitch==true)then
                    enemydmg=0
                    enemyhp=5
                    hpswitch=false
                    realenemydmg=0
                    realenemyhp=5
                               end
            end
        end
    end
    end
        end
    end
opy = 0
opx = 0
function currentlevel1()
    if(iib ==false)then
    sprite("Small World:House White",500+opx,902+opy,500)
    sprite("Planet Cute:Character Pink Girl",700+opx,800+opy)
    sprite("Small World:Tree 3",1000+opx,0+opy)
        
        
    opy = opy+topy
    opx = opx+topx
        end
end

    

    

Here are the fotos of my game

@Mega5000 Is this supposed to be run in portrait or landscape mode. No matter which way I try to play it, I can only move the character in 3 directions. I can’t get it to move in the 4th direction. You code is formatted so bad that I’m not even going to see why.

I dont know what you mean on my ipad it works fine and what
Do you mean with landscape or portrait

-But anyway i try copy that and test it-
I copied it and it worked like My real code

@Mega5000 What device are you running this on. The screen I see for your first image (316_JPG) doesn’t fit the screen in landscape mode. Part of the button and text is off the screen. I’m trying to run this on an iPad Air. Another thing I see that you shouldn’t do is to have print statements in the draw function. It will eventually slow the game down and eventually crash the code.

Oh im on ipad pro thats why xD

My version is very big

If you’re going to post a game for anyone to try, then your code should handle any screen size. If you don’t want to add code for any size screen, then you should specify that the code is written for a certain size device. A lot of users won’t like trying your game when they can’t get it to work.

So how can i make it so the code knows what the version of ipad is or how big it is

Or can i just use the “WIDTH”?

Yup, use WIDTH / HEIGHT, SupportedOrientation etc

Ok i try

@Mega5000

When I coded both my games I use percentages of the screen size. I create an x variable for width and a y variable for height and divide those by 100 to get 1% of the width and height. Then when I draw objects I scale that variable by the amount I need.

E.g.

if HEIGHT/WIDTH > 1.6 then
        scalerY=HEIGHT/115
        yy=scalerY*20
        topbar=true
    else
        scalerY=HEIGHT/100
        yy=scalerY*10
        topbar=false
    end
    scalerX=WIDTH/100

The example above is my game set up and my game is portrait. The first part works out if the apple device is tall like an iPhone 5-7 or more standard size like an iPad ir iPhone 2-4.

So for tall devices I actually divide the height of my screen by 115 so that the graphics are more in proportion on a tall screen matching a tradition screen.

So if I have a ship on screen and it is 10% the width of the screen and 20% the height I set its width and height like so:

sh=Ship(scalerX*50,scalerY*20,scalerX*6.25,scalerY*6.25)

I’ll beak that line of code down.

sh is the instance name of a class I created called Ship

It’s worth noting that codea works bottom left with positions of things.

Inside the brackets, the first thing I define is the x position of the ship on screen. Since the screen width is divided by 100 to create a variable called scalerX I times scalerX*50 to place the ship instance on the stage in the middle.

I then set the y position with scalerY*20 so the ship is placed 1/5 of the height of the screen from the bottom.

Then I set the width and height of the ship again using the scalerX and scalerY variable but this time to make them 6.25% of the height and width of the screen.

Hopefully that makes sense. You can call the variables whatever you want.

I tried making my first game using 320x480 pixel size screen and using pixel placement but that didn’t work because when I came to test it on a different sized device, I had the same problems the others had with your code, it took one of the amazing helpful people on here to suggest I code it by scaling percentages of the width and height.

Hope you get on alright,