Tuesday, January 24, 2017

Chocolate Clicker v0.0.0

Welcome back to my blog about Java Programming. In my previous blog I showed where i was at on an android phone app, I was using a website that allowed me to work on the project on my school laptop. What I didn't realize is that if you leave your project for a week the website removes your project unless you have a premium account. So, starting all over I have made it farther than I did before, also I made it into a computer program instead due to me not being able to make an android app, though it still uses some code from the book.

I've learned much more in my programming class, in the book, and just self teaching, My game could be considered complete but I am determined to improve on it because as of now, it is literally just 2 buttons as you can see in this image of what you see when the game first starts up.

 And if you hover over the locked chocolate in the corner you will see this text.


What could that 100 mean? maybe we have to click the chocolate 100 times!

Look at that I've clicked the chocolate 100 times and now I have unlocked the ability to buy the dark chocolate. This will take 100 chocolate away BUT this will start generating 1 chocolate per second.

Now we have 1 dark chocolate and so far it has generated 5 chocolate. The more you buy the more times the chocolate goes up per second. This stacking can be stacked up infinity many times and so far I have gotten this up to this.

This is code I am using to make the buttons, I changed it slightly from the book so it would work the way I was using it.

notLocked.addMouseListener(new MouseListener()

        {
            @Override
            public void mouseClicked(java.awt.event.MouseEvent e)
            {
                // TODO Auto-generated method stub
               
            }

           
            public void mouseEntered(java.awt.event.MouseEvent e)
            {
                unlock.setVisible(true);
                price.setVisible(true);
            }

            @Override
            public void mouseExited(java.awt.event.MouseEvent e)
            {
                unlock.setVisible(false);
                price.setVisible(false);
            }

           
            public void mousePressed(java.awt.event.MouseEvent e)
            {
                if(count >= 100)
                {
                    count-=100;
                    hasBought++;
                }
               
            }

            @Override
            public void mouseReleased(java.awt.event.MouseEvent e)
            {
            }

        });
A major problem I ran into making this was making multiple buttons, originally the buttons were doing the same thing and only one would do what I wanted it to do, and the other, does the same thing. I hope to expand on the available purchases by the next upload. If you have any suggestions i would love to hear them and try to implement them into the game.

No comments:

Post a Comment