New games every week!
Copy + Paste
Blog
11th April 2023
In all my years of making so many many many games, I've usually written code in such different languages that the ability to copy huge chunks of code and paste it into a newer version of a project, in a different language, is well and truly beyond the capabilities of the various languages.
-=-=- In recent years, I've taken to reusing the same set of arrays. The plr[] array is for the player, the grid[] array for the level data, things like that. It's a shorthand so that I don't always have to sit and wonder what the variable names might be for this week's game, and instead just type things like "plr[50]+=10" to give the player 10 points, or "plr[1]=300" to move them along to X position 300. But each language is unique, and has its own little quirks. I can't, for example, copy a swathe of Blitz3D code and paste it into MonkeyX, without then having to dig through and bit-by-bit fix all the broken code. Fixing broken code is a RIGHT pain in the arse! Redo From Start is typically much better. Which brings us to yesterday, and my realisation that my C++ code is remarkably similar to my Javascript code, and .. .. Could I!?!! Less than about 10 minutes later, Platdude was running around the level with only a couple of minor quirks, most of which have occurred because I shifted some of the sprites on the spritesheet. And that's the only reason those errors occurred. The rest honestly ran flawlessly. The actual interaction code will need to be tweaked because of how I created the "isSolid()", "isFloor()", etc functions. The idea of overloading functions doesn't quite work the same way in Javascript as it did in C++, but I should be able to flick through the code and get that working, fairly well. I think... Maybe! You can Test the engine here. You have to click to start the engine. WASD to move K to Hold J to Jump Left L to Jump Right I will toggle the camera zoom (and also restart the music, for testing purposes!) Like I say, there's currently no interaction with objects, so you can't pick up the spheres, or use the triggers, or get killed by the spikes. You can at least hold on to the hooks, use the ladders and other such things. It's really quite impressive that I didn't have to code any of that!! The animations, the movement, everything. He even does that wiggle when holding on to the hooks, if you point him in the other direction. This is the identical wiggle to the 2018 version, because it's the identical code to the 2018 version!! .. What I DID have to code, though, was the display code, and the input code. Layout the sprites onto new sprite sheets, find a way to grab the current spritesheet when the level loads, and use just that for the game. I had to code the inputs well enough that they stand up to AZERTY/etc keyboard layouts. I've tested in Windows with different layouts, and either it's working flawlessly, or VM-based Win11Arm on a Mac is lying to me!! Today's todo list. 1. Get Gamepad input working 1b. Give up even thinking about getting Touchscreen controls even barely functional. 2. Get objects interactions working 3. Try to get the test level working from start to finish Let's a-go! Views 50, Upvotes 12
Daily Blog
,
Jnkplat
New games every week!
|