MakeCode Kart

This is what I have now! It has pipes that work and are placeable now!

In the original V0.2 (that was going to get posted, but I fixed the game before the post was approved and deleted that post), the game lagged a lot (with random lag spikes worse than Minecraft Java), but I did an optimization that would only render the pipes in a range of 100 pixels so now the framerate is stable.

I will probably implement more tracks, playable characters, thwomps, MKSC style item boxes, items, cpu racers, and maybe even trees if it doesn’t lag too much.

2 Likes

@kwx Thanks for your so detail explainations. Make my understanding about these concepts more clear.
What I strugled with is

        out[0] = tx * cosHeading + sinHeading * tz
        out[2] = -tx * sinHeading + cosHeading * tz

At first I drew out, and understood the relationship between them. But it’s “-” instead of “+” at front of Y part in my result, like this:

        out[0] = tx * cosHeading - sinHeading * tz
        out[2] = -tx * sinHeading - cosHeading * tz

until I realized the Y( or v) and cy are “points down” in world coordinates. I used the coodination in my math class. :smile: But even after I knew this, still take a long time to adopt it in mind.

BTW, I love it because so effient it is, no angle calculation and the cosHeading/sinHeading are only trigonomic functions invovled, that can be reused in entire update() each time.
Thanks again, I learned a lot!

2 Likes

I’ve made bug fixes, item boxes (animations coming soon) with green shells that bounce off of walls and can hit you and mushrooms that speed you up. I’ve made turning work according to how fast you move, as well as better collision which checks your position for every pixel you move every frame instead of just your position every frame.

1 Like

If you guys want me too I know how to do really good art from images on google it takes a while but it’s fun and I’d like to be of help

how’s the game going?

Here’s a new version. It has trees, drifting, a lap timer, and other major changes.

(For historical interest, there’s also the earlier version 1.8.3 which I had tried to post on Friday but it hadn’t made it to the forum. That one had similar features but was slower due to using floating point math.)

Gameplay and user-visible changes:

  • Some basic car physics with inertia and drifting. It’s not at all realistic, but I think it’s kind of fun. Press A to boost, and B to drift. There’s a drift practice track in the northeast corner of the map.
  • Terrain slowdown/collisions
  • A lap timer triggered by crossing the finish line. (Yes, it’s possible to cheat. It would need check points to avoid that.) The score display is based on the lap time.
  • Improved performance on hardware compared to version 1.8.3 - I’m getting about 14fps on the PyGamer with trees enabled.

Internals changes:

  • Blocks support! The new Renderer category has “place image”. There’s two versions that both do the same thing, the “placed image is visible” one is useful if you need to change logic depending on if the image is in view or not. See version 1.8.3 for a demo of that.
  • The object drawing is now based on blitting images directly instead of scaling sprites, this should be a lot more efficient. It does its own visibility checks and Z sorting. I think you shouldn’t need the 100-pixel range limit anymore. (If it’s still an issue, use renderer.setZClipFar(distance) to adjust the render distance.) By default the images are attached at the bottom center, you can change that with the optional anchor parameter. The code is a bit less readable due to using fixed-point math, but that’s a lot more efficient.
  • Updated the background renderer to scale the image to match the field of view - this isn’t pretty but helps avoid motion sickness. You can use renderer.setBackgroundSolidColor(col) instead of renderer.setBackgroundImage if you prefer. I had added lots of comments about this, but the Blocks conversion deleted them. Sigh.
  • The renderer and maths code now live in separate files to de-clutter the Blocks view. To import this, use JavaScript mode, open Explorer at the left, and copy the renderer.ts and fx14.ts files to your own project. (This would be nicer as an extension, but I haven’t had time to package it yet.) I hope this will make it easier to import future changes.
  • Some fixes to the projection code to better attach objects to the ground. This slightly changes the visible view, you may need to tweak zNear and zFar to compensate.
  • The coordinate system is now based on texture pixel centers, not edges. This way, you don’t need to add 0.5 to center objects on pixels.

There’s also a few possible regressions where things work differently:

  • The player car is now always drawn in front of the 3d images. If that’s an issue, let me know - it’s fixable but I’m not sure if people care.
  • I removed the pixel-accurate attachX/attachY, let me know if you need this back. The new anchor (default is bottom center attachment) seemed simpler.
5 Likes

Thanks so much for all these optimizations! Are you done working on this project, or are you still working on the engine? I think the engine is pretty good in its current state and I could start making an official game with it if that’s okay with you. I was thinking I’d include some custom tracks, some smk tracks, some mksc tracks, and (maybe) some CTR Nitro GBA tracks. Anyone can help if they want to, but if you’re done @kwx, I’d like to add some features like stitching images together (to have a high track resolution, hopefully stitching up to 16 images to make some of the GBA tracks at their original quality.) I will also probably add back in projectiles to your new version, and more items. I just want to know if you are still working on this project so I don’t start an official development and have it be a few versions behind. ITS TOTALLY OKAY THOUGH IF YOU ARE STILL WORKING ON THIS, just please tell me. Also, I don’t really care about changes listed in the bullet points at the bottom of your post as it wouldn’t really affect a 2.5d racing game clone.

It’s a bit too fast for my liking, can you at least slow down the character a bit so it’s at somewhere of a normal speed

I’m done with it at this point - I mainly intended to do a tech demo to see if it’s feasible to do this kind of perspective transform in MakeCode Arcade, and I only added some basic racing features since it was fairly easy to do and helped with testing. I may reuse the code to make my own game at some point, but that would be a separate project.

Personally I’d strongly encourage going with original tracks and art. Getting inspired by other games is one thing, but outright copying assets is uncool, and could potentially also be copyright or trademark infringement. Fair use rules are not always obvious, but actually downloading tracks ripped from a game and importing them into your own game seems rather dubious and is the kind of thing that would normally require getting permission first.

3 Likes

The speed and acceleration are all adjustable, for example the dy(-3) for acceleration and the drag constants. I was largely testing on the PyGamer which has analog control. It’s way too twitchy when using touchscreen controls on a phone.

Hi there! Could you make a tilt control? Tilt forwards is throttle and backwards is brake! Tilt Left/Right to steer. I recently made a f1 steering wheel and want to put the meowbit with this game on it to play games with it! Thank you!

This is technically an unofficial fan project (very similar to this html5 project someone made), so I will probably rip some of the tracks, but I will definitely make originals too.

Also, on a different subject, I’ve completed a basic engine for Makecode Kart off of 1.9.4. This is not even close to the final product, and will be a collab, hopefully with people on this forum making different tracks and characters. I’ll add menus, and charactors in the future, as well as adding item boxes and items back (I havn’t tried to make moving objects yet, I’ll just hope they work lol!)

Thanks @kwx and I’ll put you at the top (or very close to the top) of the credits when the game has credits!

4 Likes

As far as the renderer is concerned, moving objects should work just fine. You can modify their locations in track coordinates in the update loop.

If you want rotating objects, you could for example have sprites for 8 different orientations (N, NE, E, …, NW), and then pick the appropriate sprite based on heading and rotation angles.

Roughly, something like spriteRotation = Math.round((360 - heading) * 8 / 360) % 8 to get a sprite number from 0 to 7 for a track-attached object. If the object is also rotating, try Math.round((360 - heading + objectHeading) * 8 / 360) % 8 using the angle difference. This is untested, and if things are spinning the wrong way try flipping the sign. (That’s an old tradition in 3D graphics programming, and is often easier than trying to reason out the correct sign ahead of time.)

About the tracks, check out Tom Scott’s video “YouTube’s Copyright System Isn’t Broken. The World’s Is.”. While that’s about copyright in the context of YouTube videos, I think it’s a good explanation about the difference between how people think/wish the laws work and how they are actually written and enforced. I’m not a lawyer or moderator, so I’m not going to tell you what to do or not do, but if you do want to go that route I’d prefer to stay out of this project going forward.

Last time I tried this, tilt control needed to be a configurable option that’s off by default. As soon as you read an accelerometer value, the simulator switches to a mode where mouse movements tilt the virtual device, and this is annoying and makes the controls borderline unusable on a touch device. For example, try activating tilt controls in Space Rocks 3D in the simulator.

2 Likes

Yeah, I basically went through all of Tom Scott’s videos and watched most of them a few years back, and I have watched that vid before. It probably is wrong to rip those tracks, even as an “unofficial” game dev project. I think if I do use them, I will manually recreate them and not rip/make them exactly the same. I know this might kind of be bad but I really want to play some mksc tracks (Idc about the other games that much because the themes are kind of bland) on a different platform than an emulator, and Nintendo’s track layouts are really good. I’m currently deving one of my own tracks, as well as I’m going to make menus soon.

1 Like

By the way I really want the pipes to have water come out when you hit it

Pretty good build, nothing wrong, sure but this makes me wonder if it’s possible to somehow add multiplayer

You shouldn’t put him at the top, he should be in the title. I cant beleive someone actually made a working and very optimized mode 7 game. He deserves to get a medal

Online multiplayer is impossible, unless you mean local co-op. if yes, then I’m thinking u’d have to basically either put 2 screens in one as a splitscreen, or you put both players in 1 screen but that would be a bit troublesome

I’ve made a custom track! Menus are still not developed yet but I (hopefully) will make them in the future.

3 Likes

jumping?