Hello! I'm back with a new project, albeit, a project that I already know I'm not going to be able to finish. Evil or Very Mad

Self-demoralization aside, I have been working hard on this (and on my schoolwork so I can get to this project in the first place), and I have what every Minecraft game needs: a terrain generator! My next step will be to implement Steve and all of his animations (they're all just rotations thankfully Razz).

This is a chunk (32x32) sample generated using yours truly Perlin Noise:


Right now, there seems to be a transposition error that is shifting the tilemap 8 blocks up from where it's supposed to be (meaning there are 8 extra layers at the bottom), but that can be fixed tomorrow. Cool


Oh... And the major features I plan to include in my game:
    placing and destroying blocks Razz
    mobs (both friendly and hostile)
    day-night cycles
    water bodies
    biomes
    farming
    villages?


...And the major features that will not be included (well... maybe eventually):
    caves (I don't know how I would implement these)
    nether (maybe eventually)
    end
    multiplayer
    TNT? (If I do end up implementing it, it's going to be very primitive)
    redstone



Cool! Also, I would LUUV feedback on possible game elements you would like to see in my Minecraft game! Good Idea
Looks great so far man! Speed is good too Smile.

How many blocks will you include?
*Small Progress Repo*

added:
trees
ores

into the terrain generator Smile




tr1p1ea wrote:
Looks great so far man! Speed is good too Smile.

How many blocks will you include?


It will be an infinite world... or in other words, the maximum capacity of memory the CE will let me store the world in (65kB?) Razz
How is this coming? Any new updates? It's been 3 months Razz

This looks really good, hope you're planning on doing more with it! Also please make the sky blue lol
*necro-bump

I started this project back up (let's see how long I work on it this time before I take another unneeded hiatus).

I've been mostly working on pseudo-coding the project to (hopefully) ensure maximum structural integrity when I start typing the actual meat of the code.

One of the first things I tried to set up was a struct containing a block's given properties. I would then make an array of those structs to represent the properties of all the blocks in minecraft as per:

data.h

Code:
#ifndef DATA_H
#define DATA_H

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <tice.h>

#define TILE_COUNT 32
#define MAX_BLOCK_TILE_COUNT 32

#define NO_YIELD         0
#define NO_TOOL            0
#define NO_HARDNESS         0

// Tile Index Definitions (Blocks)
#define AIR             0
#define STONE             1
#define GRASS             2
#define DIRT             3
#define COBBLESTONE       4
#define COAL_ORE          5
#define DIAMOND_ORE       6
#define GOLD_ORE          7
#define IRON_ORE          8
#define BEDROCK          9
#define OAK_SAPLING       10
#define OAK_LOG          11
#define OAK_PLANK         12
#define LEAVES            13
#define SAND            14
#define SANDSTONE         15
#define CACTUS            16
#define CRAFTING_TABLE      17
#define CHEST            18
#define FURNACE_OFF         19
#define FURNACE_ON         20
#define DEAD_BUSH         21
#define FLOWER_YELLOW      22
#define FLOWER_RED         23
#define FLOWER_PINK         24
#define BED_LEFT_SIDE      25
#define BED_RIGHT_SIDE      26
#define OAK_DOOR_BOTTOM      27
#define OAK_DOOR_TOP      28
#define LADDER            29
#define WATER            30
#define LAVA            31

typedef struct {
   
   uint8_t yield; // Index of the item that it gives you when you break it.
   uint8_t required_tool; // required tool to successfully harvest item
   uint8_t best_tool; // best tool to harvest item (e.g. sand - shovel, cobweb - shears)
   uint8_t hardness; // 0 (instant breaking) - 255 (obsidian)
   
   /*
   Pointer to a function that will contain a certain block's unique properties such as:
      - abides by gravity
      - gives off light
      - puts you on fire
      - makes you sink
      - slows you
      - etc.
   */
   void (*unique_properties)(void);
   
} block_t;

extern block_t blocks[MAX_BLOCK_TILE_COUNT];

#endif


data.c

Code:

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <tice.h>

#include "data.h"

block_t blocks[MAX_BLOCK_TILE_COUNT];

blocks[AIR].yield = NO_YIELD;
blocks[AIR].required_tool = NO_TOOL;
blocks[AIR].best_tool = 0;
blocks[AIR].hardness = NO_HARDNESS;
blocks[AIR].unique_properties = NULL;


When I compile the project, I get an error on all of the lines where I tried to store values into the struct array:

Code:

C:\....\Minecraft\src\data.c
C:\...\SRC\DATA.C      (10,11) :       ERROR (100) Syntax error
C:\...\MINECRAFT\SRC\DATA.C      (10,20) :       WARNING (221) Type defaults to int
C:\...\MINECRAFT\SRC\DATA.C      (11,11) :       ERROR (100) Syntax error
C:\...\MINECRAFT\SRC\DATA.C      (11,28) :       WARNING (221) Type defaults to int
C:\...\MINECRAFT\SRC\DATA.C      (12,11) :       ERROR (100) Syntax error
C:\...\MINECRAFT\SRC\DATA.C      (12,24) :       WARNING (221) Type defaults to int
C:\...\MINECRAFT\SRC\DATA.C      (13,11) :       ERROR (100) Syntax error
C:\...\MINECRAFT\SRC\DATA.C      (13,23) :       WARNING (221) Type defaults to int
C:\...\MINECRAFT\SRC\DATA.C      (14,11) :       ERROR (100) Syntax error
C:\...\MINECRAFT\SRC\DATA.C      (14,32) :       WARNING (221) Type defaults to int
C:\...\MINECRAFT\SRC\DATA.C      (14,43) :       ERROR (195) Initializer is not assignment compatible


I was wondering how to fix these errors so I can eventually use the struct array to something of this effect in the program:


Code:

uint8_t i =0;
for( i = 0; i < MAX_BLOCK_TILE_COUNT; i ++ ) {
   if ( block[i].yield == <index> ) {
      <Do stuff here>
   }
}



Edit:

Thanks to jacobly for this code fix Smile:


Code:
block_t blocks_zds[MAX_BLOCK_TILE_COUNT] = {
    { NO_YIELD, NO_TOOL, 0, NO_HARDNESS, NULL, }, // AIR
    { NO_YIELD, NO_TOOL, 0, NO_HARDNESS, NULL, }, // STONE
    { NO_YIELD, NO_TOOL, 0, NO_HARDNESS, NULL, }, // GRASS
    { NO_YIELD, NO_TOOL, 0, NO_HARDNESS, NULL, }, // DIRT
};
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are GMT - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement