Craft game. Ship and walls.

@UberGoober If you’re looking for games you want to add to, do a search for starter games. I posted 20 of them. They’re something I coded because I was bored, but didn’t want to put a lot of time into them. I figured I would start something and let anyone else add to them and do whatever else they wanted.

@dave1707 I’m not really looking to build on things, not much, I’m more looking for projects I want to preserve from people who don’t come around anymore.

But occasionally that leads me to a neat project from someone who’s still around, like yourself—thankfully.

@dave1707 just noticed the cool explosion shader in the Shade app. Should you ever decide to fiddle with it, this project seems like a great place to use it.

@UberGoober It might look nice the first couple of time you see it, but after awhile you’ll probably get tired of seeing it.

@dave1707 of course no one ever tires of a black screen with a still frame of a pixel art explosion :wink:

I kid. It’s a very cool project.

@UberGoober You don’t see that constantly throughout the game. It’s also a screen that you don’t want to see.

@UberGoober I tried doing the explosion shader and it didn’t turn out very good. One problem is the ball is already past the camera view when the collision is detected so I would have to keep track of which direction the ship is going so I could add that to the camera position so the explosion is always in front of the camera.

@dave1707 a) I feel like I’m being a bit of a pest about this so I’ll leave it alone from here, b) even if you just use the same black screen you use now, except with a 3D animating shader explosion instead of a frozen bitmap explosion, it might look kinda cool, c) or heck, you could just fill the whole black screen with the explosion so you can’t see a dang thing behind it anyway

For no good reason I did a few tweaks to @dave1707 ’s game7.

I added some glows, and darkened the sky, and added a sun that gleams off the ground.

I couldn’t figure out how to control the color of the glows, otherwise I would have made the yellow balls glow yellow; right now all glows are green.

Anyone know how to control the glow color?

I also kind of added a craft spaceship.

I think I got it the right size, and I got it tilting correctly, and I got it traveling with the camera, but I couldn’t grok the math to keep it right in front of the camera at all times, so for now it’s fixed in one direction.

Anyone know the math to keep the ship centered in front of the camera?

@UberGoober Don’t like it. Too much going on.

@dave1707 to each their own. Is this more your speed? It’s basically the same colors as the original but with a tad more dramatic lighting.

Now the only thing that glows is the yellow balls, which I think is good because it calls attention to that game mechanic, which otherwise can be hard to notice. I do wish I could get them glowing yellow though.

But my whole original idea was just to get the craft spacecraft in there. Codea gives us a perfectly fine 3D spaceship, I thought, why not try to put it in?

I think I did a fine job of that, I just can’t do the camera math to keep it center screen.

The code can be changed however anyone wants as long as they don’t say they wrote it. Someone did that to one of my programs long ago after they change some variables names. This was originally written to show some Craft coding, so I wasn’t trying for anything dramatic. As for the 3D ship, you only see if from the back so it doesn’t need to be 3D. Try swapping the yellow balls with the 3D ship. That way you’ll see the ships from different angles, but I’m not sure what that would involve because you’d have to rotate the ship in the direction it’s moving.

I don’t want to take anyone’s credit; as you may have noticed I almost always credit the author right in the names of my zips.

The 2D ship always looked kind of jarring to me in these games, so I wanted to see how hard it would be to get a 3D ship behaving the same way. It actually should be pretty easy to get it to rotate to point the same direction as the camera, I guess, you could just take the x and z Euler angles from the camera and apply them to the ship. I still have no idea how you’d keep it center screen though. Maybe something with ray tracing? That’s another thing I don’t fully understand.

@UberGoober I seen that you always mention me whenever you post it. I post a lot of things for others to look at or to add to. So I don’t mind a lot of modifications. It’s just that in the past someone took one of my programs, made minor changes then claimed they wrote it. Maybe instead of showing a ship like I have, I wonder if something like a fighter jet display in its place would look OK.

I don’t think anything 2D will be as convincing as seeing the shadows change on even a simple 3-D spaceship model as it tilts left and right.

@UberGoober This code might help you.

viewer.mode=FULLSCREEN

function setup()
    bx,bz=0,0   -- initial block position
    vel=.2      -- velocity
    dir=0
    
    scene = craft.scene()
       
    ground=scene:entity()
    ground.model = craft.model.cube(vec3(1000,1,1000))
    ground.position=vec3(0,-10,0)
    ground.material = craft.material(asset.builtin.Materials.Standard)
    ground.material.map = readImage(asset.builtin.Surfaces.Desert_Cliff_Normal)
    ground.material.offsetRepeat=vec4(0,0,50,50)
    
    ship = scene:entity()
    ship.model = craft.model(asset.builtin.SpaceKit.spaceCraft2_obj)
    
    cam = scene:entity()
    cam.position=vec3(0,8,14)    
    cam.parent=ship   -- attach camera to ship
    c=cam:add(craft.camera, 120, .1, 1000, false) -- set camera values
end

function update(dt)
    scene:update(dt)
    ship.eulerAngles = vec3(0,dir,0)
    bx=bx-vel*math.sin(math.rad(dir))   -- calculate x value
    bz=bz-vel*math.cos(math.rad(dir))   -- calculate z value
    ship.position=vec3(bx,0,bz)        -- update ship x,z position   
    c.entity.eulerAngles=vec3(0,180,-Gravity.x*100)  -- set camera pointing direction
end

function draw()
    update(DeltaTime)
    scene:draw()	
    dir=dir-Gravity.x*3
end

Fantastic again! How did you learn about element.parent?

This version now has the 3-D ship working correctly, yellow-glowing moving orbs, and a new icon to match.

Who was it said something about not trying to please all the people all the time…?

Anyway four score and seven seconds ago I finished my latest iteration, which now has user-customizable sky, sun, horizon, and both the yellow ball and the green ball diffuse settings—and in addition to that, it has two presets, @dave1707’s original settings and my super-dark-super-glowy settings, so you can easily see two pretty darn distinct takes on the same game.

Also the code has been totally cleaned up, so no longer is my janky code randomly interspersed with dave’s clean, efficient code. Now my janky code is sensibly interspersed with dave’s clean, efficient code. :wink:

@dave1707 @UberGoober Both your original project (game7) & UberGoober’s modified version have been added to Codea Community Repo and are now downloadable using the WebRepo project.

Hopefully I’ve got the crediting correct here :smile:

@dave1707 I added your explosions to the game.

When you hit something the explosions go off and the screen shakes.

It’s kind of irritating tbh but also a little funny for that reason.

You won’t see them unless you toggle on the UberGoober presets or 3D explosions though.

In fact now the game starts out almost exactly like your first version—2D ship and all—and you can separately toggle off and on the 3D ship and the 3D explosions.

I say ‘almost exactly” because for some reason I couldn’t get the sky back to your starting colors, it always stays a little too dark.

@Steppers I’m not sure what I should do about WebRepo now—do you feel like you should approve this as an update or something?