Sunday, October 6, 2013

Pong!

This week's main project was to tackle the arcade classic "Pong." Where as you probably know, you play a game of back and forth, trying to score goals, similar to air hockey. A very important discovery that my partner and I made was that you cannot move smoothly using "when key pressed" commands, and that it works better if you use "If key pressed." Not only does it move smoother, it is impossible to move both at once if you use the "when key pressed" blocks. The ball moves back and forth between the two paddles, it starts going at 90 degrees, and then when it comes in contact with a paddle, the direction is multiplied by -1, and by a variable called "Speed." Speed is determined by every 10 steps the paddle moves Rawspeed being multiplied by 2, and then having Rawspeed divided by 5 in order to determine speed. This is to make it so the speed of the paddle has a direct effect on the direction the ball goes. There are a few bugs with this, but the most noticeable one is that the ball tends to get stuck inside the paddle, and scores a goal even though the player shouldnt have had a goal scored on them. The most important thing I learned from this project is the moving function earlier, without that knowledge creating this game and other games in the future would be impossible.


W: Left Paddle Up
S: Left Paddle Down
Up Arrow: Right Paddle Up
Down Arrow: Right Paddle Down

Crazy Conversions!

This task involved creating a system that converts various units. We were only required to go from one to the other, but I made mine go both ways, except for on binary because I did not have time. The First two just used the simple equations for Temperature conversions and Distance conversions, but the Binary was where it got complicated. I was not sure how to make a way that you could type in the whole binary number with one go, and have that be converted, but I was able to get it to work with the enter one digit at a time method. Basically it asks how many digits in total (Up to 6) and it will set the ones up until where you chose to 0 (ie you choose 5, digit 6 becomes 0). Then it asks individually which digit is which, and multiplies those digits by the corresponding power of 2. From this program I learned that the "Brute force method" is not always the best way, and you can find yourself wasting hours doing something that you may all of a sudden realize could have been done in a much easier way, or in my case realize that you did it all wrong.

What an A-MAZE-ING Game!

For my final draft of the maze I kept all the mechanics from the original, and then added more levels. Level 2 is nothing new, other than I had to implement sprite shrinking and a new level. But level 3 adds an aspect that I did not see an anyone else's maze, and that is a key. Level 3 you have to first avoid a shark, which moves back and forth. Once you pass the shark you have to grab a key, which opens up a gate in front of the finish, allowing you to complete the level. If you do not grab the key you will be teleported back to the start of the level. The Key works by using a broadcast once the starfish touches it, which tells a thin yellow line in front of the finish to disappear once that message is recieved. In this maze I learned a lot about broadcasts. I had never used broadcasts before, but once I started they became very useful. I used broadcasts for when the sprite hits the wall in order to go back, as well as completing the level and the Key.


W: Step Foreward
A: Turn Counterclockwise
S: Step Backward
D: Turn Clockwise

SWARM

I had a lot of ideas for the swarm program, but unlike the others, I planned to have a bunch of sprites move randomly, and when they came within a certain distance of eachother one would become the leader, and the other would follow closely behind. This would have been done by having all sprites move to random areas of the stage. Then when 2 came within a certain distance, both would pick a random number, if they picked the same one they would try again until one is the leader. Then the process would repeat for all the random sprites until they are all lined up together. From this project I learned that the touching color option is often much more useful than the touching sprite option, because of a higher accuracy. And I also learned about the functionality of lists. I will not post the program here because currently it only has one sprite picking a random start point.

Sunday, September 22, 2013

The A-MAZE-ing Race Begins!

This week we started work on making our own maze games! While some went for a more simple control style, I decided to make my maze work somewhat differently. The normal style of movement people chose was: W=Up A=Left S=Down D=Right. But I decided that I would take a different route with my game. I chose to have W and D move the sprite foreword and backward. While A and D rotated the sprite left and right, this makes for a very different, and in my opinion more difficult maze game. When the sprite touches the edges in your pursuit for the finish line, it returns back to its starting point and is ready for you to try again. Overall the project was fairly easy, as we have already used most of the mechanics for it in our intro to scratch. But in order to make more of a challenge, I decided to mess around with the rotating controls a bit, which proved to be more difficult to program. If I had more time I would have added more levels that would start when the sprite comes in contact with the finish line, as well as enemies and maybe even teleports. I will attempt to add some of those features during class this week.


Controls: W: Move Foreword. D: Move Backward. A: Rotate Counterclockwise. D: Rotate Clockwise

Sunday, September 15, 2013

Algorithm Summary

In the second day of class we were assigned the task of creating an algorithm that determines the day of the week for a set date. My partner jplafor ( http://programmingwithjplafor.blogspot.com ), started brainstorming ideas, and after about 10 minutes I managed to pull an equation out of thin air that actually worked for what we were doing. That equation is D - (7W). Where D is equal to Days from the first of March 2001, and W is equal to the amount of weeks from that day, rounded down to the whole number. D is determined by the equation (([Year]-2001)365)+M+A+L. In this equation M is equal to the amount of days for each month, ie input 10 = 213 because at the start of October 213 days have already happened since the first of march. A = the date selected, ie the 5th =A=5. And L is the leap year equation, where you divide ([Year]-2000) by 4, and round down in order to find the amount of leap year days to add to the equation for the day. Once all the variables are determined, and the equation is done out, you then have D. To determine W, you divide D by 7, and round down to the whole number. Do that equation out and you will have a number between 1 and 7. 1=Thursday, 2=Friday, and so on. I spent a few hours putting this into a scratch program, but I am still troubleshooting it. But it is nearly working.
EDIT: This should work perfectly fine now, but make sure to select the year first, and then press b before continuing date
Controls: Q and A: Up and Down for Day of the month
W and S: Up and Down for Month
E and D: Up and down for Year

Initial post

In the first few weeks of our programming class, we made steps in order to reach certain locations in the school, noting that it is very important to not leave any small directions out, because a computer needs specific directions, and cannot interpret anything on its own. We also learned the basics of scratch IDE, we learned how to, make sprites move around using the arrow keys (I made my sprites animated when they walk), we made sprites walk around the edge, we made a program that when a ball bounces into another ball, the second ball rolls (even if we did it in a somewhat cheaty way), and lastly we made sprites move randomly, and when they collide they made a sound to signal the collision. All of these tasks were fairly simple, and I was able to complete them within 2 days without much trouble, even though I wasted 15 minutes animating the sprite on one of them.


Here are the Projects Mentioned in this post: