I am new to the Codea community and I am starting my first project, but I can’t seem to get a simple background to work. The background I am trying to create is a black background with white dots (stars) moving to like like they are going towards the screen. I have already spent a lot of time creating my own sprites and game music, so I don’t want to give up on this because of the background. If someone could give me some tips on how to create this background in working order, I would be greatly appreciative.
The bit invader example has a scrolling star background, you could look in there
@Rekneps Here’s an example of moving stars towards you. It’s set up for white stars, but if you want colors, comment out the line that says white stars.
displayMode(FULLSCREEN)
function setup()
col={color(0, 12, 255, 255), color(107, 145, 171, 255),
color(255, 243, 0, 255), color(168, 169, 97, 255),
color(255, 255, 255, 255), color(255, 150, 0, 255),
color(255, 0, 13, 255)}
nbrStars=150
st={}
for z=1,nbrStars do
c=math.random(7) -- colored stars
c=5 -- white stars
table.insert(st,vec4(math.random(WIDTH),math.random(HEIGHT),1,c))
end
speed=75
end
function draw()
background(40, 40, 50)
for a,b in pairs(st) do
fill(col[b.w])
ellipse(b.x,b.y,b.z)
xd=WIDTH/2-b.x
if xd<.05 and xd>-.05 then
xd=.1
end
yd=HEIGHT/2-b.y
if yd<.05 and yd>-.05 then
yd=.1
end
b.x=b.x-xd/speed
b.y=b.y-yd/speed
b.z=b.z+.1
if b.x<0 or b.x>WIDTH or b.y<0 or b.y>HEIGHT then
st[a].x=math.random(WIDTH)
st[a].y=math.random(HEIGHT)
st[a].z=1
end
end
end
Thank you all so much!