tentus wrote:zac352 wrote:Why is it that all you microsoft/adobe folks always have trouble with the idea that computers operate on an iterative cycle?
Hey, I'm an MS/Adobe guy and I understand iteration. Quit with the generalizations, it only serves to chase people away.
Sorry, but I have to at least seen 5 of these threads so far about not understanding iterative rendering cycles.
I never really realised that it'd be a difficult thing to understand, as it simply clicked for me while I was learning Lua. I really never thought about it until I came here...
This place is really difficult, because it propagates hurdles that I have never encountered before... It really makes you feel like an alien or a robot or something.
This is probably my oldest unedited script I can find:
Code: Select all
tri1={{1,0},{1,1},{0,0}}
point={.25,.25}
c=0
for i=1,3 do
pointb=tri[i]
pointc=tri[i+1<4 and i+1 or 1]
pointa={point[1]-pointb[1],point[2]-pointb[2]}
pointx={pointc[1]-pointb[1],pointc[2]-pointb[2]}
rot=AngleFromSlope(pointx[1],pointx[2])
rot2=AngleFromSlope(pointa[1],pointa[2])
if rot2-rot>0 and rot2-rot<180 then
c=c+1;
end
end
if c==3 then
print("Collision")
else
print("No collision")
end
It's my first attempt at collision detection ever. It took me weeks to figure out the math for it, and I eventually discovered that it doesn't work. I believe AngleFromSlope was my old function I used before figuring out what math.atan2 does.
JRascall wrote:Thanks for that, Its helped me out alot, any chance you would know how make a floaty effect so its constantly moving, am guessing using a loop?
If you have the numbers stored in a value in memory, you can modify those values in love.update each frame to change the position of the window relative to each time reference. I recommend multiplying the update value by dt to keep it moving at a constant rate, though.
Here's an example:
Code: Select all
function love.load()
myPrettyBox={ --declare our pretty box to draw on screen
x=0;
y=0;
w=200;
h=100;
}
end
function love.update(dt)
myPrettyBox.x=myPrettyBox.x + 50*dt --move it to the right by 50 pixels every second.
myPrettyBox.y=myPrettyBox.y + myPrettyBox.y*dt --double position every second
end
function love.draw()
love.graphics.setBackgroundColor(255,255,255) --Set the bg to white
love.graphics.setColor(0,255,0) --myPrettyBox will be a lovely green
love.graphics.rectangle(
"fill", --Draw it filled with beautiful colour
myPrettyBox.x, --x position
myPrettyBox.y, --y position
myPrettyBox.w, --width
myPrettyBox.h --height
)
end
Edit: There seemed to be more comments while editing that in gedit...
Hello, I am not dead.