iOS Programming

Hey

I have a Q for all you codea bods. I want to do some simple newbie-friendly programming on my ipad and I don’t want to use codea, so please don’t suggest that. (note:- I already bought codea, so the devs aren’t gonna lose out by me now buying something else!!)

So want to buy an ios programming app for my ipad that has these specifics

1:- newbie friendly

2:- does NOT run a draw loop 60x a sec (I sooooo hate that and could never get my head around it)

3:- is pretty cheap $5-$10

4:- has a good forum for help or has a very good database of guides and tutes.

5:- is good for making games

like I said pls don’t say codea, I want an alternative.

Thanks muchly.

Any programming environment you find for programming anything on ipad/pod will run a draw function X-times per second. That is pretty much unavoidable unless you want an app with no visuals or an unchanging image.

I think your best bet is Pythonista. It runs python, a pretty well known and broadly-used language. There are many guides and tips about Python on the internet. Pythonista has a forum, but I don’t think it is as good as Codea’s. I believe Pythonista’s game capabilities are worse than Codea’s, but still usable, and it has support for a canvas type object (if that’s what you are looking for).

@Monkeyman32123 Ideally I want something like the old Basic you used to get built in your computer, where if you type code and put a sprite on screen at x,y it stays there until you move it, not disappears 1/60th of a sec later. That screen redrawing that codea does, I could never get my head around it. it seemed so alien to what I’d ever done before.

@Jordan Thanks, I will look at that right away!

@Paul123 Oooooh ok, I worked with something like that in java, makes sense. Odd, I always ridiculed that system and wondered who would use it, but if that’s what you prefer, good for you! ^-^

@paul123: check this out http://codea.io/talk/discussion/3472/on-ipad-coding-apps-updated/

https://www.youtube.com/watch?v=UH5CESyZ7So

@se24vad Wow that guy in the video is so patronising :smiley:

ty though!

@Paul123 just to let you know: codeo does work perfectly without the draw loop! I discovered this only recently… ex:

-- test no draw

function setup()
    backingMode(RETAINED)
    text("touch the screen anywhere",WIDTH/2,HEIGHT-100)
end

function touched(t)
    fill(255, 165, 0, 255)
    ellipse(t.x,t.y,10)
end    

@jmv38 Now try display a sprite without it. :stuck_out_tongue:

@Paul123

-- test no draw

function setup()
    backingMode(RETAINED)
    text("touch the screen anywhere",WIDTH/2,HEIGHT-100)
end

function touched(t)
    if t.state == BEGAN or t.state == MOVING    then
    fill(255, 165, 0, 255)
    ellipse(t.x,t.y,10)
    sprite("Planet Cute:Character Boy",WIDTH/2,HEIGHT/2)
    else
        background(0, 0, 0, 255)
        text("touch the screen anywhere",WIDTH/2,HEIGHT-100)
    end
end    

I could make you a class, if you like, which draws an object 60 times per second (but you only have to instantiate the class once, and it’ll continue drawing, you won’t have to worry about it) and you can just change its x and y values to move it. It’d somewhat simulate your “it stays until you move it” style.

In addition to what @Briarfox and @Jmv38 have shown you, you can also adapt Codea to work the way you want. For instance, in the example code below you call sprite once and it stays on the screen forever until you call it again with new position, size or image.

-- SpriteHack

function setup()
    sprite("Planet Cute:Character Boy", WIDTH / 2, HEIGHT / 2, 100, 150, "player")
end

function draw()
    background(40, 40, 50)
end

function touched(t)
    sprite("Planet Cute:Character Boy", t.x, t.y, 100, 150, "player")
end

-- Code to draw sprites
drawSprites = function()
    for _, s in pairs(sprites) do
        _sprite(s.img, s.x, s.y, s.w, s.h)
    end
end

-- Code to hijack sprite and draw functionality
_sprite = sprite

sprites = {}

sprite = function(img, x, y, w, h, id)
    if id == nil then
        error("Sprite function must be passed valid identifier")
        return
    end
    
    sprites[id] = { img = img, x = x or 0, y = y or 0, w = w or 0, h = h or w or 0 }
end

_draw = draw

draw = function(...)
    _draw(...)
    drawSprites()
end

Here’s an example of the idea I had, i just whipped it up real fast so obviously there’s room for improvement, but, here you go! See if you like it or could see it being good with minor changes (and if it’s almost there but not quite just tell me what I could do to improve it and I’d be happy to do my best).


--# Main

function setup()
    --[[ the variables in the persistent drawer's init function
    (isSprite,isEllipse,isRect,isMesh,
    width,height,spritename,meshverts,
    fillcol,strokecol,strokewid,x,y)]]--
    --sprite("Planet Cute:Character Boy",,,): for finding sprite names 
    --(just uncomment it to use the file searcher)
    
    --set up the master for the persistent draws (the first instance of Persist will 
    --always be the master, this one is simply used to handle draws. the first argument is the background color
    --the second argument, if true, enables smoothing. if false it disables smoothing.
    m = Persist(color(255,255,255),false)
    --make a new persistent object named "p". you can also access this object from the global table "q" created by the master. the first persistent object (past te master) is indexed as q[1], the next as q[2], etc.
    p = Persist(true,false,false,false,30,60,"Planet Cute:Character Boy",nil,nil,nil,nil,37,92)
    --p2 or q[2]
    p2 = Persist(false,true,false,false,30,60,nil,nil,nil,nil,nil,37,300)
    p3 = Persist(false,false,true,false,60,30,nil,nil,nil,nil,nil,WIDTH/2,HEIGHT/2)
end
function touched(t)
    --different functions in the Persistent class
    local a = true
    if a then
        p:setLoc(t.x,t.y)
    elseif b then
        p:move(t.deltaX,t.deltaY) 
    elseif c then
        p:resize(t.deltaX,t.deltaY,true)
    elseif d then
        if t.state == BEGAN then 
            p:togglevis()
        end
    end
end

function draw()
    --all that needs placed in the draw step :)
    --this draws all of the objects by accessing the "draw all objects" function of the master
    m:drawall()
end

--[[ if you are interested in this method of things staying until you move them then, by all means, tell me and id love to improve upon this class for you, adding more and more features and the likes :) --]]


--# persist
Persist = class()

function Persist:init(isSprite,isEllipse,isRect,isMesh,width,height,spritename,meshverts,fillcol,strokecol,strokewid,x,y)
    if not q then 
        q={} 
        self.master = true 
        self.bgcol = isSprite
        self.smoothing = true
    end
    self.s = isSprite or false
    self.e = isEllipse or false
    self.r = isRect or false
    self.m = isMesh or false
    if self.s then
        self.spritename = (spritename) or ("Planet Cute:Character Boy")
    end
    if self.m then
        self.mesh = mesh()
        self.verts = meshverts
        self.mesh.vertices = self.verts
    else
        self.wid = width or 30
        self.hei = height or width or 30
        self.strokewid = strokewid or 0
        self.strokecol = strokecol or color(0,0,0)
        self.x =x or WIDTH/2
        self.y =y or HEIGHT/2
        self.loc = vec2(self.x,self.y)
    end
    self.fillcol = fillcol or color(0,0,0)
    if self.m then
        self.mesh.setColors(fillcol)
    end
    if not self.master then
        table.insert(q,self)
    end
    self.invis = false
end

function Persist:draw()
    if not self.invis then
    if self.s then
        spriteMode(CENTER)
        sprite(self.spritename,self.x,self.y,self.wid,self.hei)
    elseif self.e then
        ellipseMode(CENTER)
        fill(self.fillcol)
        strokeWidth(self.strokewid)
        stroke(self.strokecol)
        ellipse(self.x,self.y,self.wid,self.hei)
    elseif self.r then
        rectMode(CENTER)
        fill(self.fillcol)
        strokeWidth(self.strokewid)
        stroke(self.strokecol)
        rect(self.x,self.y,self.wid,self.hei)
    elseif self.m then
        self.mesh:draw()
    end
    end
end

function Persist:move(xoffs,yoffs)
    if not self.m then
        self.x = self.x + xoffs
        self.y = self.y + yoffs
        self.loc = vec2(self.x,self.y)
    end
end

function Persist:setLoc(x,y)
    if not self.m then
        self.x = x
        self.y = y
        self.loc = vec2(self.x,self.y)
    end
end

function Persist:moveByAngle(mag,angleDeg)
    if not self.m then
        self.x = self.x + (mag*math.cos(math.deg(angleDeg)))
        self.y = self.y + (mag*math.sin(math.deg(angleDeg)))
        self.loc = vec2(self.x,self.y)
    end
end

function Persist:resize(w,h,Additive)
    if Additive then
        self.wid = self.wid + w
        self.hei = self.hei + h
    else
        self.wid = w
        self.hei = h
    end
end
    
function Persist:togglesmooth()
    if self.master then
        self.smoothing = not self.smoothing
    end
end
function Persist:togglevis()
    self.invis = not self.invis
end
function Persist:drawall()
    background(self.bgcol)
    if self.smoothing then
        smooth()
    else
        noSmooth()
    end
    for i=1,#q do
        q[i]:draw()
    end
end