Jump to content


Photo

Minecraft Type Game Hotbar help


  • Please log in to reply
18 replies to this topic

#1 secondry2

secondry2

    GMC Member

  • GMC Member
  • 34 posts

Posted 08 December 2011 - 10:03 AM

Hello All!

Ok, i have made a game like minecraft, in game maker based on the block engine.
i need some help with a hot bar, where you can scroll to select blocks, and an image
of that block appears in the bottom right hand corner of the screen. Then the player
must right click to place them. i dont accually know how to go about doing this, so any
help would be appreciated, if you would like the gmk, or would like to try the game out so far,

HERE IS A LINK TO THE GMK (mediafire) : http://www.mediafire...irlyb1k9h3wcwrz



Thanks!
  • 0

#2 link3000

link3000

    Link3000

  • GMC Member
  • 1129 posts
  • Version:GM8

Posted 09 December 2011 - 01:04 AM

I assume you know how to program the selection part of the hotbar. For displaying it, use d3d_set_projection_ortho after you've drawn everything else to draw 2D items to the screen.
  • 0

#3 secondry2

secondry2

    GMC Member

  • GMC Member
  • 34 posts

Posted 09 December 2011 - 01:06 AM

I assume you know how to program the selection part of the hotbar. For displaying it, use d3d_set_projection_ortho after you've drawn everything else to draw 2D items to the screen.

yes i know how to display the 2d hotbar image.
  • 0

#4 link3000

link3000

    Link3000

  • GMC Member
  • 1129 posts
  • Version:GM8

Posted 10 December 2011 - 03:21 AM

So why are you asking for something different than you topic title?

Also ray tracing.
  • 0

#5 secondry2

secondry2

    GMC Member

  • GMC Member
  • 34 posts

Posted 12 December 2011 - 12:16 AM

i think you're going down wrong path, im trying to make it so when you scroll or press a number, it changes a variable, and when the player right clicks, he/she places that block.
  • 0

#6 ND4SPD

ND4SPD

    GMC Member

  • GMC Member
  • 2167 posts

Posted 12 December 2011 - 05:07 AM

Did you not just describe the process of achieving what you're trying to achieve...
  • 0

#7 secondry2

secondry2

    GMC Member

  • GMC Member
  • 34 posts

Posted 12 December 2011 - 09:52 PM

probably. but does anyone know how 2 do this?
  • 0

#8 Gamer3D

Gamer3D

    Human* me = this;

  • GMC Member
  • 1588 posts
  • Version:GM8.1

Posted 12 December 2011 - 10:25 PM

i think you're going down wrong path, im trying to make it so when you scroll or press a number, it changes a variable, and when the player right clicks, he/she places that block.


probably. but does anyone know how 2 do this?


Because you have given a description of what you want, let me tell you how to do it:
"Make it so when you scroll or press a number, it changes a variable, and when the player right clicks, he/she places that block."

You don't want help. You want someone to write simple code for you. Try going to the team request forum and asking for someone to do that. This is a place for help, not for us to write your game for you.

Alternately, go to the Novice Q&A forum and ask "How do I set a variable?"

Edited by Gamer3D, 12 December 2011 - 10:26 PM.

  • 0

#9 secondry2

secondry2

    GMC Member

  • GMC Member
  • 34 posts

Posted 12 December 2011 - 10:28 PM

i know, i c wat ur telling me, but i have tried exactly what you have said, i know how to set variables. its just i did that, and a random block kept on placing when i pressed a number. thats why im asking for help here.
  • 0

#10 link3000

link3000

    Link3000

  • GMC Member
  • 1129 posts
  • Version:GM8

Posted 12 December 2011 - 11:14 PM

Use the two scrolling events and then add or subtract 1 to your block type variable accordingly.

Ask for help in the Novice + Intermediate forums; your problem has nothing to do with actual 3D game programming.

If you want to continue here, post code of what you have done.
  • 0

#11 secondry2

secondry2

    GMC Member

  • GMC Member
  • 34 posts

Posted 12 December 2011 - 11:20 PM

ok, i accually deleted the code, but this is basically what i had:

if block_intersect(600)
{
if mouse_check_button_pressed(mb_right)
 if global.selected = 1  
 {
  add_ball(x2,y2,z2, radius, choose(5))
 {
}

and then i just kept going. except when the global.selected changed, i just put in different code (just changes the block being placed)
  • 0

#12 link3000

link3000

    Link3000

  • GMC Member
  • 1129 posts
  • Version:GM8

Posted 14 December 2011 - 02:41 AM

My first guess is the combination of using the assignment operator "=" instead of the conditional operator "==" and the lack of parenthesis, which could be changing which block gets created. I'd recommend putting the object to create in an array so you can just grab the object ID out of there given a block ID or selection ID. With the given information though, I can't tell too much about your problem.
  • 0

#13 jsorgeagames

jsorgeagames

    GMC Member

  • GMC Member
  • 620 posts
  • Version:GM8.1

Posted 14 December 2011 - 04:33 AM

My first guess is the combination of using the assignment operator "=" instead of the conditional operator "==" and the lack of parenthesis

This doesn't matter in Game Maker because it will never assign a variable inside of a test, and the compiler ignores parentheses unless they are grouping tests, unlike in C for example where they are required.

secondry2, I'm guessing by your code that choose(5) is what randomizes the block. You may have typed this wrong, the choose() function returns a random one of its arguments, and so it will always return 5 in this case. So replace choose(5) with a variable that holds the selected block type. You can increment the variable with in scroll wheel up event.

edit: cleared some stuff up.

Edited by jsorgeagames, 14 December 2011 - 04:34 AM.

  • 0

#14 secondry2

secondry2

    GMC Member

  • GMC Member
  • 34 posts

Posted 14 December 2011 - 05:52 AM

jsorgeagames: but why would i need to replace the 5 with a variable? its "choosing" a random argument but theres only one to "choose" from so it shouldn't matter. and secondly, i dont think arguments can have variables NOTE: please correct me if i am wrong, and if i am wrong, please tell me how to apply it.

link3000: is there anything wrong with the layout? and plus, it looks correct 2 me :P
  • 0

#15 link3000

link3000

    Link3000

  • GMC Member
  • 1129 posts
  • Version:GM8

Posted 15 December 2011 - 01:31 AM

@Jsorgeagames: Yeah, I just didn't know what any of the code actually was supposed to do. No comments or description of any sort.

I was actually wondering what that choose(5) was supposed to represent? You can use variables as arguments, if that was what you meant. It just passes along the value of the variable, not the actual variable like passing a pointer in C/C++ would.
  • 0

#16 secondry2

secondry2

    GMC Member

  • GMC Member
  • 34 posts

Posted 15 December 2011 - 10:23 PM

OH I GET IT NOW! "EDIT: how to apply the variable to an argument" :P .

link3000: basically, all it does, is checks for ur cursor to b placed on a block (simply) and if that is true, then it will check for the mouse button right to b pressed, and if that is true, it will check what block is 2 b placed (using a variable, the variable doesnt accually mean anything, its just there 2 ditirmin which block is placed) and in this case, if the the global variable, selected is one, it will place that block. And for the "choose(5)", all that the choose(5) represents, is the choose means "choosing" a random argument. 5 is one of the arguments (in this case it is a type of block

Edited by secondry2, 15 December 2011 - 10:24 PM.

  • 0

#17 left4matt

left4matt

    GMC Member

  • New Member
  • 19 posts
  • Version:Unknown

Posted 21 December 2011 - 06:08 AM

Ha well I got the display image prob ya don't know how to do it in lite version and my minecraft is 2d so placing blocks is really easy
  • 0

#18 link3000

link3000

    Link3000

  • GMC Member
  • 1129 posts
  • Version:GM8

Posted 21 December 2011 - 09:00 PM

link3000: basically, all it does, is checks for ur cursor to b placed on a block (simply) and if that is true, then it will check for the mouse button right to b pressed, and if that is true, it will check what block is 2 b placed (using a variable, the variable doesnt accually mean anything, its just there 2 ditirmin which block is placed) and in this case, if the the global variable, selected is one, it will place that block. And for the "choose(5)", all that the choose(5) represents, is the choose means "choosing" a random argument. 5 is one of the arguments (in this case it is a type of block

What?

Ha well I got the display image prob ya don't know how to do it in lite version and my minecraft is 2d so placing blocks is really easy

...what?

@Secondry2 - Did you fix your problem, or are there still issues?
  • 0

#19 secondry2

secondry2

    GMC Member

  • GMC Member
  • 34 posts

Posted 21 December 2011 - 09:37 PM

i havent fixed the problem, but i tried displaying my hotbar, and the fps goes up 2 about 16/30 < and then i removed it, and the game ran so much smoother. i think i would know how to do this in the future, if i knew how to higher the fps rate, i would definately do this, now that u guys have tought me how. thanks guys for your help :) . I'm adding mobs to my game so if you would like to check out my new post that would be much appreciated :) .
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users