4x4k

4x4K

Drive your truck across the 3 environments in the fastest time possible.

Play 4x4K

Controls:

Up/Down - Accelerate/Reverse
Left/Right - Tilt the truck back and forth (just makes the back/front a bit heavier)
R - Restart Level
Space - Jump (only available every five seconds, indicated in the top right hand corner)
1/2/3 - Start Track 1,2 or 3

Tips:

Tilting is important to climb steep slopes. Jump can be used to get awesome times if you get it right. It can also be used to get you off your back used in conjunction with the tilt controls. Thats only really useful if you’re quite a long way through the track and don’t want to just restart.

Stuff:

I thought doing some physics in 4K would be interesting. This is a light weight verlet implementation. The truck thing was just going to be a test case for the tiny engine before writing something else but it seemed to turn out ok. Now I just need another idea for a physics game.

It’s barely under 4k at the moment. Java performed surprisingly well even when I had the option to turn on antialiasing (taken out due to space restrictions).

Comments and bug reports welcomed!

Kev

woot lol first 2 seconds experience…

http://img88.imageshack.us/img88/6064/wootfr9.gif


http://img88.imageshack.us/img88/wootfr9.gif/1/w640.png

I will now play it and edit to give comments ;D

EDIT:
Track 1: 35seconds
Track 2: 42seconds :frowning:

It’s great :smiley:
I like how the tilting brings an extra skill element to it. Also, you can use the jump to get awesome air and jump over some rocks.

Yeah, thats a special feature :wink:

Nice one!

Kev

Neatobuckets!! =D

Really nice graphics and solid physics (except for the inverted truck thing. ;))
My only complaints are that it feels like it either is too fast in general, or perhaps too “jerky” in the acceleration, and that getting stuck on your roof after having used the jump recently means you have to wait five seconds.

I’ll rethink the jump thing, acceleration I’ll try reducing it a bit and apply on a curve.

Anyone know how you get the inverted truck thing, I can’t get it here :frowning:

Kev

It happened only that once!

EDIT:

Level 1:
Hold down LEFT+DOWN.
Press R whilst keeping LEFT+DOWN down.

EDIT2:

I thought I would add that I have experienced this exception three times


java.lang.IllegalStateException: Buffers have not been created
	at sun.awt.windows.WComponentPeer.getBackBuffer(Unknown Source)
	at java.awt.Component$FlipBufferStrategy.getBackBuffer(Unknown Source)
	at java.awt.Component$FlipBufferStrategy.updateInternalBuffers(Unknown Source)
	at java.awt.Component$FlipBufferStrategy.createBuffers(Unknown Source)
	at java.awt.Component$FlipBufferStrategy.<init>(Unknown Source)
	at java.awt.Component$FlipSubRegionBufferStrategy.<init>(Unknown Source)
	at java.awt.Component.createBufferStrategy(Unknown Source)
	at java.awt.Window.createBufferStrategy(Unknown Source)
	at java.awt.Component.createBufferStrategy(Unknown Source)
	at java.awt.Window.createBufferStrategy(Unknown Source)
	at E.<init>(Unknown Source)
	at E.main(Unknown Source)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at com.sun.javaws.Launcher.executeApplication(Unknown Source)
	at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
	at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
	at com.sun.javaws.Launcher.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)


Happens all the time to me… wanna have some fun? hold down for a few sec, then jump. For me, at least, I hit the ground and go flying, about half the time the truck does that inverted trick.

A race condition between creating the buffer strategy on the main thread and the size of the window being changed on the EDT… Creating the BS on the EDT will help.

Also, looks like the the slpash screen image is missing:


Caused by: java.io.FileNotFoundException: http://www.cokeandcode.com/fourkay/truck/icon.gif
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
	at java.net.HttpURLConnection.getResponseCode(Unknown Source)


Not that we’d have lots of time to enjoy it with a 4k jar file =)

Dmitri

New version up:

  • Physics instability should be fixed
  • Jump can now be used any time
  • Minor graphical fixes

4096 bytes.

Kev

Added an applet version - saved some space doing it, interesting :slight_smile:

http://www.cokeandcode.com/fourkay/truck/

Kev

Good physics, apart from the inverted truck and jumping when your’e not the right way up.

Good game.

Really great physics.

One thing that seemed weird was the way you slow down so much when flying through the air?

By the way, no truck inversion here despite my best efforts :slight_smile:

It’s quite impressive the way you have mastered different physics systems one by one. What are your thoughts about verlet vs the system used in Phys2D/box2d?

Not sure why you’re seeing slow down in the air, there’s no damping at all so there shouldn’t be any force against the particles.

Verlet seems great for things that likely to be quite bouncy, implementing it was pretty simple following that paper. However, I did try box/box interaction originally and couldn’t get that stable.

Box2D would still be my choice for real stuff, but then I might have a non-4k play with verlet later also just to see if it’s really that hard or whether it was 4k making it a little hard to think about :slight_smile:

Thanks for playing all! :slight_smile:

Kev

PS. Incidentally, no one should be getting inverted trucks anymore. I was quite surprised to see Renoria reporting them still happening.

The only way to get boxes/cubes realistic in Verlet (not bouncy) is to have a 2d or 3d grid of spheres, and LOTS of springs to bind them all together. It drains performance, but it works!
4x4x4 cubes = 2226 + 6417 + 2811 + 8*7 = 744 springs (I might have missed a few)
The spheres must be overlapping a fair bit to get the shape solid, so don’t do sphere<->sphere collision.

Bounces around like a rock, or like jelly, depending on spring stiffness.

I think he was just repeating what was already posted, for the sake of it.

That advanced character physics paper seems to imply you can use SAT type collision with just four particles, one for each corner with 6 constraints per box. Didn’t want to work for me at least.

Kev

The problem is momentum and angular rotation.

That’s all a ‘side effect’ of Verlet integration, but the downside is that you need lots of particles.

4 (2x2 grid) spheres for a 2d box is certainly not enough, because it will deform too much, resulting in bouncy behaviour.

If you keep adding particles spheres to the grid (4x4 and up), the result gets better and better, as each sphere has it’s own momentum, and thus ‘correcting’ the abruptly moving spheres (those that are colliding).

If you have enough spheres, you can simulate everything any other physics engine can do, as the world around us is basically Verlet, until you get to the mulecule level and other forces that to take over. We just don’t have the processing power to simulate it, but it will certainly get very realistic if you add enough spheres and springs to your box.

N.B. The reason I’m using spheres instead of particles is that a particle-based box is basically hollow, while a sphere based box is solid, which is important for box<->box collision.

I like the vector-based graphics. Nice color scheme. The physics engine is amazing. You’ll have to teach us all about verlet physics one day. The truck is very difficult to control. I can’t make it through the first level unfortunately.