Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

The Final Frontier

edited February 3 in General Posts: 1,958

Hi All,

That’s a well used phrase (the title I mean) but it is generally related to Space. Since I got my first iPad I have been playing around trying to learn how to emulate publicised games - mainly classics. One of which is Elite, published in 1984. That was a game changer for the gaming industry. Now, with the help of Craft I can pay a little homage to it - hopefully with more to follow.

I have posted previously showing my interest and had some help from @TechDojo. But for now I have posted a website with a video - a homage to the original BBC Micro Elite and the two geniuses who wrote it.

Elite Homage

Hope you like it.

Edit: Hi all, been messing about with the HTML on the website, just noticed video not loading. Edited and works now but you need double tap the grey box to get the video running. May have to move to YouTube if this gets messy.

Edit2: Modified the web page to get a better link to the video. Also edited a few ‘English’ errors. I suggest you boost the video up to full screen and - when you can see the rotating ships you may recognise something in the top left and bottom left. Forgot to remove them - need to edit them out.

Comments

  • Posts: 1,958
    All,

    Just tidy up the code and I'll post later. Also will post the next vid when I can get the ships sorted out.
  • edited February 5 Posts: 1,958

    All,

    Here is modified code using the assets available to all Codea users. The only thing you need to do is save the attached blackboard skybox images (just a simple black screen!!!) to somewhere convenient to you and set up the ‘galaxy’ path to that file. You can either tap the screen to change the model or use the parameter slider and the load button to change the model. Not some of these are legless character images. Code below, mostly extracted from the forum. Doesn’t include the sprite at the bottom of the screen, just demonstrates model movement and rotation.


    viewer.mode = FULLSCREEN function setup() -- galaxy = asset.documents.Dropbox path = asset.builtin.CastleKit mod, turns = 1, 0 parameter.integer("mod",1,#data,1) parameter.action("Load Model",function() buildModel(mod) end) setScene() buildModel(mod) end function update(dt) -- Rotate the entity e.eulerAngles = vec3(x,y,z) if CurrentTouch.state == MOVING then else if camZ > 8 then camZ = camZ - 1 else rot = rot-1 if rot > 360 then rot = 0 end CameraX = CameraX - 1 CameraY = CameraY - 0.8 CameraZ = CameraZ - 1 turns = turns + 1 end if turns >= 900 then mod = mod + 1 if mod > #data then mod = 1 end buildModel(mod) end end scene.camera.position = -scene.camera.forward * camZ e.eulerAngles = vec3(CameraY, CameraX, 180) scene:update(dt) end function draw() update(DeltaTime) scene:draw() end function touched(t) -- if t.state == ENDED then mod = mod + 1 if mod > #data then mod = 1 end print(mod) buildModel(mod) end end function setScene() -- scene = craft.scene() skyMaterial = scene.sky.material skyMaterial.horizon = color(255) scene.ambientColor = color(255, 0) scene.sky.material.envMap = craft.cubeTexture(galaxy[space[1]]) scene.camera.position = -scene.camera.forward * 5 CameraSettings = scene.camera:get(craft.camera) CameraX,CameraY,CameraZ = 0,0,0 rot = 0 end function buildModel(mod) -- Create a new entity if e then e:destroy() end output.clear() e = scene:entity() e.model = craft.model(path[data[mod]]) e.position = vec3(0,0,0) e.scale = vec3(1,1,1)*Rscale[mod]/32 camZ = 100 CameraX,CameraY,CameraZ = 180,180,0 turns = 0 end data = { -- "bridge_obj", "gate_obj", "king_obj", "knightBlue_obj", "knightRed_obj", "metalGate_obj", "shieldBlue_obj", "shieldRed_obj", "siegeBallista_obj", "siegeCatapult_obj", "siegeRam_obj" } space = { "blackbox" } Rscale = { 10,10,10,10,10,10,20,20,5,5,5}

    I will add improvements later - if you can improve this (most probably) please post your code for us. Also moving on to make the next vid.

    P.s. when you download the attached image rename it blackbox and add the name to the galaxy asset path in setup().

  • edited February 5 Posts: 1,958
    All,
    The two developers of Elite were ahead of their time and managed to fit all the code needed for a 3D space game plus a massive amount of data describing 8 galaxies together with their resident planets, 256 in each galaxy. Also for a trading system across the universe. All in 32K memory staggering. Apparently they used procedural generation with a fibonacci series from a seed, together with a carefully built long string to describe all 2048 planets. I think they used scrolling of binary numbers to achieve this. Tried to figure out how to do that in Lua, but no joy. Anyone have any ideas on that?
  • SimeonSimeon Admin Mod
    Posts: 5,438

    Nice! I just played with this

    To do procedural generation you might start by coming up with an encoding for a planet. Something like

    <diameter><biome><terrain-seed>

    Where biome is some enumeration of planet type (gas, earth-like, ice, barren, etc). And terrain seed is the random seed used to generate the terrain. It would be fun to generate an "endless" 2D star map where
    you can build a new universe by giving a new initial random seed

    Have you looked at the game "No Man's Sky"? That's a recent attempt at a space game with a procedurally generated universe

  • Posts: 1,958

    @Simeon - thanks for the feedback, checked on "No Man's Sky" - intriguing, more or less what I’d ultimately like to get to - I think it will take a little time, but I’m up for it. Thanks.

  • Posts: 1,958
    All,
    Just updated the website, not much added as busy trying to finish next videoo.
Sign In or Register to comment.