Wednesday 5 June 2013

Restart

I now have a restart method! Whenever the player presses "Play Game", the restart(); will run and the player will return to the first room of the game. Maybe I should also put down stuff like [whatever the item] = false; so that they won't be able to open a locked door if they haven't picked up the key yet during the second time they restart the game. It's working for my couple rooms at the moment but I'm not too sure about the rest of them but I guess I should HURRY UP SINCE THIS IS DUE SOON.

Next room added: [1][0] or 10.png and 10after.png

The green room still has the sword and the red room is after the user has picked up the sword. Why I chose a sword in an alien UFO, I have no idea. But the hilt looks awesome, doesn't it? Grass is a bit questionable too.



Thursday 30 May 2013

BorderLayout inside BorderLayout

Okaaaay... this is what happened today:

  • made program exit on pressing red button by having a JOptionPane pop up
  • made a second gamePane to make a second BorderLayout
  • second BorderLayout will act as a menu for the user with "quit", "instructions", and "map" (maybe)
  • the 1st BorderLayout goes into the 2nd BorderLayout 
Everything of that works fine and awesome after I fiddled with some things. Now my issue is how to use the booleans to make the rooms clickable or not. Because at the moment, this is working:
             
        if(whatClicked.getButton()==whatClicked.BUTTON1)

    {
    if(roomArray[cRow][cCol]==roomArray[2][0])
    {
    prev=false;
    }
    else
    {
    prev=true;
    }
    if(roomArray[cRow][cCol]!=roomArray[2][0])
    {
    cRow++;
    if(tracing)
    {
    System.out.println("CHARACTER HAS ENTERED PREVIOUS ROOM");
    }    
    }
   
    }

What's not working, is if I replace if(roomArray[cRow][cCol]!=roomArray[2][0]) with if(prev=true);
Which I think should work unless I'm missing something very obvious, which I probably am, but it really looks like it should work. I don't get why it won't work. My computer crashes when I try to use if(prev=true);.

So. I got a back to menu button, plus an "exit screen" of sorts, but this part, which I was actually supposed to do today, won't work. 
Nice. 

Wednesday 29 May 2013

Back!

Right. So yesterday, I managed to make the forward button work. Now, I've been trying to make it so the buttons aren't clickable if there is no room up ahead, or if it isn't a dead end. I've managed to do that with the back button in the starting room, but now when I move forward into a room that I haven't made yet, the program crashes. The way how I'm stopping the buttons from being clicked is by using an if statement to see if the character is in a specific room. If the character is in a room that doesn't have a forward room, I make the room equal to that room.
...Showing it might make more sense.

if(roomArray[cRow][cCol]==roomArray[2][0]) //if character's place on board is same as starting room
{
    roomArray[2][0]=roomArray[cRow][cCol]; //the starting room now equals to the character room
    prev=false; //button for previous room equals false (not sure if this is even needed)
}

That will basically keep them inside the current room. But if that's how it is, then I think I'm going to have waaaaaay too many if statements for this one thing. Doesn't sound right. At all. Or it should, since it works, but I don't think that it's the efficient way to program this bit.

Anyways. That's how it looks to be programmed at the moment!

Tuesday 28 May 2013

Forward!

AAAAAAAAAH!! My character can move through rooms now! :D
Well... technically, it's just two rooms. Forward and Back. But still. Yay. Although if I press back again after they are in the start room, I get a massive error on the black screen (I need to learn the name of that box!), plus the screen turns white since there's nothing before the beginning.
There was a slight problem in the beginning because I forgot to add the MouseListener to the buttons! I am so smart sometimes. >_>
Another problem was that I had to use the removeAll() method and put the other picture into the CENTER layout, which means I probably have to declare the Forward, Back, Right, and Left buttons all the time. I didn't do that at first, so the program didn't work at the time. But it works properly afterwards.
Maybe I can put them in a method and just use the method whenever I need them. I haven't tried that yet but I don't see why it won't work.
Just yeah. I can see that I'm going to have more if statements than I've ever used for any of my other programs put together.

Wednesday 22 May 2013

Some Random Updates That I See as Achievements In Moving Forward

So... this is how it looked yesterday and I had no clue why although it seems pretty obvious now. 
Since JCreator is still wonky on my laptop I will not touch any of my code (since it's working fine now) and just mention some stuff! Stuff. That's... pretty broad. But stuff is stuff which is stuff so it's valid stuff.

The reason for why the image wasn't appearing in the frame was because I had a lot of nonsense code to show the image (that code was mooched off of some website I don't even remember or know) and I didn't actually "put" the image into the game method which means it wasn't added to the gameFrame, which is why it wasn't showing up when it should have.
It kind of looks like this now after I removed the excess code:
roomImage = new ImageIcon(""+r+c+".png");
roomImageAfterItem = new ImageIcon(""+r+c+"after.png");
setIcon(roomImage);
The ""+r+c+".png" in the brackets gets the png file I named that certain row and col from the class folder. roomImage is the picture of the room with the item, and roomImageAfterItem is the picture of the room without the item in question. roomImageAfterItem was then made equal to roomImage after they click the item so that the after-image would be the picture that shows up after they click the item.

So... some other things that happened today has to do with getting the option pane to pop up to tell me that an item has been picked up! Since it has an "OK" button and not a "YES/NO" button, they will be kind of doomed if they pick up and eat something that is pretty dangerous...though I wonder at how I'm going to be able to tell them that. Hm. Ah. More if statements and messages. Mm.
Pretty silly mistake on my end... it wasn't working at first, and that was because I didn't add the MouseListener to it. I had the MouseMotionListener added, but I forgot that my if statement for picking up the item is part of the MouseListener method and not the MouseMotionListener.
Before I figured that, I --- AM I WRITING TOO MUCH HERE??-- made a tracing statement that says "MWAHAHA" if the item's actually being clicked. Turns out in the end after I added the MouseListener, both the item message and the tracing statement works. Yay.

Oh, and lastly, there was a null pointer exception error that popped up when I went to the instructions frame. My good quacking friend +Chilly C and my teacher found out that it was because the roomArray was initialized in the game method. It should have been initialized in the constructor method, because the if statements I had going on were trying to access rooms that weren't created yet when I clicked the instructions button...I wonder if I even made sense.

Tuesday 14 May 2013

Half Finished ONE Part of x Parts of Program

With help, I was able to somehow start getting my array for the rooms working! Although there was this huge misunderstanding I had about using a class and making an array using one of them, and another one (which should be the same one) as the template of the rooms in my game. ERM... Nothing else is worth mentioning yet.

Right... As for what to put in the other rooms, I decided that I would have a quest within the adventure. I think it is fairly simple since I just have to deal with booleans and if statements, like almost everything else in my program.
I also plan to add a little helper/familiar that would warm you if there is immediate and serious danger. I don't know how the helper should look. Some kind of outer space animal, earth animal, or something else entirely. Who knows...

Friday 10 May 2013

Wow

Wow, is this really just the 5th day I've done something about my program?

Okay, so far I have about 14 things I can put into the rooms of my game and I have 18 rooms to fill.

  1. key 1
  2. key 2
  3. locked door 1
  4. locked door 2
  5. alien god who asks riddle 
  6. The Epic Answers to Epic Riddles book
  7. alien monsters
  8. weapon
  9. a pit hole that leads to instant death (GAME OVER)
  10. treasure chest with 1000 coins in Pluto currency
  11. greedy alien god
  12. poisonous gas trap
  13. anti-gas potion
  14. poisonous food with no antidote
  15. a map (?How am I going to work this out?)
Other than that, I'll be a happy person after I make sure that the array that will determine what room is available etc works. Which I think means I'll have to make a few more classes for these rooms before I can properly test it out. 

I figured that if I make it so after they click on an item, a JOptionPane will appear to say that they picked it up. Then--maybe instead I shoul dmake it so they could chose whether they want to pick it up after they click it. So...I can say in the JOptionPane... Do you want to pick up (item)? Yes/No
And then if yes, then draw the exact same room but without that item, if no, then it stays the same and they can proceed. I guess I could make it so they can't leave unless they pick up a certain item, but I'd say that it's their own fault for not picking up a key that would most likely open a locked door. I mean, what's the harm of picking up a few items?

Currently this is how the first room looks although it's terrible bare and more things will have to be added to it!(Or not?) Maybe the key should be in a drawer by the front wall instead.

They key is there, but it's pretty small. I tried to make the size reasonable considering the size of the room and everything...
There's only one door, but if it's going by how my grid looks, they'd also be able to go right so I should probably add a door on the wall to the right. 

Sunday 5 May 2013

Ahhh...

Pieces of code are missing from my program! >_< They disappear and reappear after pressing enter. And that only worked twice. Good thing I didn't have anything on it!
It started acting funny after I put more stuff into the instruction screen but I really doubt that's the problem. I could see everything when I run the program and it works perfectly fine but I can't see my code. I opened my first GUI project and it's also missing a fair bit of code, and it won't let me do anything to it. Must be my computer that's busted. For some reason. It was working fine yesterday...Yup. I'm doomed.

Friday 3 May 2013

MouseMotionListener

I'm moving on to making it possible to click onto objects in the room. To do that, I have to know the coordinates of the object, so I used the .getX() and .getY() methods. The coordinates will be printed out on a separate screen.
I tried using the MouseListener at first, but when I did that, the coordinates didn't show up when I tried it--I could only see the coordinates if it passed by a button.
Then I used MouseMotionListener and added it to the JFrame I want it to show up in. And I printed out the coordinates in the mouseMoved method. This worked out so one part is solved!!
...Maybe the mouseEntered didn't work because I didn't add the MouseListener to it...

Friday 26 April 2013

Mapping!

Today was all about mapping out my game. Laying traps, treasure, and keys for the user. Oh, not to mention the deadly pit I planned to put somewhere in the game. It was actually pretty fun!

I haven't actually started programming the game yet since I want to make sure I have everything I want in all my rooms (18 of them), even though I should be able to change my mind in the middle of it.
And I have a feeling it's going to be very confusing.

Ah, and about the problem I had yesterday. It's fine when I run the program on my school computer and +Chilly C  guesses that I probably ran out of RAMs when I...ran...the program... (too many rans there O_O).

Thursday 25 April 2013

Strange Error Occurs...

Okay...this is so weird, I'm not even sure if it can be considered an error or not...I mean, it's not supposed to do this so of course it's an error (facepalm).

I'm in the middle of making my "About" screen, which has to include stuff like who it belongs to, copyright (Me), year, etc etc... ( I think!). Anyways. So I made an "About" button on my menu screen and tested it out after adding the MouseListener and whatnot. I clicked it. Perfectly fine (although it's centred and I didn't write any code to make it so), except if I close the window and run the program again, press the INSTRUCTIONS button first, then press the BACK button, THEN, when I press the "About" button, the words (c) Vivian Luu shows up TWICE. Not once, but twice. Why? I have no clue.
It's the strangest thing I've ever come across.

Either my computer has gone wonky or my program is crashing because I imported java.awt.* and javax.swing.awt* even though I'm not using all of the things included in the packages. Does a program even crash like that?
I fiddled with it a bit, like making the text of "About" set so it's uneditable, placed a BorderLayout in the aboutPane, and added the "Back" button to it. Then I ran it again. I checked the About screen, and it looked alright. I clicked back, clicked "Instructions", and went back to "About". I would have done a short happy dance, except that when I tried this a few more times, it started glitching on me.
Me: ....what?
My program: (stops working)
And I get this white screen. I click my mouse and my instruction screen shows up. Phew. I click back. Then I click "About". Again, it takes a few seconds for everything to pop up. This happened in my last program so I wasn't too worried. I clicked "Instructions" again and this time a black screen greeted me.
Uhhhh, so what's happening? I move the window around. That works. I click it. Nothing happens. Then I try to click Google Chrome, which was open. THE BLACK INSTRUCTION SCREEN POPS BACK UP.
I click another window. It pops back up again. I click minimize. And click another window. My computer's task bar tells me that I'm still on the black instruction screen even though I see my browser. I click my browser and for a second I see that my Google Chrome icon is highlighted, but then it jumps back the java screen with the black instruction screen, even though it's minimized.
So I started the task manager but the black window's still saying that it's there which makes everything else unclickable.
I try to end the window, but it won't worrrrk! I keep on clicking on the end task button until a bunch of "End Now" or "Send Error Report" window pops up and I click "End Now" which worked. But still.
That was super weird!
I tried it again, this time just importing the stuff I needed, but it still happened. Guess it must be my computer then.

Conclusion of Today's Programming
  1. I found a suspicious error with my copyright sign that disappeared after some fiddling
  2. My program's glitching and the window won't close without forcing it to close using the task manager
  3. I think it's my computer's fault.


Tuesday 23 April 2013

Frames and Frames and more Frames

So, I figured out that it's normal for me to have more than just a few frames in the program if I'm doing chose your own adventure... I'll probably end up with around 20 or 30 of them. I'll probably end up calling them scene 1, or something that describes what's going on in that frame.
My title screen is done! It has a picture of a UFO with its beam to the ground, taken from here. My instruction screen is more like the beginning of the story and the goal, which is to escape from the aliens before they preform experiments on your family. I also put all the text in the middle of the window by using JTextArea and a JScrollPane but it seems like I won't be needing it.

Monday 22 April 2013

The Gooey Monster Arrives...

Hi! 
I think the name of this blog is pretty self explanatory and since you are probably my teacher or someone else I know who is reading this, I won't bother to explain it in much detail. I'm planning on making it a bit like an agenda/journal to remind me to do things and to sum up the stuff that I managed to get done.
Basically, for my GUI culminating, I'm planning on making a chose your own adventure game that has aliens, green goo, kidnapped family members plus a dog and of course, GUIs. 

I was thinking of not making it from a birds-eye-view although I think I should since I have to include arrays and ... yeah. I have to think of some other way to put them in. 
But I wanted to make it like the user will be walking through the story as the character, so they see everything from "street view" and if they see something (i.e a map) they can click on the graphic or .png, and they will be able to pick it up. After that, I have no idea what they'll do. 
Maybe each scene will be a panel within the same frame and they just keep clicking on something in the room that will lead them to another one? I'll think more of that later...for now, each scene is a separate...something. 

The story so far (without the chose-your-own bit)...

You live in a family of four: your mom, your dad, your little brother, and your poodle. One day, your mother told you to go to the corner store to buy a bag of milk. Being the responsible child you are, you go and buy the milk.
Coming back, you find out that aliens have abducted your family to an unknown location!

You've decided that it's up to you to save them. So, you follow the trail of goo that the aliens who kidnapped your family left behind and found that it led to High Park. As the sun was setting, you have to rely on your human eyes to look for the goo. You'd think that the aliens would try to hijack a car if they were carrying three people plus an annoying pink poodle named Elephanté. But everyone has their own methods, so you don't dwell on it.

There! You find the aliens and their flying saucer called GUI Munsta.
You hide behind the bushes. You see them loading a crate labelled SGNIL HTRAE. (EARTHLINGS). When they turn their backs, you sneak into the flying saucer through another entrance since they already closed the other ones. You hide beneath the covers as the doors slide shut. Then when you realise that you're flying, you come out of your hiding place. But there's just one problem.
You don't know where you or your family are.
But look, there's a map on the floor! So you pick it up and locate yourself. Sadly, it looks like the flying saucer has a lot of rooms to go through. What do aliens put in those rooms anyways?

....and that's all I have for now! Time to do my history homework.