Codea Developer Simulator

Hey again, I’ve continued working on my time management game and came up with this: a Codea developer simulator. You start as a noob and work yourself to the top! I’m still working out the details but I’m already excited to share my code with you all, so here it is:


--# Main
-- Codea Dev Simulator
displayMode(FULLSCREEN)
-- Use this function to perform your initial setup
function setup()
    
    Codea = false
    Subscription = false
    Blog = false
    
    gameMode = Menu
    cash = 25
    knowledge = 0
    ranks={"Codea Noob", "Average Programmer", "Codea Veteran", "Supercomputer", "Simeon Himself"}
    rank=ranks[1]
    
    C1=Clicker(vec2(300, HEIGHT-300), "Edit example projects", 0, 0.05, 3)
    C2=Clicker(vec2(300, HEIGHT-400), "Ask a question on the forums", 0, 0.1, 1.5)
    C3=Clicker(vec2(300, HEIGHT-500), "Make a 2D game", 0, 0.3, 1)
    C4=Clicker(vec2(300, HEIGHT-600), "Sell your game's code", 8, 0.7, 0.3)
    
    C5=Clicker(vec2(WIDTH-300, HEIGHT-300), "Publish a 2D game", 16, 1.2, 0.2)
    C6=Clicker(vec2(WIDTH-300, HEIGHT-400), "Publish a 3D game", 28, 2.1, 0.1)
    C7=Clicker(vec2(WIDTH-300, HEIGHT-500), "Post a blog update", 0, 0.5, 4)
    C8=Clicker(vec2(WIDTH-300, HEIGHT-600), "Make a Codea tutorial", 0, 2, 0.7)
     
end

-- This function gets called once every frame
function draw()
    
    if knowledge > 100 then
    knowledge = 100
    end
    
    --Ranking
    if knowledge>99 then
        rank=ranks[5]
    elseif knowledge>75 then
        rank=ranks[4]
    elseif knowledge>50 then
        rank=ranks[3]
    elseif knowledge>25 then
        rank=ranks[2]
    end
    
    -- This sets a dark background color 
    background(40, 40, 50)
    gameMode()
    -- This sets the line thickness
    strokeWidth(5)

    -- Do your drawing here

end

function Menu()
    background(255, 255, 255, 255)
    sprite("Cargo Bot:Codea Logo", WIDTH/2-250, HEIGHT-150)
    fontSize(100)
    font("AmericanTypewriter-Light")
    fill(0, 0, 0, 255)
    text("Developer", WIDTH/2+250, HEIGHT-170)
    fill(0, 47, 255, 255)
    text("Simulator", WIDTH/2, HEIGHT/2+50)
    fill(0, 0, 0, 255)
    rect(WIDTH/2-200, 100, 400, 150)
    fill(255, 255, 255, 255)
    text("Start", WIDTH/2, 175)
end

function Play()
    background(255, 255, 255, 255)
    fill(0, 0, 0, 255)
    rect(WIDTH-100, HEIGHT-200, 100, 50)
    fontSize(20)
    font("AmericanTypewriter")
    text("Rank:"..rank, 150, HEIGHT-50)
    text("Knowledge:"..math.floor(knowledge).."%", WIDTH/2, HEIGHT-50)
    text("Budget: $"..cash, WIDTH-150, HEIGHT-50)
    fill(255, 255, 255, 255)
    text("Store", WIDTH-50, HEIGHT-175)
    
    if Codea == true then
    C1:draw()
    C2:draw()
    C3:draw()
    C4:draw()
    
    if Subscription==true then
            C5:draw()
            C6:draw()
    end
    
    if Blog==true then
            C7:draw()
            C8:draw()
        end
        
    else
    fill(0, 0, 0, 255)
    fontSize(50)
    text("Go to the store and buy Codea!", WIDTH/2, HEIGHT/2)
    text("^", WIDTH-50, HEIGHT-250)
    stroke(0, 0, 0, 255)
    line(WIDTH-50, HEIGHT-255, WIDTH-50, 450)
    stroke(0, 0, 0, 0)
    end
end

function Store()
    background(255, 255, 255, 255)
    fill(0, 0, 0, 255)
    rect(WIDTH-100, HEIGHT-100, 100, 100)
    
    --Buy Codea
    if Codea == false then
    fill(0, 0, 0, 255)
    rect(WIDTH/2-150, HEIGHT/2+200, 300, 50)
    fontSize(15)
    textWrapWidth(300)
    text("Start your adventure buy purchasing this wonderful app from Two Lives Left!", WIDTH/2, HEIGHT/2+175)
    textWrapWidth(WIDTH)
    fill(255, 255, 255, 255)
    fontSize(20)
    text("Buy Codea   -$10-", WIDTH/2, HEIGHT/2+225)
    else
    fill(50, 167, 23, 255)
    rect(WIDTH/2-150, HEIGHT/2+200, 300, 50)
    fill(255, 255, 255, 255)
    text("Purchased", WIDTH/2, HEIGHT/2+225)
    end
    
    
    --Buy iTunes dev account
    if Subscription == false then
    fill(0, 0, 0, 255)
    rect(WIDTH/2-150, HEIGHT/2+100, 300, 50)
    fontSize(15)
    textWrapWidth(300)
    text("Want to publish your apps? Buy this for only $100!", WIDTH/2, HEIGHT/2+75)
    textWrapWidth(WIDTH)
    fontSize(20)
    fill(255, 255, 255, 255)
    text("Buy dev subscription   -$100-", WIDTH/2, HEIGHT/2+125)
        else
    fill(50, 167, 23, 255)
    rect(WIDTH/2-150, HEIGHT/2+100, 300, 50)
    fill(255, 255, 255, 255)
    text("Purchased", WIDTH/2, HEIGHT/2+125)
    end
    
    
    --Buy blog
    if Blog == false then
        fill(0, 0, 0, 255)
    rect(WIDTH/2-150, HEIGHT/2, 300, 50)
    fontSize(15)
    textWrapWidth(300)
    text("Keep your fans updated about your games and double your profits :D", WIDTH/2, HEIGHT/2-25)
    textWrapWidth(WIDTH)
    fontSize(20)
    fill(255, 255, 255, 255)
    text("Buy a blog   -$200-", WIDTH/2, HEIGHT/2+25)
        else
    fill(50, 167, 23, 255)
    rect(WIDTH/2-150, HEIGHT/2, 300, 50)
    fill(255, 255, 255, 255)
    text("Purchased", WIDTH/2, HEIGHT/2+25)
    end
    
    
    fill(255, 255, 255, 255)
    fontSize(20)
    font("AmericanTypewriter")
    text("Back", WIDTH-50, HEIGHT-50)
    
    fill(0, 0, 0, 255)
    text("Budget: $"..cash, 150, HEIGHT-50)
end


function touched(t)
    
--Menu
if gameMode == Menu then
    if t.x>WIDTH/2-200 and t.x<WIDTH/2+200 and t.y>100 and t.y<250 and t.state == ENDED then
        gameMode = Play
    end
end
   

--Game
if gameMode == Play then
    if Codea==true then
    C1:touched(t)
    C2:touched(t)
    C3:touched(t)
    C4:touched(t)
            
    if Subscription==true then
        C5:touched(t)
        C6:touched(t)
    end
            
    if Blog==true then
        C7:touched(t)
        C8:touched(t)
    end

    end
    
    if t.x > WIDTH-100 and t.y < HEIGHT-150 and t.y > HEIGHT-200 and t.state == ENDED then
        gameMode = Store
    end
end
    
  
--Store
if gameMode == Store then 
    --Back
    if t.x > WIDTH-100 and t.y > HEIGHT-100 and t.state == ENDED then
        gameMode = Play
    end
        
    --Buy Codea
    if Codea == false and cash>=10 and t.x>WIDTH/2-150 and t.x<WIDTH/2+150 and t.y>HEIGHT/2+200 and      t.y<HEIGHT/2+250 and t.state==ENDED then
            cash=cash-10
            Codea=true
            sound("Game Sounds One:Assembly 4")
        end
        
    --Buy dev subscription
        if Subscription == false and cash>=100 and t.x>WIDTH/2-150 and t.x<WIDTH/2+150 and t.y>HEIGHT/2+100 and      t.y<HEIGHT/2+150 and t.state==ENDED then
            cash=cash-100
            Subscription=true
            sound("Game Sounds One:Assembly 4")
        end
        
    --Buy dev subscription
        if Blog == false and cash>=200 and t.x>WIDTH/2-150 and t.x<WIDTH/2+150 and t.y>HEIGHT/2 and      t.y<HEIGHT/2+50 and t.state==ENDED then
            cash=cash-200
            Blog=true
            C4.incm = C4.incm*2
            C5.incm = C5.incm*2
            C6.incm = C6.incm*2
            sound("Game Sounds One:Assembly 4")
        end
end
    
    
end


--# Clicker
Clicker = class()

function Clicker:init(pos, name, incm, exp, speed)
    -- you can accept and set parameters here
    self.pos = pos
    self.name = name
    self.incm = incm
    self.exp = exp
    self.speed = speed
    
    self.earn = false
    self.earnw = 0
end

function Clicker:draw()
    -- Codea does not automatically call this method
    fill(255, 0, 0, 255)
    rect(self.pos.x-25, self.pos.y-15, 50, 30)
    fill(24, 39, 161, 255)
    fontSize(15)
    font("ArialMT")
    text(self.name, self.pos.x, self.pos.y+25)
    fontSize(15)
    fill(0, 0, 0, 255)
    if self.incm~=0 then
    text("Income:"..self.incm, self.pos.x, self.pos.y-30)
    end
    
    --Earning process
    if self.earn == true then
        fill(30, 159, 39, 255)
        rect(self.pos.x+50, self.pos.y-15, self.earnw, 30)
    if self.earnw<100 then
            self.earnw=self.earnw+self.speed
    elseif self.earnw>=100 then
            cash = cash+self.incm
            knowledge = knowledge+self.exp
            self.earnw=0
            sound("Game Sounds One:Wall Bounce 2")
            self.earn = false
        end
    end
end

function Clicker:touched(t)
    -- Codea does not automatically call this method
        if self.earnw==0 then
        if t.x>self.pos.x-25 and t.x<self.pos.x+25 and t.y>self.pos.y-15 and t.y<self.pos.y+15 and 
        t.state == ENDED then
        self. earn = true
        sound("Game Sounds One:Wall Bounce 1")
            end
        end
end

@dave1707 - I thought that too, until I met quaternions. Anyway, I’ll stop hijacking this thread now.

I don’t really get the point. Maybe you could get more money overtime after publishing the app. And @dave1707 thanks for the idea!
knowledge=100

… and maybe if you want to get really clever you could even add a random text generator so you can actually see the blog posts! Now that would be funny!

Kind of interesting. I didn’t want to take the time to build up my knowledge, so I just changed the knowledge to 100 and ran the program.

Good start! Rather quick to beat, so more gameplay and more emphasis on the knowledge skill

@CodeaNoob Maybe like when you get to 100% you rank up and go back to 0% instead of all the ranks within the 100%

Lol@dave1707 - I wish learning some parts of graphic programming could be accelerated like that!

@Ignatz I think learning is the fun part of coding. Don’t want to accelerate past the fun.

@jaj_TheDeveloper You’re right, that would be an easy yet fun addon!

Maybe I’ll add a new variable containing your customers/fans, the more fans you gain, the higher your profits!

And I don’t see why everyone changes their knowledge to 100%, it would make more sense to change your money.

I think I’ll have to stop development of this game for the moment. I just dropped my iPad and the screen is all cracked. It was time for a new one anyway.
PS. What iPad would you recommend?

@G_nex I tried changing cash first. I increased it from 25 to 2500 and started to play. After awhile I stopped the game and increased the knowledge to 100% just to see the end. As for what iPad to buy, the latest one that you can afford. At least it will last awhile before Apple stops supporting it.

I was thinking the same thing. My current one is the iPad mini first gen and I was quite happy with its size so I considered buying the iPad mini 3 but everyone seems to be a bit negative about it. I think I might buy the iPad air 2 for €450.

@G_nex Something you might want to invest in is a protective case. That way if you drop it, it won’t break.

@dave1707 I don’t really like the feel of a case around my tablet. I rather feel my iPad’s cold metal than a piece of rubber.

[UPDATE] I’ve ordered an iPad mini 2 (128GB for only €360!!!) and it should arrive soon, so I can continue working on my game :slight_smile:

@G_nex If you don’t like protective cases, then start saving your money for your next iPad.

@dave1707 My last one lasted 3 years, I hope this new one will too

@G_nex I have written a random text generator. Click Here to view.