SQ4 timecode panel like

Started by SonnyBondsAtOnce, Tue 26/07/2011 08:54:06

Previous topic - Next topic

SonnyBondsAtOnce

I looked forever in this forum... can I -please- get a final straight answer on how to create a panel like in Space Quest 4 timepod, that appears with buttons with SHAPES when pressed they appear in a screen and then either WORK or FAIL!!!!

please let's not post parts of the solution, whether ALL full solution including script code and object names, or nothing! from scratch! I have a room with a panel OBJECT, when clicked it should show the close up to the panel which -hopefully- should work like the one in the timepod. HELP!
.....
...
......aaaaaaaaaaahhhhh!!!  :'(

Khris

I looked forever in this thread... can I -please- see the lot of not helpful answers to your question that warrant such a weird, whiny way of posting?
Oh wait, they aren't there.

I might still scratch together a few bits of helpfulness to address your problem, I hate the Space Quest games though and don't have a clue how the time pod controls work. Maybe someone else does, good luck.

SonnyBondsAtOnce

the panel looks like this:

a Key Pad (with alien images instead of numbers)
a display screen showing the entered sequence...
an Enter button.

Khris

Alright, I'd use a GUI for the close up.
Put the buttons on the GUI and assign the button images with the symbols to them.
Make another button for the display screen but make it not clickable. (Call the button "btnDisplay" and before showing the GUI, call "btnDisplay.Clickable = false;").

Now create a second array of the symbols for the display, without a background. Ideally, the GUI's background image contains the empty display and btnDisplay's Graphic is used to show the symbols appearing on it.

Now for the tricky part: internally, the sequence of symbols is stored as a sequence of letters. So in the beginning, the code will just be an empty string "", and each button is going to add its letter to the end of that.
Say there are ten symbol buttons. Make sure you create them in order so we can use the buttons ID number displayed in the editor to add the letter.
Example: The first symbol button has ID 0, so we add 65 to that to get to the ASCII value of a capital 'A', which is then appended to our code String.

Since the function associated with a click on the button allows us to read its ID, we can use just one function to handle all symbol button clicks (this goes at the end of Global.asc):

Code: ags
String TimeCode;

// FUNCTION UpdateDisplay GOES HERE!

function btnSymbol_Click(GUIControl*control, MouseButton button) {

  // only react to a left click
  if (button != eMouseLeft) return;

  int c = control.ID + 'A';   // button 0 adds 'A', button 1 adds 'B', etc.

  if (String.IsNullOrEmpty(TimeCode)) TimeCode = "";  // avoid a null pointer error in the next line

  TimeCode = TimeCode.AppendChar(c);

  // limit code length to 5:
  if (TimeCode.Length == 6) TimeCode = TimeCode.Substring(1, 5);  // cut off first letter

  // aBeep.Play();  // optionally sound a beep

  UpdateDisplay();
}


Now put "btnSymbol_Click" without quote marks into each symbol button's click event field.

What's still missing is UpdateDisplay:

Now for this to work, the order respectively numbering of the buttons and display symbols is really important. Make sure that the sprites used to display the code are numbered in sequence and that the buttons on the GUI have their IDs in the same sequence. So if button 0's display symbol is in sprite slot 45, make sure that button 1's display symbol is in slot 46, and so on.

Code: ags
DynamicSprite*timepod_display;

void UpdateDisplay() {

  int a = 45;        // Sprite slot of display image associated with first button, change this to match your slot

  int l = TimeCode.Length;

  timepod_display = DynamicSprite.Create(btnDisplay.Width, btnDisplay.Height); 

  DrawingSurface*ds = timepod_display.GetDrawingSurface();
  ds.Clear();

  // empty string -> empty display
  if (l == 0) {
    ds.Release();
    btnDisplay.NormalGraphic = timepod_display.Graphic;
    return;
  }

  int i = l - 1, x = btnDisplay.Width;
  int slot;
  
  // go backwards through code string, paint symbols to dynamic sprite
  while (i >= 0) {

    slot = TimeCode.Chars[i] - 'A' + a;   // example: letter B: 'B' = 66, 'B' - 'A' = 1, 1 + a = 46
    x -= Game.SpriteWidth[slot];

    ds.DrawImage(x, 0, slot);

    i--;
  }
  ds.Release();

  btnDisplay.NormalGraphic = timepod_display.Graphic;
}


Put this code segment where indicated in the first one.

Note that the symbols are placed in the top right corner of the display button and can have variable widths.

The final step is the enter button, create its function by double-clicking it, then put this inside:

Code: ags
  if (button != eMouseLeft || String.IsNullOrEmpty(TimeCode)) return;

  // only accept a code length of 5
  if (TimeCode.Length < 5) return;

  if (TimeCode == "BHEGA") {

    // turn off GUI, print message, change room, etc
  }


None of the code is tested!

If you're having problems, please give as much info as possible, not "doesn't work" ;)

SonnyBondsAtOnce

Khris, your reply is VERY appreciated.
seems complicated though, I'm still not satisfied though. I really got my head bumpy on too much coding and so on.. what I was looking for exactly was a step by step in an easier method such as:

create 12 images for each button.
create 1 image for the display screen.
create 1 image for the panel where the buttons and screen are placed.

then the full code in one single shot! not parts from here and there.. even the comments would be more appreciated if they were included inside the code only --> //comments....

I'm sorry, I know I am too picky and demanding but this has bothered me and many others (as I see from their replies).. it's been an issue for long and no one shared their final solution in one clear thread.

Khris

Are you kidding me?

You know you're too picky and demanding yet you still complain?

I don't give a fuck about what format you and allegedly 'many others' prefer. If you need instructions that people without a brain could follow, maybe programming Adventure Games isn't the right way to spend your spare time.

You see, I demand that people who follow tutorials by others are still required to do some brain work themselves. You wouldn't believe the number of times when some dumbass, after having been provided with a complete solution, posts back with "I get an error in line x" when all they'd have to do is pull their head out of their ass for two seconds and correct the easy to spot typo in a command that's right there in the fucking manual.

How are people supposed to learn anything if all they ever get is 'zombie instructions'?

Long story short, I'd continue to post my help the way I did even if all newbies in unison complained about it. (And most of them don't.)

WHAM

Quote from: SonnyBondsAtOnce on Thu 28/07/2011 09:55:17
create 12 images for each button.
create 1 image for the display screen.
create 1 image for the panel where the buttons and screen are placed.

This CAN be done, but you'd have to study how to use dynamic sprites or something to get the screen working and I doubt it's worth the effort. Khris' instructions were very eye-opening and expansive. If you're really looking for step-by-step tutorials on everything, I suggest you either hire someone to tutor you, or hire someone to script for you. What you are asking is simply too much for most people to do just because they want to help you out.

I recommend you start small, seriously small, by making simple one or two room game with some actions, hotspots and objects and build up from there. It is incredibly frustrating to try learning the more complex stuff first, as this can be made easier by learning the simple things.

Sorry if i was unhelpful, but there is no easy twelve-step program to learn scripting, you either learn it little by little or you dont.
Wrongthinker and anticitizen one. Utterly untrustworthy. Pending removal to memory hole.

Knox

Khris is one of the most helpful posters here (if not, the most)...I dont think its a real good idea to "direct" him in how he "should" help you! It can come off as a bit insulting, really.
--All that is necessary for evil to triumph is for good men to do nothing.

arj0n

Quote from: General_Knox on Fri 29/07/2011 00:43:41
Khris is one of the most helpful posters here (if not, the most)...
He's indeed.

Khris

Thanks guys,

and SonnyBondsAtOnce, just to be clear, it wasn't my intention to attack you personally.
I grant that a strict step-by-step tutorial detailing every click would be helpful in the sense that it allows everybody to use a certain resource. The reason why I don't usually provide those is that I don't think it's useful in the long run. Those tutorials could be replaced by a short set of instructions like "import GUI x" and "import code y" and the result would more or less be the same. It would get the job done but you wouldn't learn anything in the process.

I myself want to understand why and how something I use works and in my opinion, the ultimate purpose of these forums isn't solving other people's problems but showing them how to do stuff on their own.

Shane 'ProgZmax' Stevens

QuoteHow are people supposed to learn anything if all they ever get is 'zombie instructions'?

While I don't agree with Khris' tendency to be abrasive, this is absolutely true.  It's almost become an epidemic of lazy on the internet for people to want their hand held through EVERYTHING -- and I'm sorry -- but coding is one thing someone cannot just make a walkthrough for.  It's something you need to learn by reading a few books and just doing it.

Having read some of your other posts Sonny, my advice is to get a book on c-style coding so you can not only ask for help but UNDERSTAND the solutions offered to you.

SonnyBondsAtOnce

You decided that I'm lazy, you decided I'm a beginner, and somehow implied I'm stupid... check out my posts you'll see I am a polite person and did not attack anyone, I appreciate all comments by Khris and the others, I didn't say his posts were useless, I'm sure they are the direct solution for my problem, I said at the first post, a STEP by STEP, I guess I forgot to include 'no attacks as well'...
anywho..
I'm sorry I asked.
I'm sorry I joined the forums.
Bye.

Khris

Your first post didn't mention "step by step", but it was demanding and whiny, and the middle part didn't make much sense although I could guess the meaning.
So in some way one could say you were indeed asking for attacks.

WHAM

In what way were any of his posts "polite"?  ???
Wrongthinker and anticitizen one. Utterly untrustworthy. Pending removal to memory hole.

Shane 'ProgZmax' Stevens


LimpingFish

Sigh. Welcome to the Age of Entitlement.

Threads like this make me sad.
Steam: LimpingFish
PSN: LFishRoller
XB: TheActualLimpingFish
Spotify: LimpingFish

David Ostman

SonnyBondsAtOnce (SB rocks btw), it's possible you didn't mean to come off the way you did, but even as someone who isn't completely used to the mentality of these forums, I too thought you came off sounding like a dick, as did most, I'm sure.

Imagine you've been working at the same company for 10 years, you've become an expert at what you do. One day this new guy starts, and he doesn't quite know the ropes, but instead of hanging back a bit to get a feel of the culture of the company he walks up to you after not even a week.

"Hey, you," he says, not even introducing himself. "I've looked everywhere for information on how to file this report. I need you to show me how to do it, what to do with these CHECKBOXES and these FIELDS here!!!" his voice high, and not a little bit shrill.

You look at him wondering if the guy is for real, before he continues. One or two of your co-workers have clearly stopped what they are doing, to listen to what's going on.

"Now, I don't just need directions, go through these forms for me now and show me EVERYTHING so it's all PERFECT. The instructions in the back says the P712 form is used for this request so it SHOULD be right," he stops for a moment to catch his breath, then slams both hands, palm down, on your desk and look you squarely in the eyes. "HELP!"

You flinch, then give one of your co-workers a look trying to figure out if this is a joke. She gives you a shrug.

"Aaaaah!" the guy exclaims, throwing all the paperwork up in the air before walking away.

This is how I pictured you. As the crazy guy. Does this seem normal to you? It's not. Maybe it's a language thing, maybe it's interpersonal skill thing. Whatever it is, you need to adjust your apparent attitude if you want people to help you willingly and without hating your guts. If people perceive you this way in real life you will no doubt have been punched in the face several times in your lifetime already.

Sorry for carrying this topic even further off topic...

WHAM

Mr Ostman, I applaud your dramatization of this thread.  :)
If a moderator read this: lock please? I'm probably not the only one who feels its time this thread died down.
Wrongthinker and anticitizen one. Utterly untrustworthy. Pending removal to memory hole.

Gilbert

Yes, locking time. :p

While SonnyBonds wasn't really clear with what he's going to do, did overreact and people seemes to support KhrisMuc, I'll warn KhrisMuc again that trying to reply politely won't hurt.

SMF spam blocked by CleanTalk