Coder Social home page Coder Social logo

jocelynwsj / miniminecraft Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 1.0 1.31 MB

An interactive 3D world exploration and alteration program in the style of the popular computer game Minecraft

GLSL 1.69% CMake 0.07% C++ 98.07% QMake 0.14% C 0.03%
opengl cpp computer-graphics-opengl

miniminecraft's Introduction

MiniMinecraft

It is an interactive 3D world exploration and alteration program in the style of the popular computer game Minecraft. We worked in group of three.

https://www.youtube.com/watch?v=UM3sVK046Ks

https://www.bilibili.com/video/BV1AE411J7rR

My part:

Game Engine Update Function and Player Physics

  1. Player: Use bool status[12] to record mode. Player's position can use Camera's position whose y need to minus one.

  2. Fly and jump: Both actions can be divided into rising process and landing process. In the rising process, give Player::velocity[1] a positive initial value and use int MyGl::flyLastFrame; to record the number of consecutive frames. Player::velocity[1] need to contact decrease based on flyLastFrame.

  3. Swimming

  • Altering the player's physics and controls when the player is touching a WATER or LAVA block to simulate swimming.
  • Adding overlay to cover the screen when player is swimming.
  1. Gravity: Give Player::velocity[1] a negative initial value in MyGL::timerUpdate(). And then make changes according to the mode or detection, if necessary.

  2. Collision Detection: Detection is divided into horizontal direction detection and vertical direction detection. bool MyGL::HerizCollisionDetect(glm::vec3 pos, glm::vec3 movetrend); bool MyGL::VertCollisionDetect(glm::vec3 pos, glm::vec3 movetrend); In the flying mode, only horizontal detection is needed. And in the other condition, detection of both direction are needed.

Multithreaded Terrain Generation

  1. Adding multithreading functionality to prevent the gameplay from slowing down when new terrain is generated to expand the world. Adding Worker class to complete FBM calculation in each thread.

Day and night cycle

I used the raycast method to create a procedural sky background. In Miniminecraft, one day lasts 2400 seconds, there are four main periods: Daytime, Sunset/Dusk, Nighttime, Sunrise/Dawn. The light direction and color also changed with sun and moon. To achieve smooth change of the sky color, I used mix function to generate color. Most code is in sky.frag.glsl, sky.vert.glsl.

  1. Daytime: (0~1200) Day time is the longest period in a day, lasting 1200 seconds. During this time, sun moves from east to west. The light direction will also change with it.

  2. Sunset/Dusk: (1200~1380) Sun descends on the western horizon. The sun will appear larger when it falls. The sky becomes darker, while the sky near sun changed to orange.

  3. Night Time: (1380~2220) The moon rises from east and stars shows up(I used Worley noise in 3D space to generate stars). The intensity of moonlight is half of sunlight.

  4. Sunrise/Dawn: (2220~2400) Sun rises up from east. The sun will also appear larger as it rises. Sky becomes lighter, while the sky near sun become orange.

miniminecraft's People

Contributors

jocelynwsj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

sanyamdtu

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.