Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

My little game

edited March 5 in Code Sharing Posts: 26

1st half of code

currentlevel = 1
blocks = 10
addblock = 0
removeblock = 0
leftright = 10
leftorright = 0
RandomBattle = 0
hp = 10
enemyhp = 999999
enemyDmg = 5
dmg = 2
turntimer = 200
lost = 500
maxhp = 10
regenerate = 0
exp = 0
level = 1
expneeded = 200
dmgboost = 1
wichdmgboost = 0
score = 0
randomenemy = 0

losta = true
switch = false
space = false
IfInBattle = false
RCOFB = false
bswitch = true
aswitch = true

atext = "welcome to the game"
itemisthere = 1
itemisthere2 = 1
itemisthere3 = 1
function setup()
end
function draw()
      if(currentlevel<=3)then
  background(31, 116, 33, 255)  
        end
    if(currentlevel==3)then
        background(30, 30, 30, 255)

end
    if(currentlevel==4)then
         background(23, 23, 23, 255)
    end
if(currentlevel >= 100)then
     background(81, 81, 81, 255) 
    end
    if(currentlevel <99)then
        font("AmericanTypewriter-Bold")
          fontSize(60)
        textWrapWidth(800)
        fill(0, 0, 0, 255)
        text("xp:",700,1000)

         font("AmericanTypewriter-Bold")
        fontSize(60)
        textWrapWidth(800)
        fill(0, 51, 255, 255)
        text(exp,800,1000)

         font("AmericanTypewriter-Bold")
        fontSize(60)
        textWrapWidth(800)
        fill(0, 0, 0, 255)
        text("/",880,1000)

        font("AmericanTypewriter-Bold")
        fontSize(60)
        textWrapWidth(800)
        fill(0, 55, 255, 255)
        text(expneeded,970,1000) 
               font("AmericanTypewriter-Bold")
        fontSize(60)
        textWrapWidth(800)
        fill(84, 27, 144, 255)
        text(level,200,1000)

         font("AmericanTypewriter-Bold")
        fontSize(60)
        textWrapWidth(800)
        fill(0, 0, 0, 255)
        text("level:",100,1000)



        font("AmericanTypewriter-Bold")
        fontSize(60)
        textWrapWidth(800)
        fill(0, 0, 0, 255)
        text("hp:",800,100)

 font("AmericanTypewriter-Bold")
        fontSize(60)
        textWrapWidth(800)
        fill(173, 31, 31, 255)
        text(hp,900,100)

    end



        wichdmgboost = math.random(1,3)
    if(wichdmgboost == 3)then
        dmgboost = 1
        else
        dmgboost = 0
    end


    if(exp >= expneeded)then
        if(IfInBattle == false)then
        exp = exp-expneeded
        expneeded = expneeded+200
            maxhp = maxhp+2
        level = level+1
        hp = maxhp
            dmg = dmg+1

    end
        end
    if(regenerate == 27)then
        hp = hp+1
        regenerate = 0
    end

    if(hp >= maxhp)then
        hp = maxhp
    end

    if(switch == true)then
        leftright = 10
        blocks = 10
        switch = false
    end
    if(currentlevel <=98)then
        end
    parameter.action("go up",addblocks)
     parameter.action("go right",left)
    parameter.action("go down",removeblocks)
       parameter.action("go left",right)
    if(addblock == 1)then
        if(blocks<=18)then
        blocks = blocks+1
            end
        addblock = 0
    end
      if(removeblock == 1)then
        if(blocks >= 3)then

        blocks = blocks-1

            end
        removeblock = 0
    end
    --levels--
    --level1--
    if(currentlevel == 1)then

    sprite("Planet Cute:Character Boy",leftright*50,blocks*50)
    sprite("Planet Cute:Character Pink Girl",15*50,7*50)
    sprite("Planet Cute:Rock",12*50,14*50)
    sprite("Planet Cute:Wall Block Tall",8*50,15*50)
    sprite("Planet Cute:Shadow South",8*50,15*50-80)
    sprite("Planet Cute:Character Horn Girl",8*50,15*50+80)
        sprite("Planet Cute:Tree Tall",4*50,5*50)
        --sprite("Dropbox:Swordsmall",leftright*50-70,blocks*50+60)

         font("AmericanTypewriter-Bold")
        fontSize(60)
        textWrapWidth(800)
        fill(84, 27, 144, 255)
        text(level,200,1000)

         font("AmericanTypewriter-Bold")
        fontSize(60)
        textWrapWidth(800)
        fill(0, 0, 0, 255)
        text("level:",100,1000)



        font("AmericanTypewriter-Bold")
        fontSize(60)
        textWrapWidth(800)
        fill(0, 0, 0, 255)
        text("hp:",800,100)

 font("AmericanTypewriter-Bold")
        fontSize(60)
        textWrapWidth(800)
        fill(173, 31, 31, 255)
        text(hp,900,100)

        font("AmericanTypewriter-Bold")
               fontSize(60)
        textWrapWidth(800)
        fill(0, 0, 0, 255)
        text("xp:",700,1000)

         font("AmericanTypewriter-Bold")
        fontSize(60)
        textWrapWidth(800)
        fill(0, 51, 255, 255)
        text(exp,800,1000)

         font("AmericanTypewriter-Bold")
        fontSize(60)
        textWrapWidth(800)
        fill(0, 0, 0, 255)
        text("/",880,1000)

        font("AmericanTypewriter-Bold")
        fontSize(60)
        textWrapWidth(800)
        fill(0, 55, 255, 255)
        text(expneeded,970,1000) 

             if(itemisthere == 1)then
        sprite("Space Art:Part Green Wing 4",15*50,11*50)
            end
        if(itemisthere3 == 1)then
            sprite("Space Art:Part Green Hull 5",7*50,5*50)
        end
        end
    --level2
    if(currentlevel ==2)then

        sprite("Planet Cute:Rock",9*50,15*50)
        sprite("Planet Cute:Character Boy",leftright*50,blocks*50)
           --sprite("Dropbox:Swordsmall",leftright*50-70,blocks*50+60)

          font("AmericanTypewriter-Bold")
        fontSize(60)
        textWrapWidth(800)
        fill(84, 27, 144, 255)
        text(level,200,1000)

         font("AmericanTypewriter-Bold")
        fontSize(60)
        textWrapWidth(800)
        fill(0, 0, 0, 255)
        text("level:",100,1000)

          font("AmericanTypewriter-Bold")
        fontSize(60)
        textWrapWidth(800)
        text("hp:",800,100)

 font("AmericanTypewriter-Bold")
        fontSize(60)
        textWrapWidth(800)
        fill(174, 22, 22, 255)
        text(hp,900,100)

          font("AmericanTypewriter-Bold")
        fontSize(60)
        textWrapWidth(800)
        fill(0, 0, 0, 255)
        text("xp:",700,1000)

         font("AmericanTypewriter-Bold")
        fontSize(60)
        textWrapWidth(800)
        fill(0, 51, 255, 255)
        text(exp,800,1000)

         font("AmericanTypewriter-Bold")
        fontSize(60)
        textWrapWidth(800)
        fill(0, 0, 0, 255)
        text("/",880,1000)

        font("AmericanTypewriter-Bold")
        fontSize(60)
        textWrapWidth(800)
        fill(0, 55, 255, 255)
        text(expneeded,970,1000) 

       if( itemisthere2== 1)then
        sprite("Space Art:Part Green Wing 4",6*50,12*50)
            end
            if(itemisthere == 0)then
                if(itemisthere2 ==0)then
                    if(itemisthere3 == 0)then
                sprite("Space Art:Green Ship",11*50,9*50)
                        end
                    end
            end


    end
    --level3--
    if(currentlevel == 3)then

          font("AmericanTypewriter-Bold")
        fontSize(60)
        textWrapWidth(800)
        fill(84, 27, 144, 255)
        text(level,200,1000)

         font("AmericanTypewriter-Bold")
        fontSize(60)
        textWrapWidth(800)
        fill(0, 0, 0, 255)
        text("level:",100,1000)

Comments

  • edited March 5 Posts: 26

    2nd half o f code:

    if(aswitch== true)then
                maxhp = maxhp +10
                aswitch = false
                hp = hp+10
             music("Game Music One 2:Nothingness")
            end
              font("AmericanTypewriter-Bold")
            fontSize(60)
            textWrapWidth(800)
            text("hp:",800,100)
    
     font("AmericanTypewriter-Bold")
            fontSize(60)
            textWrapWidth(800)
            fill(140, 28, 29, 255)
            text(hp,900,100)
            if(now == 1)then
            switch = true
                now = 0
            end
            space = true
            sprite("Space Art:Green Ship",leftright*50,blocks*50)
            sprite("Space Art:Asteroid Large",9*50,11*50)
              font("AmericanTypewriter-Bold")
    
    
        end
        if(currentlevel==4)then
    
            sprite("Space Art:Green Ship",leftright*50,blocks*50)
            sprite("Space Art:Cloudy Nebula",14*50,9*50)
        end
    
        if(currentlevel>= 100)then
            --  sprite("Dropbox:Battle",WIDTH/2,WIDTH/2,1240)
            if(currentlevel <= 102)then
             sprite("Planet Cute:Enemy Bug",WIDTH/2,WIDTH/2)
                end
            if(currentlevel == 103)then
                sprite("Space Art:UFO",WIDTH/2,WIDTH/2)
            end
    
             fill(255, 0, 0, 255)
    
            font("Futura-MediumItalic")
            fontSize(80)
            textWrapWidth(800)
            text(hp,900,950)
             fill(71, 30, 30, 255)
    
                     font("Futura-MediumItalic")
            fontSize(80)
            textWrapWidth(800)
            text(enemyhp,230,950)
            fill(45, 45, 45, 255)
             font("Futura-MediumItalic")
            fontSize(40)
            textWrapWidth(800)
            text("your hp:",780,950)
             fill(42, 42, 42, 255)
             font("Futura-MediumItalic")
            fontSize(40)
            textWrapWidth(800)
            text("enemys hp:",100,950)
            if(currentlevel ==  104)then
                if(randomenemy == 1)then
                sprite("Tyrian Remastered:Boss A",WIDTH/2,WIDTH/2)
                    end
                if(randomenemy==2)then
                sprite("Space Art:Asteroid Large",WIDTH/2,WIDTH/2)
                    end
                if(randomenemy==3)then
                sprite("Space Art:Asteroid Small",WIDTH/2,WIDTH/2)
                    end
            end
        end
        --lost level--
        if(currentlevel==99)then
            background(76, 76, 76, 255)
            sprite("Small World:Bunny Skull",WIDTH/2,WIDTH/2,100)
    
              font("AmericanTypewriter-Bold")
            fontSize(60)
            textWrapWidth(800)
            fill(0, 0, 0, 255)
            text("you score:",550,300)
              font("AmericanTypewriter-Bold")
            fontSize(60)
            textWrapWidth(800)
            fill(0, 0, 0, 255)
            text(score,550,225)        
        end
    
        if(leftorright == 2)then
            if(leftright<=19)then
            leftright = leftright+1
    
                end
            leftorright = 0
        end
          if(leftorright == 1)then
            if(leftright >= 2)then
    
            leftright = leftright-1
    
                end
            leftorright = 0
    end
     font("ArialMT")
        fontSize(35)   
        textWrapWidth(800)
        fill(0, 0, 0, 255)
    
        text(atext,500,50)
    
    
         if(leftright <= 3)then
           if( currentlevel==1)then
            currentlevel = currentlevel+1
            leftright = 18
    
                end
        end
          if(leftright >= 19)then
           if( currentlevel==2)then
            currentlevel = currentlevel-1
            leftright = 4
              end
            end  
                 if(leftright >= 19)then
           if( currentlevel==3)then
            currentlevel = currentlevel+1
            leftright = 4
    
                end
            end
            if(leftright<=3)then
                if(currentlevel==4)then
                    leftright = 18
                    currentlevel=currentlevel-1
                end
            end
    
        -- end-of-Switch land--j
       -- --items-- --
        if(leftright ==6)then
            if(blocks == 12)then
                if(currentlevel == 2)then
                    if(itemisthere2==1)then
                itemisthere2 = 0
                atext = "you picked up the 2th spaceship part"
                        end
                    end
            end
        end
           if(leftright ==7)then
            if(blocks == 5)then
                if(currentlevel == 1)then
                    if(itemisthere3 == 1)then
                itemisthere3 = 0
                atext = "you picked up the space ship kabin"
                        end
                    end
            end
    
            end
           if(leftright ==15)then
            if(blocks ==11)then
                if(currentlevel == 1)then
                    if(itemisthere==1)then
             itemisthere = 0 
    
                atext = "you picked up a spaceship part"  
                end
            end
                end
                end
        if(leftright == 11)then
              if(itemisthere == 0)then
                    if(itemisthere2 ==0)then
                            if(blocks == 9)then
                            if(currentlevel == 2)then
                                currentlevel = currentlevel+1
                                atext = "you walked into a ship"
                                end
                            end
                        end
                            end
                    end
    
       --BATTLE--
     if(RCOFB == true)then
         RandomBattle = math.random(1,45)
             randomenemy= math.random(1,3)
    
         RCOFB = false
     end
     if(RandomBattle == 25)then
         IfInBattle = true
            RandomBattle = 0
            if(currentlevel == 3)then
                enemyhp = 10
            end
     end
    -- Battle scene + HP DMG and turn
    if(IfInBattle == true)then
        atext = "You are in a Battle!"
            if(bswitch == true)then
        currentlevel = currentlevel+100
                music("Game Music One 2:Jungle Rampage")
                bswitch = false
                if(currentlevel <= 102)then
                    enemyhp = 5
                end
                if(currentlevel == 105)then
                    enemyhp = 0010101010100101
                    enemyDmg = 100
                end
                if(currentlevel == 104)then
                    if(randomenemy == 1)then
                enemyhp = 12       
                        end         
                end
                 if(currentlevel == 104)then
                    if(randomenemy == 2)then
                enemyhp = 10 
                        end         
                end
                 if(currentlevel == 104)then
                    if(randomenemy == 3)then
                enemyhp = 4
                        end         
                end
                end
            print(enemyDmg,dmg,dmgboost)
            turntimer = turntimer-1
    
            if(turntimer <= 1)then
                         if(currentlevel <= 102)then
                enemyDmg = math.random(1,2)
                    end
                if(currentlevel == 103)then
                    enemyDmg = 2
                end
                if(currentlevel == 104)then
                    if(randomenemy == 1)then
                    enemyDmg = math.random(2,3)
                        end
                end
                 if(currentlevel == 104)then
                    if(randomenemy == 2)then
                    enemyDmg = math.random(2,3)
                        end
                end
                 if(currentlevel == 104)then
                    if(randomenemy == 3)then
                    enemyDmg = 1
                        end
                end
                enemyhp = enemyhp-dmg-dmgboost
                hp = hp-enemyDmg
                turntimer = 200
            end
            end
            if(enemyhp <= 0)then
                 if(currentlevel == 103)then
                exp = exp+200
                score = score+200
            end
            if(currentlevel<=102)then
                exp = exp+100
                score = score+100
            end
            if(currentlevel ==4)then
                if(randomenemy == 1)then
                    xp = xp+300
                    score = score+300
                end
            end
             if(currentlevel ==4)then
                if(randomenemy == 2)then
                    xp = xp+150
                    score=score+150
                end
            end
             if(currentlevel ==4)then
                if(randomenemy == 3)then
                    xp = xp+50
                    score=score+50
                end
            end
                currentlevel = currentlevel-100
               atext = "you won!"
                IfInBattle = false
                enemyhp = 5
                bswitch = true
            if(currentlevel <= 2)then
                  music("Game Music One 2:Venus")  
                end
            if(currentlevel == 3)then
                music("Game Music One 2:Nothingness")
            end
            if(currentlevel == 4)then
             music("Game Music One 2:Nothingness")   
            end
    
            end
            if(hp <= 0)then
                              currentlevel = 99
            IfInBattle = false
                    if(losta == true)then
                music("A Hero's Quest:Hero's Loss")
                losta = false
            end
                atext = "you lost!D:"
                if(lost >= 0)then
                    lost = lost-1
                end
                if(lost == 1)then
                restart()
                    end
    
            end
        end
    
    
    
    
    
    -- --end-of items
    
    function addblocks()
        if(IfInBattle ==false)then
        addblock=1
        RCOFB = true
    
          regenerate = regenerate+1
            end
    end
    function removeblocks()
          if(IfInBattle == false)then
        removeblock = 1
        RCOFB = true
    
        regenerate = regenerate+1
            end
    end
    function left()
              if(IfInBattle == false)then
        leftorright = 2
        RCOFB = true
    
          regenerate = regenerate+1
            end
    end
    function right()
                  if(IfInBattle == false)then
        leftorright = 1
        RCOFB = true
    
          regenerate = regenerate+1
            end
    end
    function setup()
        music("Game Music One 2:Venus")
    end
    
  • Posts: 26

    Evrything is a code

  • edited March 5 Posts: 26

    I hope you enjoy it ;D

  • edited March 5 Posts: 26

    If you want to have more Details:

    1.-its a Rpg style game
    2.-there are no mission(coming Soon)
    3.-there are just 4 maps :c
    4.-there is a automatic battle
    5.-infinity levels
    6.- you must have all the basic Codea assets
    7.- awesome music xD

    Next update:
    -map 5 (and maybe 6)
    - 3-7 new enemys
    - Maybe adding armour/sword

  • Posts: 59

    Could you put this in a pastebin at pastebin.com? I can't copy the code because if I have too much selected, my iPad starts acting weird.

  • edited March 5 Posts: 26

    Sorry all http//'s i tried didn't worked
    But you can try its called in pastebin.com My little game (Codea)

  • dave1707dave1707 Mod
    Posts: 5,620

    @Mega5000 Some suggestions. Don't have any print statements in the draw function. Those will slow the game and eventually crash Codea. You should change the code so your character remains in the middle of the screen and the background moves up/down/right/left.

  • Posts: 26

    I did not know that you just could move the background
    (And i forgot to delet the print statements because i wanted to test the game out)
    And my ipad is working fine if i start it

  • Posts: 26

    I know i know its laggy and slow
    But i will update it and try fixing it
    Im a newbie now but i become better and better when
    I make more projects like this

  • dave1707dave1707 Mod
    edited March 5 Posts: 5,620

    @Mega5000 Here's an example of moving the background. Press and hold an arrow to move. Code could be added to move based on how the iPad is tilted instead of pressing arrows.

    displayMode(FULLSCREEN)
    
    function setup()  
        spTab={"Platformer Art:Coin","Planet Cute:Key",
                "Small World:Flag","Small World:Heart","SpaceCute:Star"}
        tab={}
        for z=1,100 do
            table.insert(tab,vec3(math.random(-20,20),
                        math.random(-20,20),math.random(5)))       
        end
        dx,dy=0,0
        xval,yval=0,0
    end
    
    function draw()
        background(142, 228, 101, 91)
        for a,b in pairs(tab) do
            sprite(spTab[b.z],b.x*100+dx,b.y*100+dy)
        end  
        sprite("Platformer Art:Guy Standing",WIDTH/2+23,HEIGHT/2-20)  
        sprite("Cargo Bot:Command Left",75,HEIGHT/2,50,50)
        sprite("Cargo Bot:Command Left",WIDTH-75,HEIGHT/2,-50,50)
        sprite("Cargo Bot:Command Grab",WIDTH/2,HEIGHT-75,50,-50)
        sprite("Cargo Bot:Command Grab",WIDTH/2,75,50,50)
        dx=dx+xval
        dy=dy+yval
    end
    
    function touched(t)
        if t.state==BEGAN then
            if t.x<200 then
                xval=2
            elseif t.x>WIDTH-200 then
                xval=-2
            elseif t.y<200 then
                yval=2
            elseif t.y>HEIGHT-200 then
                yval=-2
            end
        elseif t.state==ENDED then
            xval,yval=0,0
        end
    end
    
  • Posts: 26

    Sorry but i dont make it in the first(Rpg style game)because i already did
    The code but 100% i will make it in the 2nd one

  • edited March 6 Posts: 26

    im currently working on a 2nd rpg game

Sign In or Register to comment.