Making characters

Understanding the language, error messages, etc.

Making characters

Postby Jman123 » Mon Oct 06, 2014 1:51 pm

Hi there everyone sorry to sound like a bit of a newbie at this but I am ! Just wondering how to create a character that can move that's all
Thanks
Jman123
 
Posts: 2
Joined: Mon Oct 06, 2014 1:47 pm

Re: Making characters

Postby rodot » Mon Oct 06, 2014 2:50 pm

You should look at the "basic/controls" example first, then at "intermediate/physics". These examples are provided with the gamebuino library.
User avatar
rodot
Site Admin
 
Posts: 1290
Joined: Mon Nov 19, 2012 11:54 pm
Location: France

Re: Making characters

Postby Sushi » Fri Oct 24, 2014 9:12 pm

First, declare your player position variables like so
Code: Select all
int player_x = 0;
int player_y = 0;

Then, create a bitmap for your character. You can use a bitmap or just create a square like this:
Code: Select all
int boxDim = 5;
gb.display.drawRect(boxDim,boxDim,player_x,player_y)

in the case of a bitmap, you can do this
Code: Select all
gb.display.drawBitmap(player_x,player_y,bitmap_name_goes_here)

don't forget to make sure your player_x and player_y variables change when you press the buttons
Code: Select all
if(gb.buttons.pressed(BTN_button_goes_here)){
    player_x_or_y = player_x_or_y + or - 1;
}
User avatar
Sushi
 
Posts: 52
Joined: Tue Oct 07, 2014 12:12 am


Return to Programming Questions

Who is online

Users browsing this forum: No registered users and 58 guests