ive tried to code just a simple line and make it go in a random direction and length but i cant find where to start
have you read some of the tutorials on the wiki link above?
Or the examples built into the program!
Start by writing down on a bit of paper exactly what you want to do then try and split that up into a series of steps - this is called designing your program and is often the best place to start.
When starting designing add as much detail as you need, as your experience level grows then you’ll be able to do more with less detail - this is called making progress and is a by product of concentrated effort!
Yes, programming, even in Codea, is hard. It usually takes quite a few hours of learning and practice before you can write any useful code.
It occurred to me recently that Codea is actually the best game / logic puzzle available for the iPad. It really is the best possible open ended sandbox game (if you like that kind of thing), like Minecraft it allows me to create anything, solve any puzzle. Rather than being limited to solving the puzzles that someone else has thought up (although I can do that as well), I can create my own puzzles, then solve them on my own - or with the help of others.
I can create puzzles, games, challenges for others to play with / use / solve - the only limit truly is not just my imagination but also the collected imagination of the whole Codea community - and the best part is that the game actually grows with me as my experience grows, in fact like the best MMO it’s actually growing all the time, even when I don’t participate - but unlike other MMO’s, I’m not penalised in the game for not playing for any length of time as the community is designed to help one another instead of competing against one another.
And if that’s not enough - playing this game can actually have some serious “real world” benefits - it can actually improve my chances of getting employed, it can pay for itself several times over - I can actually make real cash money from solving puzzles for other people, or for making puzzles, games, apps for other people.
When you look at this way - then without a doubt Codea is THE best game / app available for the iPad and IMHO the single most important one!
@Simeon - thanks again for letting me play this game!
+1 too!
I see it in exactly this way, and the sense of satisfaction is great. If you think the questions I ask on here are basic, there are plenty I wrestle with before finally solving. Have recently cracked a (for me) difficult table manipulation problem. Extremely good fun.
@epicurus101 - Nobody will (should) never think any less of you for asking basic questions, the basics are where we all have to start. And asking questions also helps others who might not be able to ask for themselves.
What does frustrate is when people ask for a solution without attempting to solve the puzzle themselves first - which is all the more obvious when you can see that they’ve not bothered to even read the built in docs / play with the built in examples or posted any code to support their question.
It just fills the forum with crap, reduces the “signal to noise ratio” and IMHO spoils the game for everyone else.
@Ignatz - amen! The real time raytracer shader is one of the most impressive things I’ve seen on the ipad in a long time, I remember when “The Last Starfighter” came out in the early 80’s - one (if not the first) use of CGI and Raytracing in the cinema - back when home computers only had 8 bits and between 1 - 64k (if you were lucky) of space, the idea that something like that could be done (and realtime no less) was the stuff of Star Trek! I remember reading a few years back that the scene where the camera panned across the hanger full of spaceships was the most complex scene ever rendered at the time and each frame took several HOURS to complete on a mainframe render farm.
Game on!
@Ray_Spahn There are several ways to create random lines. Depending on how you’re going to use them will depend on how you create them. Here’s 2 examples. One example ( byAngle ) draws a random length line at a random angle from the center of the screen. The other ( byPoint ) draws a random length line between 2 random points. Just tap the screen for another set of lines.
displayMode(FULLSCREEN)
function setup()
w=WIDTH/2
h=HEIGHT/2
byAngle()
byPoints()
end
function draw()
background(0)
stroke(255)
strokeWidth(2)
line(w,h,w+x,w+y)
line(x1,y1,x2,y2)
fill(255)
text("tap screen for new lines",w,HEIGHT-50)
end
function touched(t)
if t.state==BEGAN then
byAngle()
byPoints()
end
end
function byAngle()
ang=math.random(360)
len=math.random(100,400)
x=math.cos(math.rad(ang))*len
y=math.sin(math.rad(ang))*len
end
function byPoints()
x1=math.random(100,WIDTH-100)
y1=math.random(100,HEIGHT-100)
x2=math.random(100,WIDTH-100)
y2=math.random(100,HEIGHT-100)
end
@ignatz @techdojo @ epicurus101
ive tried to look at the wiki tab above and did not find what i am looking for
@dave1707 thank you but i was thinking of something different
i meant where the lines grow and turn in different directions
@Ray_Spahn Something like this.
displayMode(FULLSCREEN)
function setup()
tab={}
for z=1,50 do
table.insert(tab,lines())
end
end
function draw()
background(0)
for a,b in pairs(tab) do
b:draw()
end
end
lines=class()
function lines:init()
self.x=math.random(100,WIDTH-100)
self.y=math.random(100,HEIGHT-100)
self.len=math.random(20,80)
self.ang=math.random(360)
self.col=color(math.random(255),math.random(255),math.random(255))
if math.random(10)>=5 then
self.inc=-1
else
self.inc=1
end
end
function lines:draw()
stroke(self.col)
strokeWidth(2)
self.x1=math.cos(math.rad(self.ang))*self.len
self.y1=math.sin(math.rad(self.ang))*self.len
line(self.x,self.y,self.x+self.x1,self.y+self.y1)
line(self.x,self.y,self.x-self.x1,self.y-self.y1)
self.len=self.len+.1
if self.len>300 then
self.len=300
end
self.ang=self.ang+self.inc
end
@Ray_Spahn Here’s the same thing using translate and rotate if you don’t like math.sin and math.cos.
displayMode(FULLSCREEN)
function setup()
tab={}
for z=1,50 do
table.insert(tab,lines())
end
end
function draw()
background(0)
for a,b in pairs(tab) do
b:draw()
end
end
lines=class()
function lines:init()
self.x=math.random(100,WIDTH-100)
self.y=math.random(100,HEIGHT-100)
self.len=math.random(20,80)
self.ang=math.random(360)
self.col=color(math.random(255),math.random(255),math.random(255))
if math.random(10)>=5 then
self.inc=-1
else
self.inc=1
end
end
function lines:draw()
stroke(self.col)
strokeWidth(2)
pushMatrix()
translate(self.x,self.y)
rotate(self.ang)
line(0,0,self.len,0)
line(0,0,-self.len,0)
self.len=self.len+.1
if self.len>300 then
self.len=300
end
self.ang=self.ang+self.inc
popMatrix()
end
@Ray_Spahn - have you tried sketching out what you want, or modding one of the examples. Why not post some of your experiments so far so we can give you some better advice.
Thanks @ dave1707 is there a way to make it grow the ends of the lines
@Ray_Spahn line(x1, y1, x2, y2)
There’s also the “lines” example built-in, and documentation on the function.
@Ray_Spahn The lines get longer, but at a slow rate. I stop them from getting longer than 300. If you want them to get longer than that, remove the code that compare self.len > 300 .
@dave1707 thanks you so much for all the help especially on this holiday
One last thing how can I make them curve in a different direction