PLEASE, PLEASE integrate the ReplayKit into Codea, so that we could make video tutorials by capturing the screen of everything (editor, gameplay, etc) - there could be a ton of use cases for this, but this is what I'm personally concerned about at the moment. Maybe someone else supports this idea too...

]]>```
displayMode(OVERLAY)
displayMode(FULLSCREEN)
function setup()
al = Alert(500, 200, nil)
end
function draw()
background(0, 0, 0, 255)
al:draw()
font("AmericanTypewriter")
fontSize(25)
if al.alertdraw == false then
text("Touch to see the alert", WIDTH/2, HEIGHT/2)
end
end
function touched(t)
al:touched(t)
al.alertdraw = true
end
```

Alert class:

```
Alert = class()
function Alert:init(x, y, action, title, txt)
if action == nil then
action = function() print("Action!") end
end
if title == nil then
title = "Alert"
end
if txt == nil then
txt = "The Alert has no content"
end
self.x = x
self.y = y
self.alertdraw = false
self.action = action
self.headtext = title
self.informationtext = txt
end
function Alert:draw()
if self.alertdraw == true then
-- Alert Box
fill(255, 255, 255, 255)
rectMode(CORNER)
rect(self.x, self.y, 350, 200)
-- Alert Title Text
font("AmericanTypewriter-Bold")
fontSize(25)
fill(42, 64, 74, 255)
text(self.headtext, self.x + 175, self.y + 175)
-- Alert Information Text
font("AmericanTypewriter")
fontSize(15)
fill(0, 0, 0, 255)
text(self.informationtext, self.x + 175, self.y + 150)
-- Buttons
font("AmericanTypewriter")
fontSize(25)
fill(255, 0, 0, 255)
text("Dismiss", self.x + 280, self.y + 25)
fill(0, 0, 255, 255)
text("OK", self.x + 35, self.y + 25)
end
end
function Alert:touched(t)
if t.state == ENDED and self:OKhit(vec2(t.x,t.y)) then
if self.action then
self.action()
end
end
if t.state == ENDED and self:Dismiss(vec2(t.x,t.y)) then
self.alertdraw = false
print("No Alert Draw")
end
end
function Alert:OKhit(p)
local OKT = self.y + 50
local OKB = self.y
local OKR = self.x + 50
local OKL = self.x
if p.x > OKL and p.x < OKR and p.y > OKB and p.y < OKT then
return true
end
return false
end
function Alert:Dismiss(d)
local t = self.y - 50
local b = self.y + 50
local r = self.x + 350
local l = self.x + 250
if d.x > l and d.x < r and d.y > b and d.y < t then
return true
end
return false
end
```

]]>```
-- Scale Test
function setup()
size = 7
img = image(size,size)
setContext(img)
noSmooth()
ellipse(size/2,size/2,size)
setContext()
for i = 1,size do
for j = 1,size do
r,g,b,a = img:get(i,j)
if a > 0 then
img:set(i,j,color(255))
end
end
end
end
function draw()
background(40, 40, 50)
strokeWidth(5)
sprite(img,WIDTH/2,HEIGHT/2,size*32)
end
```

And here are the images: iPad Mini iPad Air

Thanks!

]]>```
function setup()
print("swipe on the boy to hit him.")
function draw()
background(0, 243, 255, 255)
sprite("Planet Cute:Character Boy", 400, 500)
function touched(touch)
if touch.state==MOVING then
sound(DATA, "ZgBAPQBGPhleSiRr8Jp1vjxX4j6CwGU+TABhWw9EOFlAO2E0")
if touch.state==ENDED then
sound("A Hero's Quest:Hurt 1")
end
sound("A Hero's Quest:Hurt 2")
sound("A Hero's Quest:Hurt 3")
sound("A Hero's Quest:Hurt 5")
sound("A Hero's Quest:Level Up")
print("LEVEL UP!")
end
end
end
end
```

]]>*Creative Design of Boalens, Buttons, IntegerParameters and Texts in screen?*

Yes, we got all what you need! Click the activation Link.

**What is this?**

Buttons, Integer Lines, TextBoxes, Boalens, Ellipse, Line, [Soon] More features

**Updates September 2015**

We have released our classes! I Hope you enjoy. Create an GitHub Page. Click The activation link.

**Updates Dezember 2015**

We are writing currently a cool alert box

** Soon **

- More features

--# Main
function setup()
pi,ti,sin,cos,rad=math.pi,table.insert,math.sin,math.cos,math.rad
scene={Create:Box(vec3(0,-5,0),vec3(100,5,100)),
Create:Box(vec3(10,0,40),vec3(15,15,15)),
Create:Sphere(vec3(60,8,30),8,25),
Create:Cyl(vec3(20,0,20),7,20,40,0)
}
for i=1,#scene do scene[i].shader=shader(BufferVertex,BufferFrag) scene[i].shader.lr=300 end
--Screen
M=mesh()
M.vertices={vec2(0,0),vec2(WIDTH,0),vec2(WIDTH,HEIGHT),vec2(WIDTH,HEIGHT),vec2(0,HEIGHT),vec2(0,0)}
M.texCoords={vec2(0,0),vec2(1,0),vec2(1,1),vec2(1,1),vec2(0,1),vec2(0,0)}
M.shader=shader(LightVertex,LightFrag)
M.shader.lr=300
M.shader.FA=vec2(math.tan(math.rad(25)),WIDTH/HEIGHT)
--Variabler
parameter.watch("1/DeltaTime")
parameter.number("lx",0,100,85)
parameter.number("px",-100,200,-50)
parameter.number("pz",-100,200,-50)
Pos=vec3(-50,75,-50)
Eye=vec3(25,0,25)
Ljus=vec3(0,25,30)
Depth1=image(WIDTH,HEIGHT)
Depth2=image(WIDTH,HEIGHT)
Normals=image(WIDTH,HEIGHT)
end
function draw()
Ljus.x=lx
Pos.x=px
Pos.z=pz
for j=1,3 do
if j==1 then setContext(Depth1,true) elseif j==2 then setContext(Depth2,true) else setContext(Normals,true) end
background(255, 255, 255, 255)
perspective(50,WIDTH/HEIGHT,1,300)
camera(Pos.x,Pos.y,Pos.z,Eye.x,Eye.y,Eye.z)
shV=viewMatrix()
shP=projectionMatrix()
for i=1,#scene do
scene[i].shader.loop=j
scene[i].shader.View=viewMatrix()
scene[i].shader.imodmat=modelMatrix():inverse()
scene[i]:draw()
end
setContext()
end
ortho()
viewMatrix(matrix())
--Screen
background(0, 255, 255, 255)
M.shader.Depth1=Depth1
M.shader.Depth2=Depth2
M.shader.Normals=Normals
M.shader.lp=Ljus
M.shader.iView=shV:inverse()
M.shader.ViewProj=shV*shP
M:draw()
end
function normals(m)
local normal={}
local v=m.vertices
for i=1,#v,3 do
local n=(v[i+1]-v[i]):cross(v[i+2]-v[i]):normalize()
normal[i]=n normal[i+1]=n normal[i+2]=n
end
return normal
end
BufferVertex=[[
uniform highp mat4 modelViewProjection;
attribute vec4 position;
attribute vec3 normal;
varying vec4 Pos;
varying vec3 Norm;
uniform mat4 imodmat;
uniform mat4 View;
void main() {
Pos=View*position;
Norm=(imodmat*vec4(normal,1.)).xyz;
gl_Position=modelViewProjection*position;
}
]]
BufferFrag=[[
precision highp float;
varying highp vec4 Pos;
varying vec3 Norm;
uniform float lr;
uniform int loop;
vec3 encodeDepth(float d) {
vec3 enc=vec3(1.,255.,65025.)*d;
enc=fract(enc);
enc-=vec3(enc.y,enc.z,enc.z)*vec3(1./255.,1./255.,1./255.);
return enc;
}
void main() {
if (loop==1) {
if (!gl_FrontFacing) discard;
highp vec3 co=encodeDepth(-Pos.z/Pos.w/lr);
gl_FragColor=vec4(co,1.);
} else if (loop==2) {
if (gl_FrontFacing) discard;
highp vec3 co=encodeDepth(-Pos.z/Pos.w/lr);
gl_FragColor=vec4(co,1.);
} else {
vec3 N=((Norm+1.)*0.5);
gl_FragColor=vec4(N,1.);
}
}
]]
LightVertex=[[
uniform mat4 modelViewProjection;
attribute vec4 position;
attribute vec2 texCoord;
varying highp vec2 vT;
void main() {
vT=texCoord;
gl_Position=modelViewProjection*position;
}
]]
LightFrag=[[
precision highp float;
uniform sampler2D Depth1;
uniform sampler2D Depth2;
uniform sampler2D Normals;
uniform float lr;
uniform vec3 lp;
uniform vec2 FA;
uniform mat4 iView;
uniform mat4 ViewProj;
varying highp vec2 vT;
const highp vec2 Values=vec2(1./255.,1./65025.);
//This is the number of steps where we check for shadows
#define Steps 25.
float decodeDepth(vec3 c) { return dot(c,vec3(1.,Values.x,Values.y)); }
vec3 ToPos(vec2 vt,float f) {
vec2 uv=vt*2.-1.;
highp float Z=f*lr;
highp float X=uv.x*FA.x*FA.y*Z;
highp float Y=uv.y*FA.x*Z;
highp vec4 fPos=iView*vec4(X,Y,-Z,1.);
return fPos.xyz/fPos.w;
}
void main() {
highp vec3 pd=texture2D(Depth1,vT).xyz;
float D=decodeDepth(pd);
if (D>0.99) discard;
//Var
vec4 Col=vec4(0.3,0.,0.,1.);
vec3 Normal=texture2D(Normals,vT).xyz; Normal=Normal*2.-1.;
vec3 Pos=ToPos(vT,D);
//Light
vec3 ltp=lp-Pos;
float ll=max(1.-length(ltp)/60.,0.);
float Ljus=max(0.,dot(normalize(ltp),Normal)*ll);
if (Ljus!=0.) {
Col+=vec4(Ljus);
vec4 lpos=ViewProj*vec4(lp.xyz,1.); lpos.xy=lpos.xy/lpos.w;
float dz=(lpos.z/lr-D)/Steps; vec2 dir=((lpos.xy*0.5+0.5)-vT)/Steps;
float cz=D; vec2 cpos=vT;
for (int i=0;i<int(Steps);i++) {
cz=cz+dz; cpos=cpos+dir;
if (decodeDepth(texture2D(Depth1,cpos).xyz)<cz && decodeDepth(texture2D(Depth2,cpos).xyz)>cz)
{ Col=vec4(0.3,0.,0.,1.); break; }
}
}
gl_FragColor=vec4(Col.xyz,1.);
}
]]
--# Create
Create=class()
function Create:Box(p,pp)
v={
vec3(p.x,p.y+pp.y,p.z),vec3(p.x,p.y+pp.y,p.z+pp.z),vec3(p.x+pp.x,p.y+pp.y,p.z+pp.z),
vec3(p.x+pp.x,p.y+pp.y,p.z+pp.z),vec3(p.x+pp.x,p.y+pp.y,p.z),vec3(p.x,p.y+pp.y,p.z),
vec3(p.x,p.y,p.z),vec3(p.x+pp.x,p.y,p.z+pp.z),vec3(p.x,p.y,p.z+pp.z),
vec3(p.x+pp.x,p.y,p.z+pp.z),vec3(p.x,p.y,p.z),vec3(p.x+pp.x,p.y,p.z),
vec3(p.x,p.y,p.z),vec3(p.x,p.y+pp.y,p.z),vec3(p.x+pp.x,p.y+pp.y,p.z),
vec3(p.x+pp.x,p.y+pp.y,p.z),vec3(p.x+pp.x,p.y,p.z),vec3(p.x,p.y,p.z),
vec3(p.x,p.y,p.z+pp.z),vec3(p.x+pp.x,p.y,p.z+pp.z),vec3(p.x+pp.x,p.y+pp.y,p.z+pp.z),
vec3(p.x+pp.x,p.y+pp.y,p.z+pp.z),vec3(p.x,p.y+pp.y,p.z+pp.z),vec3(p.x,p.y,p.z+pp.z),
vec3(p.x,p.y,p.z),vec3(p.x,p.y,p.z+pp.z),vec3(p.x,p.y+pp.y,p.z+pp.z),
vec3(p.x,p.y+pp.y,p.z+pp.z),vec3(p.x,p.y+pp.y,p.z),vec3(p.x,p.y,p.z),
vec3(p.x+pp.x,p.y,p.z),vec3(p.x+pp.x,p.y+pp.y,p.z),vec3(p.x+pp.x,p.y+pp.y,p.z+pp.z),
vec3(p.x+pp.x,p.y+pp.y,p.z+pp.z),vec3(p.x+pp.x,p.y,p.z+pp.z),vec3(p.x+pp.x,p.y,p.z)}
m=mesh()
m.vertices=v
m.normals=normals(m)
return m
end
function Create:Cyl(pos,propx,propy,poly,open)
local cyl=mesh()
local fc={}
local ac={}
local cs=cs or 360
local angle=cs/poly
for i=1,poly+1 do
ti(fc,vec3(pos.x+propx*cos(rad(angle*i)),pos.y,pos.z+propx*sin(rad(angle*i))))
ti(ac,vec3(pos.x+open*(propx*cos(rad(angle*(i)))),pos.y+propy,pos.z+open*(propx*sin(rad(angle*(i))))))
end
local v={}
for k=1,poly do
ti(v,fc[k]) ti(v,ac[k]) ti(v,ac[k+1])
ti(v,ac[k+1]) ti(v,fc[k+1]) ti(v,fc[k])
end
cyl.vertices=v
cyl.normals=normals(cyl)
return cyl
end
function Create:Sphere(pos,r,N)
local tab={}
local snorm={}
for n=0,N-1 do
for m=0,N-1 do
x=pos.x+r*sin(pi*m/N)*cos(2*pi*n/N)
y=pos.y+r*sin(pi*m/N)*sin(2*pi*n/N)
z=pos.z+r*cos(pi*m/N)
x1=pos.x+r*sin(pi*m/N)*cos(2*pi*(n+1)/N)
y1=pos.y+r*sin(pi*m/N)*sin(2*pi*(n+1)/N)
z1=pos.z+r*cos(pi*m/N)
x2=pos.x+r*sin(pi*(m+1)/N)*cos(2*pi*(n+1)/N)
y2=pos.y+r*sin(pi*(m+1)/N)*sin(2*pi*(n+1)/N)
z2=pos.z+r*cos(pi*(m+1)/N)
x3=pos.x+r*sin(pi*(m+1)/N)*cos(2*pi*n/N)
y3=pos.y+r*sin(pi*(m+1)/N)*sin(2*pi*n/N)
z3=pos.z+r*cos(pi*(m+1)/N)
ti(tab,vec3(x1,y1,z1)) ti(tab,vec3(x,y,z)) ti(tab,vec3(x2,y2,z2))
ti(tab,vec3(x2,y2,z2)) ti(tab,vec3(x,y,z)) ti(tab,vec3(x3,y3,z3))
ti(snorm,(vec3(x1,y1,z1)-pos):normalize()) ti(snorm,(vec3(x,y,z)-pos):normalize())
ti(snorm,(vec3(x2,y2,z2)-pos):normalize()) ti(snorm,(vec3(x2,y2,z2)-pos):normalize())
ti(snorm,(vec3(x,y,z)-pos):normalize()) ti(snorm,(vec3(x3,y3,z3)-pos):normalize())
end
end
local sph=mesh()
sph.vertices=tab
sph.normals=snorm
return sph
end

]]>I was wondering whether it is possible to retrieve saveImage() and io.write() data after losing them through the dropbox sync crash. The text and image data I have lost is VERY important for some work I am doing at the moment.

The step by step method of reproducing this bug : First create an image and string, then use saveImage() and io.write() to save the image and string. Then turn off internet connection, then dropbox sync. The app will crash at this point. Then turn on the internet connection, then dropbox sync again. The syncing will appear to work but after checking dropbox, there are no files there.

Now I have been doing a bit of research and it seems the files might still be there on the ipad somewhere but after looking through iexplorer, I cannot find them. Is there a way to retrieve them now?

Would it be a good idea to save the data locally to the ipad documents as a secondary backup (even if it is difficult to retrieve it later)?

Cheers

]]>The basic idea is this: You can version/source control your Codea projects by pushing the code to remote repositories on hosting sites, such as Github, Bitbucket, Gitlab, and so for. There are 2 parts to the system: a Codea app that you would run in your Codea workspace on iPad, and a web service that runs on my server at https://codea-scm.aws.mapote.com , which does the communications with repo hosting sites, and basically acts as a proxy for your source control actions.

The web site has install instructions and more detailed info, which is recommended to take a look at: https://codea-scm.aws.mapote.com/

But if you are eager to get started, without reading any further, here's the bootstrap installer for you:

```
--# Main
-- codea-scm bootstrap installer
function setup()
displayMode(STANDARD)
print("Installing codea-scm ...")
http.request("https://codea-scm.aws.mapote.com/install",
function (data, status, headers)
assert(loadstring(data))()
print("Installation complete. SUCCESS!")
print("Launch the project again to start using codea-scm.")
tween.delay(2.0, close)
end,
function (err)
print("PROBLEM downloading: " .. err)
end)
end
function draw()
background(37, 38, 50, 255)
end
```

Possible uses:

versioning and backups: We are using true source control system, so yep we get the versioning from it. Backups are taken care off somewhat indirectly - by using remote repositories hosted at GitHub and other well known sites, (Presumably, they look after their storage systems and back them up regularly :) )

coding on both iPad and your laptop/desktop: Some types of changes are just much easier to do on a computer. Vim, full keyboard, etc.. You can do that, then commit and push your changes to the repository, then pull them to the iPad - to continue working there.

code sharing: The nice thing about repo hosting sites - such as GitHub and Bitbucket - they already have the infrastructure built around users and projects, and the logic and the UI all figured out. By hosting your repositories on one of those sites, you can leverage their access control mechanisms to share your Codea projects with just friends or everybody (or no one, if you don't want to).

Limitations:

Right now only

**git**is supported, although i tried to keep the web service and the app generic enough, so that other scm's can be added in the future, if needed/wanted. For instance, Mercurial (Hg) and Subversion should not be hard to add support for.You are limited to "Diff", "Push", and "Pull" operations. Anything more complex, you'd still need to do on your laptop/desktop. (Which is probably better kept that way anyway)

Only your source tabs are pushed/pulled. Assets, such as sprites, are not versioned. I still need to figure out a way to handle those.

Codea-SCM works on Codea 1.5.5 and Codea 2.0. However, with 2.0, there is a caveat to be aware of - related to **http.request**. It seems that in Codea 2.0, if you restart the project, http.request stops working (all requests just hang). Since Codea-SCM uses http.request quite a bit, the workaround is: don't restart the project, simply close it, and then press the "play" button again. Then all should be good.

I added 1 line to my vertex shader code:

```
attribute float myAttribute;
```

below is the example code:

```
-- Accessing a shader buffer
------------------------
-- Create a mesh
myMesh = mesh()
-- Assign a shader to myMesh
-- This shader has an attribute named 'myAttribute'
myMesh.shader = shader("Documents:MyShader")
-- Fetch the attribute array
myAttrBuffer = myMesh:buffer("myAttribute")
-- Resize our buffer
myAttrBuffer:resize(30)
-- Add some random numbers
for i = 1,30 do
myAttrBuffer[i] = math.random(-50,50)
end
-- The shader will now use this data
-- when myMesh is drawn
```

]]>*This function returns the largest integer smaller than or equal to value. This rounds a number down to the nearest integer. For example, math.floor(5.7) returns 5.*

Below is my code for rounding a number to a nearest decimal place. The code works fine when I pass in a float that needs to be rounded. When I pass in a number that doesn't need rounding my call to math.floor causes this code to round down. In this case my number goes from 1.1219 to 1.2189 when I try to round to four digits.

```
function setup()
f=Formatter(5)
f:set(1.1219)
print(f:get())
end
--===================================================
Formatter = class()
function Formatter:init(places)
-- you can accept and set parameters here
if places==nil or places<0 then
places=0
elseif places >8 then --arbitrary limit.
places=8
end
self.incr = places -- save number of decimal places to preserve
self.num=0 -- initialize as a numeric value
end
function Formatter:set(float)
print("In set, float = " .. float)
round_num=float * 10^(self.incr+1)
round=round_num % 10
print ("In set, round_num = " .. round_num)
print ("In set, round = " .. round)
self.num=math.floor(float*10^self.incr) -- turn the number into an integer with self.incr decimal places
print("In set, calc = " .. float * (10^self.incr))
print("In set, calc with math.floor = " .. math.floor(float * (10^self.incr))) -- WHY IS THIS NUMBER different?
print("In set self.num = " .. self.num)
if round > 5 then -- round up if trailing decimal place is greater than 5
self.num=self.num+1
end
self.num=self.num/10^self.incr -- return rounded decimal
end
function Formatter:get()
retval="" .. self.num
return retval
end
```

]]>The projecteuler.net site offers over 400 problems which can be solved in under a minute (of computer processing time - not the time it takes you to write a program!). They challenge you to get the right answer, using any language you like. They will simply tell you if you get it right.

Here are the first couple

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000.

Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.

Answers 1 = 233168 2 = 4613732

]]>```
function setup()
parameter.text("User") -- @ mail
parameter.text("PassWord") -- •••••
parameter.action(
"Log In",
function()
-- Make an action parameter for the logging
end
)
end
```

So now think we have 3 members. One is Admin, one beta and one normal. This is without any servers, but creating the users is on server Create 3 Functions, name them user1, user2, user3

```
function setup()
parameter.text("User") -- @ mail
parameter.text("PassWord") -- •••••
parameter.action(
"Log In",
function()
end
)
end
function user1()
end
function user2()
end
function user3()
end
```

Now you have the 3 user functions. Let think, that user1 got as User admin@chat.com and as PassWord zxcvy And the 2nd and 3rd user will come in the code. Find yourself!

```
function setup()
parameter.text("User") -- @ mail
parameter.text("PassWord") -- •••••
parameter.action(
"Log In",
function()
if User == "admin@chat.com"
and PassWord == "zxcvy"
then user1()
elseif User == "beta@chat.com"
and PassWord == "beta"
then user2()
elseif User == "example@chat.com"
and PassWord == "password"
then
end
-- Here I fixed an error
)
end
function user1()
print("Welcome, Admin")
end
function user2()
print("Welcome, Beta!")
end
function user3()
print("Welcome, have fun!")
end
```

this could be useful for chats, Loggings into forum, ... Or something like Shop OnLine. Have fun using my ideas! I currently don't know how to use the IF with the "PassWord or UserName invalid-function"

]]>

function setup()
loop=10000000
s=os.clock()
for z=1,loop do
a=math.sin(z)
a=math.cos(z)
a=math.log(z)
a=math.sqrt(z)
end
print(os.clock()-s)
end

Here are the times for my 2 iPads. The Air is almost 5 times faster than the iPad1.

iPad1 34.97 seconds
iPad Air 7.77 seconds

]]>```
-- flappy game
--Kyle Wood
supportedOrientations(PORTRAIT_ANY)--can only be used in portrait position
function setup()
displayMode(FULLSCREEN)
game=0
timer=0
highscore=readLocalData("highscore",0)--saves highscore for device
score=0
dead=0
lastscore=0
waterX=0
end
function draw()
if game==0 and dead==0 then
--Displaying the start screen and performing initial setups
if score>lastscore then lastscore=score end
if score>highscore then
highscore=score
saveLocalData("highscore",highscore) end
scorechange=0
score=0
speedY=1
pipeX1=WIDTH
pipeY1=math.random((200),(HEIGHT-200))
pipeX2=WIDTH
pipeY2=math.random(200,(HEIGHT-200))
flapX=WIDTH/2
flapY=HEIGHT/2
background(80, 131, 58, 255)
font("Futura-Medium")
fill(84, 62, 45, 255)
fontSize(50)
text("Sinking MattyBoo",WIDTH/2, HEIGHT-200)
fontSize(20)
text("Tap to Play",WIDTH/2, HEIGHT-270)
font("Futura-Medium")
fill(143, 131, 122, 255)
fontSize(50)
text("Sinking MattyBoo",WIDTH/2+2, HEIGHT-200)
fontSize(20)
text("Tap to Play",WIDTH/2+2, HEIGHT-270)
sprite("Documents:MATTYBOO",WIDTH/2,HEIGHT/2,50)--MattyBoosprite is from codea
font("Futura-Medium")
fill(84, 62, 45, 255)
fontSize(30)
text("Highscore:",WIDTH/2, HEIGHT-1000)
text(math.ceil(highscore),WIDTH/2+102,HEIGHT-1000)
fill(143, 131, 122, 255)
fontSize(30)
text("Highscore:",WIDTH/2+2, HEIGHT-1000)
text(math.ceil(highscore),WIDTH/2+104, HEIGHT-1000)
font("Futura-Medium")
fill(84, 62, 45, 255)
fontSize(35)
text("Score:",WIDTH/2-50,HEIGHT/2-100)
text(lastscore,WIDTH/2+20, HEIGHT/2-100)
fill(143, 131, 122, 255)
fontSize(35)
text("Score:",WIDTH/2-48,HEIGHT/2-100)
text(lastscore,WIDTH/2+22, HEIGHT/2-100)
sprite("Documents:MATTYBOO",flapX,flapY,50)
end
if dead==1 then
--the animation for when the flap dies
background(34, 115, 188, 255)
fill(170, 170, 170, 255)
rect(pipeX1,pipeY1, 50,HEIGHT)
rect(pipeX1,pipeY1-HEIGHT-120,50,HEIGHT)
rect(pipeX2,pipeY2, 50,HEIGHT)
rect(pipeX2,pipeY2-HEIGHT-120,50,HEIGHT)
sprite("Documents:MATTYBOO",flapX,flapY,50)
font("Futura-Medium")
fill(0, 51, 255, 255)
fontSize(50)
text("You let the MattyBoo sink...",WIDTH/2, HEIGHT/2)
speedY=speedY+0.2
if flapY>0 then
flapY=flapY-speedY
elseif flapY<=0 then game=0 dead=0 end
end
if game==1 and dead==0 then
flapY=flapY+speedY--giving the bird physics and motion depending om the flapY variable
--detecting the pipes
if flapX+25>= pipeX1 and flapX<=pipeX1+50 and flapY+10>=pipeY1 then
dead=1 speedY=1 sound(SOUND_EXPLODE, 22971)
end
if flapX+25>= pipeX1 and flapX<=pipeX1+50 and flapY-25<=pipeY1-120 then
dead=1 speedY=1 sound(SOUND_EXPLODE, 22971)
end
if flapX+25>= pipeX2 and flapX<=pipeX2+50 and flapY+10>=pipeY2 then
dead=1 speedY=1 sound(SOUND_EXPLODE, 22971)
end
if flapX+25>= pipeX2 and flapX<=pipeX2+50 and flapY-25<=pipeY2-120 then
dead=1 speedY=1 sound(SOUND_EXPLODE, 22971)
end
if flapY>HEIGHT and flapX+25>=pipeX2 then dead=1 speedY=1 sound(SOUND_EXPLODE, 22971) end
if flapY>HEIGHT and flapX+25>=pipeX2 then dead=1 speedY=1 sound(SOUND_EXPLODE, 22971) end
--detecting a score change
if pipeX1<flapX-50 and scorechange==0 then
score=score+1
scorechange=1
sound(SOUND_PICKUP, 3156)
end
if pipeX2<flapX-50 and scorechange==1 then
score=score+1
scorechange=0
sound(SOUND_PICKUP, 3156)
end
--setting up the display
background(34, 115, 188, 255)
speedY=speedY-.2--decreasing the Y position of the sprite
if flapY<0 then game=0 end
fill(170, 170, 170, 255)
--pipe 1
rect(pipeX1,pipeY1, 50,HEIGHT)
rect(pipeX1,pipeY1-HEIGHT-120,50,HEIGHT)
pipeX1=pipeX1-2
timer=timer+.01
if pipeX1<-50 then
pipeX1=WIDTH
pipeY1=math.random(200,(HEIGHT-200))
end
--pipe 2
if timer>2 then
rect(pipeX2,pipeY2, 50,HEIGHT)
rect(pipeX2,pipeY2-HEIGHT-120,50,HEIGHT)
pipeX2=pipeX2-2
if pipeX2<-50 then
pipeX2=WIDTH
pipeY2=math.random(200,(HEIGHT-200))
end
end--end of pipe 2
--showing the score
font("Futura-Medium")
fill(84, 62, 45, 255)
fontSize(50)
text(score,WIDTH/2, HEIGHT-50)
fill(143, 131, 122, 255)
fontSize(50)
text(score,WIDTH/2+2, HEIGHT-50)
sprite("Documents:MATTYBOO",flapX,flapY,50)
end-- end of "game==1"
sprite("Documents:namelogo",WIDTH-25,HEIGHT/100)--my own personal touch (initials in bottom right corner)
end
function touched(touch)
--detecting the start of the game
if touch.state==BEGAN and game==0 and dead==0 then
timer=0
flapX=WIDTH/4
flapY=HEIGHT-100
game=game+1
end
--detecting the flap when the game is running
if touch.state==BEGAN and game==1 then
speedY=5--increasing the Y position of the sprite
speech.pitch=2.0
speech.rate=0.6
speech.preDelay=0.0
speech.say("MattyBoo")
end
end
```

]]>Here is the collision detection code:

```
--collision detection
if math.sqrt((p_ball.x-r_ball.x)^2+(p_ball.y-r_ball.y)^2) <= p_ball.radius+r_ball.radius then
if r_ball.x<p_ball.x then
p_speedX=math.sqrt((p_speedX)^2)+0.1-- makes speed positive and faster
end
if r_ball.x>p_ball.x then
p_speedX=((math.sqrt((p_speedX)^2))*-1)-0.1--makes speed negative and faster
end
if r_ball.y<p_ball.y then
p_speedY=math.sqrt((p_speedY)^2)+0.1--making speed positive then faster
end
if r_ball.y>p_ball.y then
p_speedY=((math.sqrt((p_speedY)^2))*-1)-0.1--making speed negative then faster
end
end
if math.sqrt((p_ball.x-l_ball.x)^2+(p_ball.y-l_ball.y)^2) <= p_ball.radius+l_ball.radius then
if l_ball.x<p_ball.x then
p_speedX=math.sqrt((p_speedX)^2)+0.1-- makes speed positive and faster
end
if l_ball.x>p_ball.x then
p_speedX=((math.sqrt((p_speedX)^2))*-1)-0.1--makes speed negative and faster
end
if l_ball.y<p_ball.y then
p_speedY=math.sqrt((p_speedY)^2)+0.1--making speed positive then faster
end
if l_ball.y>p_ball.y then
p_speedY=((math.sqrt((p_speedY)^2))*-1)-0.1--making speed negative then faster
end
end
```

Thank you!

]]>```
a={1,2,3}
SomeFunction(unpack(a))
--is the same as
SomeFunction(1,2,3)
--and you can unpack into the end of a list
a={1,2,3}
SomeFunction(5,unpack(a))
--is the same as
SomeFunction(5,1,2,3)
--but if there are any parameters after your unpack statement, then only
--the first table item is used (this is deliberate, I forget the reason)
a={1,2,3}
SomeFunction(5,unpack(a),4)
--is the same as
SomeFunction(5,1,4)
```

Note the built in reference incorrectly tells you to unpack tables with `tableName.unpack()`

. The correct syntax is `unpack(tableName)`

.

You can unpack vectors the same way, but the syntax is `vectorName:unpack()`

.

`try count`

increments each time I try to place a piece on the board. The `fit count`

increments each time a piece fits in the next open spot and `solutions`

increments each time all 12 pieces fit. The program stops at a solution, just tap the screen to continue to the next solution. The list below are some of the solutions. I only did the first 2 solutions with this program. For the other solution values, I used a stripped down version that ran faster and just printed out the solutions. This program is too slow to find a lot of solutions, but I wrote it just for something to do.
```
Solutions at try count.
77566
77568
341780
359584
405551
407979
688578
```

```
displayMode(FULLSCREEN)
function setup()
fitcount,trycount,solution,nextopen=0,0,0,0
pieceoffset,size=1,40
col={color(255,0,0),color(0,255,0),color(0,0,255),color(255,255,0),
color(0,255,255),color(255,0,255),color(255,128,0),color(255,128,128),
color(128,128,255),color(128,128,128),color(128,64,64),color(255,0,128)}
show={vec2(500,900),vec2(500,780),vec2(500,700),vec2(500,580),
vec2(530,480),vec2(530,380),vec2(650,900),vec2(650,800),
vec2(650,700),vec2(650,600),vec2(650,500),vec2(650,380)}
used={0,0,0,0,0,0,0,0,0,0,0,0}
rot={0,0,0,0,0,0,0,0,0,0,0,0}
here={0,0,0,0,0,0,0,0,0,0,0,0}
board={88,88,88,88,88,88,88,88,88,88,88,00,00,00,00,00,00,00,00,88,
88,00,00,00,00,00,00,00,00,88,88,00,00,00,00,00,00,00,00,88,
88,00,00,00,00,00,00,00,00,88,88,00,00,00,00,00,00,00,00,88,
88,00,00,00,00,00,00,00,00,88,88,00,00,00,00,00,00,00,00,88,
88,00,00,00,00,00,00,00,00,88,88,88,88,88,88,88,88,88,88,88}
piece={
{{0,10,20,30,31,40,41},{0,1,7,8,9,10,11},{0,1,10,11,21,31,41},{0,1,2,3,4,10,11}},
{{0,1,10,11,12,13},{0,10,19,20,29,30},{0,1,2,3,12,13}, {0,1,10,11,20,30}},
{{0,10,20,30,31,32},{0,10,17,18,19,20},{0,1,2,12,22,32},{0,1,2,3,10,20}},
{{0,1,11,12,13,14},{0,10,20,29,30,39},{0,1,2,3,13,14},{0,9,10,19,29,39}},
{{0,10,20},{0,1,2},{0,10,20},{0,1,2}},
{{0,1,11},{0,1,10},{0,10,11},{0,9,10}},
{{0,1,2,3,4,14},{0,1,10,20,30,40},{0,10,11,12,13,14},{0,10,20,30,39,40}},
{{0,10,20,21,22},{0,10,18,19,20},{0,1,2,12,22},{0,1,2,10,20}},
{{0,1,2,10,11},{0,10,11,20,21},{0,1,9,10,11},{0,1,10,11,21}},
{{0,10,20,30,31,32},{0,10,17,18,19,20},{0,1,2,12,22,32},{0,1,2,3,10,20}},
{{0,10,20,30,40,41},{0,6,7,8,9,10},{0,1,11,21,31,41},{0,1,2,3,4,10}},
{{0,10,11,21,22},{0,9,10,18,19},{0,1,11,12,22},{0,1,9,10,19}}}
w1,stop=true,true
fill(255)
end
function draw()
background(33, 89, 104, 255)
drawboard()
printTotals()
showPieces()
solve()
end
function solve()
if stop or wait then
return
end
if w1 then
nextopen=nextboard()
nextpiece(pieceoffset,1)
w1,yy=false,true
end
while yy==true do
nextopen=nextboard()
if checkfit()==1 then
pieceoffset=pieceoffset+1
if pieceoffset>12 then
pieceoffset=12
solution=solution+1
wait=true
return
else
yy=false
end
else
addone()
end
end
w1=true
end
function touched(t)
if t.state==BEGAN then
if stop then
stop=false
elseif wait then
wait=false
removepiece()
addone()
end
end
end
function drawboard()
pushStyle()
local z,c=0,0
for y=10,1,-1 do
for x=1,10 do
z=z+1
c=board[z]
if c==0 then
fill(0)
elseif c==88 then
fill(64,64,64)
else
fill(col[c])
end
rect(30+x*size,360+y*size,size,size)
fill(0)
if c>0 and c<13 then
text(c,30+x*size+size/2,360+y*size+size/3)
end
end
end
popStyle()
end
function showPieces()
pushStyle()
rectMode(CENTER)
fontSize(10)
local rr=rect local tt=text local pp=piece local v=0
local tab={0,0,0,0,0,0,0,0,0,0,0,0}
for z=1,12 do
v=used[z]
if v>0 then
tab[v]=1
else
tab[v]=0
end
end
for z=1,#show do
for w=1,#pp[z][1] do
fill(col[z])
if tab[z]>0 then
fill(255)
end
v=pp[z][1][w]
rr(show[z].x+(v%10)*20,show[z].y-(v//10)*20,20,20)
fill(0)
tt(z,show[z].x+(v%10)*20,show[z].y-(v//10)*20)
end
end
popStyle()
end
function printTotals()
pushStyle()
textMode(CORNER)
font("Courier-Bold")
text("used ",50,300)
text("rotate ",50,270)
for z=1,12 do
text(used[z],100+z*30,300)
text(rot[z],100+z*30,270)
end
text("try count "..trycount,125,210)
text("fit count "..fitcount,125,180)
text("solutions "..solution,125,150)
popStyle()
end
function nextboard()
for z=1,100 do
if board[z]==0 then
return(z)
end
end
return(0)
end
function nextpiece(curr,val)
local loop,dup=true,0
used[curr]=val rot[curr]=1
while loop do
dup=0
for z=1,(curr-1) do
if used[curr]==used[z] then
dup=1
used[curr]=used[curr]+1
break
end
end
if dup==0 then
loop=false
end
end
return(0)
end
function checkfit()
local pp=piece local b1=nextopen local p1=used[pieceoffset]
local p2=rot[pieceoffset] local offset
trycount=trycount+1
for z=1,#pp[p1][p2] do
offset=b1+pp[p1][p2][z]
if board[offset] ~= 0 then
return(0) -- wont fit
end
end
for z=1,#pp[p1][p2] do
offset=b1+pp[p1][p2][z]
board[offset]=p1
end
here[pieceoffset]=b1
fitcount=fitcount+1
return(1) -- fit ok
end
function pieceused(val)
for z=1,12 do
if used[z]==val then
return(1)
end
end
return(0)
end
function removepiece()
local pp=piece local b1=here[pieceoffset]
local p1=used[pieceoffset] local p2=rot[pieceoffset]
for z=1,#pp[p1][p2] do
offset=b1+pp[p1][p2][z]
board[offset]=0
end
end
function addone()
local r,lp,u
while 1 do
r=rot[pieceoffset]+1
if r<5 then
rot[pieceoffset]=r
return
end
lp=true
while lp do
u=used[pieceoffset]+1
if u<13 then
if pieceused(u)==0 then
used[pieceoffset]=u
rot[pieceoffset]=1
return
else
used[pieceoffset]=u
end
else
used[pieceoffset]=0
rot[pieceoffset]=0
pieceoffset=pieceoffset-1
removepiece()
lp=false
if pieceoffset==0 then
exit()
end
end
end
end
end
```

]]>Every column of small rectangles is a Fib(N) value, written vertically in binary, with lowest bit at the bottom. Looking at the picture, it is quite clear that the dependency between N and the number of bits to represent Fib(N) is linear. I'm curious though, how to mathematically prove that... (I'm sure @LoopSpace can do that in like 5 seconds, but still... :) )

Code is here, if anyone needs it:

--# Main
-- Fibobits
displayMode(OVERLAY)
displayMode(FULLSCREEN)
-- Use this function to perform your initial setup
function setup()
A,B = 0,WIDTH/5
bitSize = 5
i = 0
nums = {{ 1 }, { 1 }}
for i=3,B do
nums[i] = add(nums[i-2], nums[i-1])
end
print("prepped: " .. B)
end
function add(a, b)
local c = {}
local n = math.max(#a,#b)
local carry = 0
for i=1,n do
c[i] = (a[i] or 0) + (b[i] or 0) + carry
if c[i] > 1 then
carry = 1
c[i] = c[i] - 2
else
carry = 0
end
end
if carry > 0 then
c[n+1] = 1
end
return c
end
-- This function gets called once every frame
function draw()
-- This sets a dark background color
background(40, 40, 50)
-- This sets the line thickness
strokeWidth(2)
-- Do your drawing here
if fibImg then
translate(WIDTH/2, HEIGHT/2)
sprite(fibImg)
else
pushStyle()
text("Preparing image ...", WIDTH/2, HEIGHT/2)
stroke(85, 83, 140, 255)
noFill()
rect(WIDTH/2 - 150, HEIGHT/2 - 50, 300, 20)
fill(95, 92, 111, 255)
noStroke()
rect(WIDTH/2 - 150, HEIGHT/2 - 50, 300*i/(B-A), 20)
popStyle()
co = co or coroutine.create(function()
local img = image(WIDTH, HEIGHT)
local count = 0
local s = bitSize
setContext(img)
i = 1
while i<=B-A do
local b = nums[i+A]
for j=1,#b do
count = count + 1
if b[j] == 1 then
rect(i*s,j*s,s,s)
end
if count % 1000 == 0 then
setContext()
coroutine.yield()
setContext(img)
end
end
i = i + 1
end
fibImg = img
setContext()
end)
coroutine.resume(co)
end
end

]]>I guess the psuedo code below explains it a bit better, even though it does not work this way.

```
-- Set state in the class
self.state = self:move
-- Call state the main draw function
ball.state()
```

]]>www.udemy.com

I have no idea what the udemy system is like pedagogically, whether it's effective or not. It seems primarily lecture-based, which I'm not sure I have the patience for. At these prices I don't mind signing up for a couple. (it should also be pointed out that there's a tonne of great free tutorials online, such as codecademy.com )

]]>I feel like it would be an absolute pain to set up. ]]>

**Boalen**
• Moving
• You can see true or false
• You can edit them in the script:

```
if boalen1 == true then
boalen1 = false
else
boalen1 = true
end
```

Or this:

```
-- b1 is the value that you need
b1 = Boalen(500, 500, true)
-- here is the example
if b1 == true then
alert("b1 is true")
else
alert("b1 is false")
end
```

**TextBox**

```
Isn't made by me. I don't tell.
```

**Button**
• Edit by me and made easier
• Clicked only if you leave your finger ( touch.state == ENDED )

Here's my effort. Suggestions, contributions, pull requests etc welcome.

https://github.com/Utsira/Soda

Gorgeous and powerful GUI/ button library for Codea projects.

I'm calling it Soda as it is inspired by Cider (but is not a fork).

Positions and dimensions of elements are defined relative to the parent of the element (ie the frame or window that they are in). Positions can be defined relative to any edge of the enclosing frame, or as a proportion of the parent frame. Decide a window is too cluttered? No need to move all of the elements around, just resize the parent window.

Elements automatically and intelligently resize when device orientation changes

A collection of elements can be moved around the screen, hidden or made inactive, just by addressing the parent of the collection

Drawing and touching are automatically handled in order to get the correct draw and touch order so that, for instance, it is not possible to touch an element through an overlying window.

196-sample Gaussian blur shader used for proper drop-shadows and blurred panel effects

True rounded-rectangle mesh with an anti-aliased stroke, allows for translucent rounded-rectangles

Graphics kept largely separate from button logic (in the Style tab), making Soda very easily customisable and skinnable

**Frame**. A container for other UI elements (a window).**Button**. One press to activate a callback. Has a variety of built-in defaults for frequently-used interface elements such as the settings gear, the hamburger menu button etc.**Switch**. Toggles on and off.**Segment**. Horizontally segmented buttons that activate different frames/ panels.**List**. A vertically scrolling list of elements that the user can select from. Has elastic snap-back when user scrolls past edge of list. Can easily be set up as a drop down list for auto-populating a text field.**TextEntry**. A text entry field with a touchable cursor, and scrolling if the input is too long for the field.**TextWindow**. A window for handling scrolling through large bodies of text.Various alerts and dialogs.

Sliders.

Improvements to TextEntry:

Be able to select a word with a double-tap, or the entire field with a triple-tap.

Be able to scroll the field leftwards by moving the cursor (currently you can only scroll leftward by deleting)

Add a factory for easier creation of the drop-down list seen in the demo

Various buttons in a segmented panel

An alert dialog with a blurred effect

A drop down list for autopopulating a text field

A window for scrolling through large bodies of text

Copy the contents of /SodaInstaller.lua. It is easiest to do this from the RAW page: https://raw.githubusercontent.com/Utsira/Soda/master/SodaInstaller.lua In Codea, long-press "+ Add New Project", and select "Paste into project".

]]>```
--dodgeball
displayMode(FULLSCREEN)
supportedOrientations(LANDSCAPE_ANY)
function setup()
w1=physics.body(EDGE,vec2(0,HEIGHT/4),vec2(WIDTH,HEIGHT/4))
w2=physics.body(EDGE,vec2(WIDTH,0),vec2(WIDTH,HEIGHT))
b=physics.body(CIRCLE,40)
b.x=WIDTH
b.y=HEIGHT/2
b.restitution=1
b.friction=0
b.linearVelocity=vec2(-(math.random(100,400)),30)
p=40
circnum=0
tx=20
ty=HEIGHT/4
player=physics.body(POLYGON,
vec2(tx, ty),
vec2(tx, ty+30),
vec2(tx+30, ty),
vec2(tx+30, ty+30)
)
player.info="c1"
b.info="c2"
end
function draw()
circnum = circnum +.1
if math.floor(circnum) == 10 then
--[[
b.x=WIDTH
b.y=HEIGHT/2
circnum = 0
ellipse(b.x,b.y,math.random(10,150))
p=math.random(30,60)
--]]
end
stroke(255, 255, 255, 255)
strokeWidth(3)
background(40, 40, 50)
line( 0, HEIGHT/4, WIDTH, HEIGHT/4)
fill(255)
ellipse(b.x,b.y,p)
rect(tx,ty,30)
if o==true then
text("collision",WIDTH/2,HEIGHT/1.5)
end
fontSize(25)
fill(255, 255, 255, 255)
end
function touched(t)
if t.state == BEGAN or t.state == MOVING then
tx=CurrentTouch.x
end
end
function collide(c)
if c.state==BEGAN then
if c.bodyA.info=="c1" and c.bodyB.info=="c2" or c.bodyA.info=="c2" and c.bodyB.info=="c1" then
o=true
print("collision")
end
end
if c.state==ENDED then
if c.bodyA.info=="c1" and c.bodyB.info=="c2" or c.bodyA.info=="c2" and c.bodyB.info=="c1" then
o=false
print("collision ended")
end
end
end
```

]]>What I mean by that, is breaking vectors up into separate x,y,z (scalar) values, and doing calculations on each separately - and avoiding expensive operations like square roots.

So this

```
function IsVisible(pos,radius) --pos is vec2
local p=pos+cameraDirection*tangentAdjust
local v=(p-cameraPos):normalize()
return v:dot(cameraDirection)>cosFOV
end
```

can be made over 4x faster with this

```
function IsVisible(pos,radius)
local px,py=pos.x,pos.y
local dx,dy=px-camposX,py-camposY
if dx*camdirX+dy*camdirY<0 then return end
local u=radius*tangentAdjust
local ptx,pty=px+camdirX*u-camposX,py+camdirY*u-camposY
local sq=ptx*ptx+pty*pty
local a=ptx*camdirX+pty*camdirY
return a*a>cosFOV2*sq
end
```

Simeon explains it like this:

]]>The performance difference appears to be due to allocations, every vector mult / sub / add has to allocate a new vector object as Lua user data to return its results. The overhead in the allocations accounts for all the difference in performance. I'm going to look into whether we can come up with an alternate memory allocator for lots of small short-lived objects. Note that this problem exhibits itself because the vectors are short-lived and created / deleted constantly. Using vectors in a more long-term scenario should be totally fine (the overhead will not really be noticeable without lots of operations).

If you know enough about C to help with the challenge below, please message Simeon.

He says ......

I spent some time looking at solutions for removing the need for allocations on vector objects.

The problem is that vec2 (and friends) are Lua "user data" objects, which are basically Lua-managed interfaces to C code and data. The problem is that performing operations on them needs to return a result, which needs to ask Lua to create a new user data. This causes Lua to allocate memory with its memory allocator. And that's the source of the performance difference.

Out of curiosity, I wrote a pure-Lua vec2 implementation and tested it on your benchmark. It was extremely slow (1000 iterations/frame vs. 8000 for user data).

There are only a few solutions I can think of, and some of them seem a bit infeasible.

- Modify the Lua interpreter to support native vector types. This would be pretty tricky and make keeping up-to-date with future versions of Lua quite hard.

- Find a faster memory allocator. I tried using LuaJIT's memory allocator with Lua and it seems a little faster, though not much. I'm pretty sure the generalised malloc/realloc/free are as fast as they get.
- Use a custom memory allocator that draws from a static pool rather than the heap. This would require some fixed memory size from which vectors can be drawn. The problem is you'd probably want to make this explicit in the code, or you'll run out of pool memory in general purpose applications.

Something like:

vec2.pool(20)

-- Do expensive vector loop, only 20 vectors can be allocated before old ones are reused

vec2.flush()

This is hard to implement in a bug-free manner though.

Use a vector-expression API where you pre-construct the expression tree then evaluate the expression with vectors as arguments, e.g:

local expr = vec2("someVec + someOther * (radius * 2.6) - pos")

-- In the loop

local v = expr:evaluate(a, b, c, d, e)

This is a bit clunky though. And it still allocates at least one new vector (v)

]]>function test:draw()

Texts:draw()

I'm trying to make my Codea project draw all my texts next to each other. I'm hoping I'm explaining this well I'm not very good at it. If anyone knows how please tell me :)

Thank you

]]>

StartMenu = class()
function StartMenu:init(x)
self.x = x
ironManM1 = readImage("Documents:iron man Mk1")
ironManM2 = readImage("Documents:iron man Mk2")
x = WIDTH/2
y = HEIGHT/2
end
function StartMenu:draw()
sprite(ironManM1, 100, 100)
end
function StartMenu:touched(touch)
end
function setup()
end
function draw()
StartMenu:draw()
end
function touched(touch)
end

]]>"Create a program that will allow the user to enter in the answer from a simple math problem. Both numbers for the question are in the range from 1 -> 99. If the user gets it right, a message tells them this and then increments the “Number Correct” count. If the user gets it wrong, a message tells them they got it wrong, tell them the correct answer and then increments the “Number Wrong” count. Both numbers should be generated randomly and the program should randomly select an operation each time as well (+, -, *, /). Also don't use the iPad keyboard to input the answer"

I would appreciate any input from anyone on how I would go about doing this. Thanks! :)

]]>2) If you have a text, How to make in the if-clause:

If "dHdedxe".. Andy content in ohne Word .. "Htcevik"

Example: "/open".. Andy content

Or /kick

3) How to make with openUrl, that the Brouser isn't codea, that the Brouser is like the forum by code, in your app

4) Comming Soon! ]]>

I'm confident that I don't have the shortest solution for any level above medium (and probably for easier levels too).

Here's the levels and length of the shortest known solutions

**Tutorial**. Walkthrough

Cargo 101 - 3

Transporter - 4

Re-Curses - 5

Inverter - 10

From Beneath - 5

Go Left - 9

**Easy**

Double Flip - 5

Go Left 2 - 4

Shuffle Sort - 9

Go The Distance - 4

Color Sort - **kb1ibt: 7**, ~~8~~

Walking Piles - **MrMonkeydom: 8**,~~9~~

**Medium**

Repeat Inverter - 5

Double Sort - **elizarov: 7**

Mirror - 6

Lay It Out - 7

The Stacker - **witchudebuz: 6**,~~metropolist: 7~~, ~~8~~

Clarity - 6

**Hard**

Come Together - 7

Come Together 2 - **unsigner: 7**, ~~8~~

Up The Greens - [elizarov - 6]

Fill The Blanks - **[elizarov: 9]**

Count The Blues - **Myndale: 6**, achrenico: 8, ~~9~~

Multi Sort - **atrophic: 7**, ~~msalmonse: 10~~, ~~11~~

**Crazy**

Divide By Two - elizarov: 10

The Merger - 6

Even The Odds - [elizarov: 9]

Genetic Code - **wwboy6: 16**, ~~17~~

Multi Sort 2 - 17

The Swap - **achrenico: 7**,~~10~~

**Impossible**

Restoring Order - **[elizarov: 13]**

Changing Places - **[elizarov: 10]**

Palette Swap - **achrenico: 14**, ~~15~~

Mirror 2 - **nasapunk88: 7**,~~Andrew Stacey: 10~~, ~~ruilov: 12~~

Changing Places 2 - **Zou Chang: 6**, ~~cihana: 7~~, ~~achrenico: 8~~,~~spricklyTV: 9~~,~~Andrew Stacey: 10~~, ~~ruilov: 16~~

Vertical Sort - **Markus Mühlberger:18**, ~~20~~

**Bonus Levels**

Count in Binary - **[elizarov: 9]**

Equalizer - **[elizarov: 10]**

Parting the Sea - **[elizarov: 10]**

The Trick - **Tojot: 8**, ~~achrenico: 10~~, ~~qqq: 11~~

```
-- My Little Portal Demo 0.87
-- Simple Physics
-- Use this function to perform your initial setup
function setup()
touches = {}
function touched(touch)
-- When you touch the screen, create a random portal
function draw()
-- Store current style
function touched(touch)
function draw()
ellipse(CurrentTouch.x, CurrentTouch.y, 70, 125)
stroke(0, 75, 255, 255)
strokeWidth(4)
fill(118, 190, 211, 255)
end
function touched(touch)
function draw()
ellipse(CurrentTouch.x, CurrentTouch.y, 70, 125)
stroke(255, 128, 0, 255)
strokeWidth(4)
fill(211, 162, 118, 255)
end
end
end
end
end
-- Table to store our physics bodies
bodies = {}
-- Create some static boxes (not effected by gravity or collisions)
local left = makeBox(WIDTH/4, HEIGHT/2, WIDTH/3, 10, 0)
left.type = STATIC
local right = makeBox(WIDTH - WIDTH/4, HEIGHT/2, WIDTH/3, 10, 0)
right.type = STATIC
table.insert(bodies, left)
table.insert(bodies, right)
end
-- This function gets called once every frame
function draw()
-- This sets a dark background color
background(49, 49, 84, 255)
-- Draw all our physics bodies
for k,body in pairs(bodies) do
drawBody(body)
end
for i = 1,8 do
sprite("Documents:Floor", 0, 0, 10000, 200)
end
parameter.number("X", 0, WIDTH, X)
sprite("Documents:Chell", X, 110, 200, 200)
end
function touched(touch)
-- If the user drags their finger we'll
-- update the number slider controlling 'X'
-- This shows how code can affect parameter widgets
if touch.state == MOVING then
X = touch.x
end
end
-- Helper function to create a box using a polygon body
function makeBox(x,y,w,h,r)
-- Points are defined in counter-clockwise order
local body = physics.body(POLYGON,vec2(-w/2, h/2),
vec2(-w/2, -h/2), vec2(w/2, -h/2), vec2(w/2, h/2))
-- Set the body's transform (position, angle)
body.x = x
body.y = y
body.angle = r
-- Make movement smoother regardless of framerate
body.interpolate = true
return body
end
-- Helper function to draw a physics body
function drawBody(body)
-- Push style and transform matrix so we can restore them after
pushStyle()
pushMatrix()
strokeWidth(5)
stroke(255, 255, 255, 255)
translate(body.x, body.y)
rotate(body.angle)
-- Draw body based on shape type
if body.shapeType == POLYGON then
strokeWidth(3.0)
local points = body.points
for j = 1,#points do
a = points[j]
b = points[(j % #points)+1]
line(a.x, a.y, b.x, b.y)
end
elseif body.shapeType == CHAIN or body.shapeType == EDGE then
strokeWidth(3.0)
local points = body.points
for j = 1,#points-1 do
a = points[j]
b = points[j+1]
line(a.x, a.y, b.x, b.y)
end
elseif body.shapeType == CIRCLE then
strokeWidth(3.0)
line(0,0,body.radius-3,0)
ellipse(0,0,body.radius*2)
end
-- Restore style and transform
popMatrix()
popStyle()
end
```

]]>1) Question: Is it possible to connect a server to apps made with codea??

2) Can you create a local server to codea (in codea), because then we could try to work with servers on Lua.

3) Thx for answering me the question and for listening to my idea.

]]>Thanks

]]>Just sharing a fun little project that started when I was teaching my son to make a zelda clone ... Eventually it turned into this simple split screen topdown shooter . We're having a blast machine gunning each other so I'll keep on working on it.

Current weapons are gun, machine-gun, shotgun, railgun, planning on making a "bounce gun" (bullets bounce of walls) and a rocket launcher. Drawing pretty tiles is damn hard though so proper art might never come... Currently tiles are binary (either walk through or not) but i will probably add a third type that allows shooting through...

Anyway, I'm looking for any gameplay ideas that we didn't think about..

Cheers

]]>