Re: CodeName: DontGoLeft
Posted: Thu Aug 04, 2011 2:32 pm
its strange that your poll has no 'no' ._.
UmmGijsB wrote:I have been working on Minecraft2D, pretty much the same, but mine doesnt crash when going left, it actualy never crashes
the only problem is that it goes pretty slow when using normal LÖVE instead of LÖVEJIT
here :
(re-run when stuck or re-run when below landscape X3)
Isn't that slower than detecting collision in the first place?!if math.sqrt((x1-x2)^2+(y1-y2)^2) < 100 then--you dont have to check collision with blocks that are not closeby
I decompiled terraria a while ago to look at the source but they've got so many files it scared me off.kraftman wrote:I have no idea how terraria does it.
I thought it would be interesting to see how much i could do purely in code:
For each type of block, i make a few variations of colour, and then i check the blocks around the current block, and make a random edge based on what it finds.
There is probably a better way to do it but I havnt thought of it yet. This way means there is a large amount of variation and a finite amount of images generated.
The grid layout of the blocks makes collision detection nice and simple, you can pretty much just floor the player x and y and you have the location of the block that the player is potentially colliding with.
I think terraria precalculates the entire world (since it is finite) which is why it loads more smoothly. I planned on moving the code that creates the new tiles/framebuffers over into a thread, but it seems its a lot more complicated than I thought, so I'll have to think of something else.Trappingnoobs wrote:
I decompiled terraria a while ago to look at the source but they've got so many files it scared me off.
Your code approach is great. If you make the transition between things smoother like terraria does, it'd be amazing.
Don't you have to test multiple blocks for collisions though? I saw some almost transparent lines seperating blocks of something like 10x10 tiles, I assume you check for collisions in any block the player's in?
Also, are there any tutorials on framebuffers you can link me to? I've never bothered using them but they do seem to be used quite a lot so I expect from that that it's good practise to use them.
Lines are still there. I like how the blocks sort of give up chasing after you if you keep away from them too long.kraftman wrote:I think terraria precalculates the entire world (since it is finite) which is why it loads more smoothly. I planned on moving the code that creates the new tiles/framebuffers over into a thread, but it seems its a lot more complicated than I thought, so I'll have to think of something else.Trappingnoobs wrote:
I decompiled terraria a while ago to look at the source but they've got so many files it scared me off.
Your code approach is great. If you make the transition between things smoother like terraria does, it'd be amazing.
Don't you have to test multiple blocks for collisions though? I saw some almost transparent lines seperating blocks of something like 10x10 tiles, I assume you check for collisions in any block the player's in?
Also, are there any tutorials on framebuffers you can link me to? I've never bothered using them but they do seem to be used quite a lot so I expect from that that it's good practise to use them.
The thin lines are the overlap between framebuffers, the positions are slightly wrong because I was trying to stop them blurring sometimes.
Currently, the most blocks i need to check for collisions with at any one time is 5, 3 for the x and 2 for the y.
EDIT:
here's a quick update where you can actually collect the blocks, and hopefully the thin lines have gone too.
Wow. Your texture transitions are as good, if not better than, terraria's. I've so got to look at how you did that in the morning.kraftman wrote:Did he just add cows that fall from the sky? I think he did.