Minecraft 2D

Talk about making games.

Minecraft 2D

Postby Camper1995 » Sun May 29, 2011 5:51 pm

****************************
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?
Last edited by Camper1995 on Wed Jun 08, 2011 2:07 pm, edited 3 times in total.
Say hello to my little friend.
User avatar
Camper1995
 
Posts: 707
Joined: Tue Dec 30, 2008 7:20 pm
Location: Lost in the past.
Score: 44 Give a positive score

Re: Minecraft 2D development

Postby Game A Gogo » Sun May 29, 2011 6:14 pm

enable events only if in view!
Also WSOD appear (White screen of death, where you're game doesn't respond with a white screen)
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: Minecraft 2D development

Postby Camper1995 » Sun May 29, 2011 6:16 pm

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.
Say hello to my little friend.
User avatar
Camper1995
 
Posts: 707
Joined: Tue Dec 30, 2008 7:20 pm
Location: Lost in the past.
Score: 44 Give a positive score

Re: Minecraft 2D development

Postby savvy » Sun May 29, 2011 7:49 pm

*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 :)
Attachments
terrain_1.png
--> For my help, i ask for a simple +1 if it helps! ^-^
--> I dont code, I type art which you dont understand.
--> I keep winning the 3D model challenge at college, teacher says: "you keep winning im not giving you prizes".
User avatar
savvy
 
Posts: 494
Joined: Wed Jun 03, 2009 11:55 am
Location: England
Score: 44 Give a positive score

Re: Minecraft 2D development

Postby Camper1995 » Mon May 30, 2011 4:11 pm

Yeah. Well thanks anyway. I need to make inventory now. I used Skydereign's inventory menu but im stuck with one thing.
Say hello to my little friend.
User avatar
Camper1995
 
Posts: 707
Joined: Tue Dec 30, 2008 7:20 pm
Location: Lost in the past.
Score: 44 Give a positive score

Re: Minecraft 2D - need your help Skydereign

Postby skydereign » Tue May 31, 2011 4:17 am

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Minecraft 2D - need your help Skydereign

Postby Camper1995 » Tue May 31, 2011 3:52 pm

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:
Say hello to my little friend.
User avatar
Camper1995
 
Posts: 707
Joined: Tue Dec 30, 2008 7:20 pm
Location: Lost in the past.
Score: 44 Give a positive score

Re: Minecraft 2D - need your help Skydereign

Postby skydereign » Tue May 31, 2011 8:45 pm

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Minecraft 2D - need your help Skydereign

Postby Camper1995 » Wed Jun 01, 2011 1:15 pm

Thanks Sky. This was helpful! :wink:
Say hello to my little friend.
User avatar
Camper1995
 
Posts: 707
Joined: Tue Dec 30, 2008 7:20 pm
Location: Lost in the past.
Score: 44 Give a positive score

Re: Minecraft 2D - need your help Skydereign

Postby Lacotemale » Thu Jun 02, 2011 4:50 pm

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! :)
User avatar
Lacotemale
 
Posts: 285
Joined: Wed Dec 08, 2010 7:47 pm
Location: /home
Score: 7 Give a positive score

Re: Minecraft 2D - need your help Skydereign

Postby Camper1995 » Thu Jun 02, 2011 8:04 pm

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.
Say hello to my little friend.
User avatar
Camper1995
 
Posts: 707
Joined: Tue Dec 30, 2008 7:20 pm
Location: Lost in the past.
Score: 44 Give a positive score

Re: Minecraft 2D - need your help Skydereign

Postby jimmynewguy » Thu Jun 02, 2011 8:16 pm

receive events outside of vision -> no

that should help, last thing before close in the actor control panel
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: Minecraft 2D - need your help Skydereign

Postby Imperialjester » Fri Jun 03, 2011 2:53 pm

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.
User avatar
Imperialjester
 
Posts: 185
Joined: Wed Dec 08, 2010 5:39 pm
Score: 10 Give a positive score

Re: Minecraft 2D - need your help Skydereign

Postby Camper1995 » Fri Jun 03, 2011 3:51 pm

Jimmy! Thanks man!! This helped.

And Jester, I done it too. Good idea.

Thanks guys!

+1 to both of you ;)
Say hello to my little friend.
User avatar
Camper1995
 
Posts: 707
Joined: Tue Dec 30, 2008 7:20 pm
Location: Lost in the past.
Score: 44 Give a positive score

Re: Minecraft 2D - need your help Skydereign

Postby Imperialjester » Sun Jun 05, 2011 6:40 pm

Thank you
User avatar
Imperialjester
 
Posts: 185
Joined: Wed Dec 08, 2010 5:39 pm
Score: 10 Give a positive score

Next

Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest