Im back with more character creation screen questions!

Started by LadyFreotasor, Tue 17/12/2019 01:33:09

Previous topic - Next topic

LadyFreotasor

Okay so I have successfully set up the menu so you can switch before Male and Female (sprites).  A problem I'm facing is the actual ability to customize (Which I know will be alot of sprites but Im comfortable with art).  Is there a way to set up an array or something similar so that the script will check what veiw the player is set as and then change it to the next in the sequence?  I really appreciate any help! :)

Code: ags

//Character Creation Screen UI Functions

function Confirm_OnClick(GUIControl *control, MouseButton button)
{

player.ChangeRoom (1);

}


function Male_OnClick(GUIControl *control, MouseButton button)
{
player.ChangeView (MALE1);
}

function Female_OnClick(GUIControl *control, MouseButton button)
{
player.ChangeView (FEMALE1);
}

function NextOutfit_OnClick(GUIControl *control, MouseButton button)
{
//player.ChangeView (if Female_OnClick == true(FEMALE1, FEMALE2, FEMALE3) else if Male_OnClick == true (MALE1, MALE2, MALE3));
//if player.View == (FEMALE1 == Active) player.ChangeView (FEMALE2);
//failed attempts to figure out how to set this up haha
}


HappyBoxStudios

eri0o

I don't understand much of what's going on but you can set any character as player and you can also change the normal view of a character. Here's a recent question on views of characters here in the forums: https://www.adventuregamestudio.co.uk/forums/index.php?topic=57617.0 .

Also I think you clicked something wrong when typing your question.

Matti

You could reserve a consecutive number of views for the different outfits and different gender, and use numbers instead of names (e.g. male views = 10-19, female views = 20-29). You should also keep track of things like gender with a variable, unless it really doesn't matter throughout the game and the only difference is the appearance of the character.

Code: ags

bool gender = 0;
int outfit = 10;

function Male_OnClick(GUIControl *control, MouseButton button)
{
  gender = 0;
  player.ChangeView (10);
}

function Female_OnClick(GUIControl *control, MouseButton button)
{
  gender = 1;
  player.ChangeView (20);
}

function NextOutfit_OnClick(GUIControl *control, MouseButton button)
{
  if (gender == 0)
  {
    if (outfit < 19) outfit ++;
    else outfit = 10;
  }
  else if (gender == 1)
  {
    if (outfit < 29) outfit ++;
    else outfit = 20;
  }
  player.changeview(outfit);
}

Khris

The proper syntax for what you're trying in in the  NextOutfit_OnClick  function is this:

Code: ags
  // check if view is any of the female ones:
  if (player.NormalView == FEMALE1 || player.NormalView == FEMALE2 || player.NormalView == FEMALE3) ...


Like Matti shows, there are easier ways though.

In general, the approach is:

1. establish a game state
This means create properly named variables for anything that needs to be stored to re-create the game state at any point, using as few variables as possible.
Examples would be a boolean variable for the gender and an int value for the outfit number, which put together can be used to determine the view.

2. user input changes the game state
An example here would be the user's gender choice setting the game's  is_female  boolean to true or false.

3. state determines what's displayed on screen
Again, the example is setting a player view based on the game state.

If you follow this approach correctly, everything will always work out :)

SMF spam blocked by CleanTalk