Page 1 of 17

Minecraft 2D

PostPosted: Sun May 29, 2011 5:51 pm
by Camper1995
****************************
Minecraft 2D.zip
(114.88 KiB) Downloaded 305 times

Hey guys. I havent posting anything for a long time. I talked with one my friend and we were talking about making Minecraft in 2D.
Not really Minecraft, but something similar to it.

I will post an example of how it could look like. There is nothing much you can do. Just smash objects!

Anyway, I have a question for you guys. As you can see, I will have many many clones of objects. How to make my game won't lag?

Controls: WSAD - movement
[0] - Hand
[1] - Pickaxe (on numpad)
2DMC.jpg


Give me feedback! I want to know what you think about it guys!

It's just an example. Don't take it serious that you can't do anything there!
Any ideas how to do crafting?

Re: Minecraft 2D development

PostPosted: Sun May 29, 2011 6:14 pm
by Game A Gogo
enable events only if in view!
Also WSOD appear (White screen of death, where you're game doesn't respond with a white screen)

Re: Minecraft 2D development

PostPosted: Sun May 29, 2011 6:16 pm
by Camper1995
They are.Those blocks are on "Dont draw but allow events" when out of view.

@GAG: Damn. I must think of some better tiles generator.

Re: Minecraft 2D development

PostPosted: Sun May 29, 2011 7:49 pm
by savvy
*sigh* I'm always too slow, goodluck to you.
I was going to do this after I finished my current game.

i would gladly work on this with you if you need help ^-^ idk if youve played minecraft much, but i have a lot of experience with it :)

bellow is the official tileset for minecraft :)

Re: Minecraft 2D development

PostPosted: Mon May 30, 2011 4:11 pm
by Camper1995
Yeah. Well thanks anyway. I need to make inventory now. I used Skydereign's inventory menu but im stuck with one thing.

Re: Minecraft 2D - need your help Skydereign

PostPosted: Tue May 31, 2011 4:17 am
by skydereign
Well there are things about that example that could be improved and made more user friendly, but the following scripts I think are what you wanted. Just replace the two global code scripts with these, and add an array itemHP.
Code: Select all
// adds an item to first available spot
int
addItem(int itemType)
{
    int i;
    for(i=0;i<16;i++)
    {
        if(inventory[i]==0)
        {
            inventory[i]=itemType;
            itemHP[i]=ITEM_HP[itemType];
            return(1);
        }
    }
    return(0);
}


// switches items but only use in events for inventoryDisplay
int
switchItem()
{
  if(selected>=0)
  {
    int temp = inventory[cloneindex];
    inventory[cloneindex]=inventory[selected];
    inventory[selected]=temp;
 
    temp = itemHP[cloneindex];
    itemHP[cloneindex]=itemHP[selected];
    itemHP[selected]=temp;
 
    selected=-1;
    return(1);
  }
  return(0);
}


// removes item inventory[index]
void
removeItem(int index)
{
    inventory[index]=0;
}

void
useItem()
{
  if(selected>=0)
  {
    if(inventory[selected]!=0)
    {
       itemHP[selected]--;
       if(itemHP[selected]==0)
       {
           removeItem(selected);
       }
    }
  }
}


Code: Select all
#define pickaxe_wood 1
#define pickaxe_stone 2
#define pickaxe_gold 3
#define pickaxe_iron 5
#define pickaxe_diamond 4
// used for addItem


int selected;
// holds the inventory spot currently selected
// used in switchItem


const int ITEM_HP[16] = {2,1,2,2,3,4};


ITEM_HP is an array that specifies the hp of the items. The useItem function uses the currently selected item (you can instead make it pass an index if you want). The function reduces the item's hp by one, and if it is zero remove it. I think that covers what you asked for.

Re: Minecraft 2D - need your help Skydereign

PostPosted: Tue May 31, 2011 3:52 pm
by Camper1995
Awesome. Thank you Sky!!

By the way, what do these numbers mean?
const int ITEM_HP[16] = {2,1,2,2,3,4};


And how can i write now to "hurt" the weapon. To make it's HP be less and less until it disapear.
I'm sorry for annoying you, I just dont get the code how it works exactly :roll:

Re: Minecraft 2D - need your help Skydereign

PostPosted: Tue May 31, 2011 8:45 pm
by skydereign
Code: Select all
const int ITEM_HP[16] = {2,1,2,2,3,4};

Those numbers represent the max hp of the items. The below are the indexes of that match with the above hp.
Code: Select all
#define pickaxe_wood 1
#define pickaxe_stone 2
#define pickaxe_gold 3
#define pickaxe_iron 5
#define pickaxe_diamond 4

So, the first one is ignored (as there is no item type 0), but then the [1] is the max hp for the pickaxe_wood, [2] is for pickaxe_stone, etc. In the addItem script it sets the item hp to equal the ITEM_HP.
Code: Select all
itemHP[i]=ITEM_HP[itemType];


Then in the useItem function it reduces the hp by 1. If the hp should be destroyed it will call removeItem. You can also put the code you want the function to execute there (or use a return and a switch). So, you can set the hp of items that should die after one use to 1, and two uses 2, hope that helps.

Re: Minecraft 2D - need your help Skydereign

PostPosted: Wed Jun 01, 2011 1:15 pm
by Camper1995
Thanks Sky. This was helpful! :wink:

Re: Minecraft 2D - need your help Skydereign

PostPosted: Thu Jun 02, 2011 4:50 pm
by Lacotemale
Believe it or not but I actually had this idea ages ago... I thought about it for a while but I knew it would be too complicated for me to do and ALOT of work. So I gave up on it before I even bothered starting! :D

Good luck with this project though, if I have time this summer I may try to help out! :)

Re: Minecraft 2D - need your help Skydereign

PostPosted: Thu Jun 02, 2011 8:04 pm
by Camper1995
Yeah. Well that would be nice if you'll help me. :)

The problem is that we must have a really really big amount of blocks (10000+) and that's just too much for GE.
So we have to "destroy" all around view.. or something like that.

I have no idea. I tried disabling their functions, but that didnt helped.

Re: Minecraft 2D - need your help Skydereign

PostPosted: Thu Jun 02, 2011 8:16 pm
by jimmynewguy
receive events outside of vision -> no

that should help, last thing before close in the actor control panel

Re: Minecraft 2D - need your help Skydereign

PostPosted: Fri Jun 03, 2011 2:53 pm
by Imperialjester
and you could up the fps and change movement compensation to yes.

EDIT: i downloaded the source and changed movement compensation to yes and it is faster.

Re: Minecraft 2D - need your help Skydereign

PostPosted: Fri Jun 03, 2011 3:51 pm
by Camper1995
Jimmy! Thanks man!! This helped.

And Jester, I done it too. Good idea.

Thanks guys!

+1 to both of you ;)

Re: Minecraft 2D - need your help Skydereign

PostPosted: Sun Jun 05, 2011 6:40 pm
by Imperialjester
Thank you