Friday, December 18, 2009

Fill In

This week ive been trying to work on the animations side of Smalltalk programming. The main thing ive been working on is creating morphs withing a square area at random points. Ive succeeded in this, however i had hoped for the morphs to be created one at a time. No matter what I've tried however, the morphs insist on not appearing on screen until all are created. Even when i add a delay into the repeating statement, it adds the delay at the beginning of the command and simply waits a moment before showing them on screen. A screenshot of the end result follows. I'm currently looking for a tutorial for the animation side of squeak which, though I've been told by several tutorials is quite good, none of these tutorials has given any time to it.

Wednesday, December 9, 2009

Movement

Today I worked more with the morph adding keyboard input for motion. So far (for a reason im not quite sure of) the tutorial has had me limit the motion of the morph so that it only responds to the keyboard input if the mouse is hovering over the morph. The method for the motion follows:

handleKeystroke: anEvent
| keyValue |
keyValue := anEvent keyValue.
keyValue = 30 "up arrow"
ifTrue: [self position: self position -- (0 @ 1)].
keyValue = 31 "down arrow"
ifTrue: [self position: self position + (0 @ 1)].
keyValue = 29 "right arrow"
ifTrue: [self position: self position + (1 @ 0)].
keyValue = 28 "left arrow"
ifTrue: [self position: self position -- (1 @ 0)]

I also learned how to check the values of each key by opening a Transcript and in a workspace preforming:

Transcript show: anEvent keyValue

12-8-09

I'm working with creating Morphs now. One thing I was pleased to find was how simple the syntax for adding keyboard and mouse input was. For the object to change color based on what it was clicked on is as simple as including a method of
mouseDown: anEvent
anEvent redButtonPressed
ifTrue: [self color: Color red].
anEvent yellowButtonPressed
ifTrue: [self color: Color yellow].
self changed

which checks if the mouse is over morph and if either the red mouse button (left click) or the yellow mouse button (wheel click) are pressed.

I ended the period trying to get croquet to work properly. Its an interesting software but I do prefer 3d modeling over 2d (im not sure of croquets 3d modeling capabilities).

Friday, December 4, 2009

Animating screens

I played around a lot with animating morphs. I started with a simple string and moved on to figuring out how to open the viewer for any object on the screen. As it turns out there is an open viewer button on the morphic halo. With this information I animated several browsers and had them rolling around the screen. A screenshot of this is included.

Wednesday, December 2, 2009

Morphic

I moved on to the chapter on morphic projects. I skipped over quite a few chapters on the way but the tutorial is pretty good about making sense no matter which point you start from. This chapter if considerably more interesting than the class creation. The code for creating morphs looks something like this

s := 'WEEEEEEEEEE!' asMorph openInWorld "Opens a string object on the screen which can be manipulated in the same way as any other morph"
s openViewerForArgument "Opens a screen used for manipulating the weee string"
joe := Morph new color: Color blue. "Defines joe as a blue morph which is by default a rectangle"
joe openInWorld.
bill := Morph new color: Color red .
bill openInWorld.
joe position:(joe position + (15@-5)) "Changes the position of joe by (15, -5)
joe extent:(joe extent*1.1)
joe color: Color orange
joe color: (Color blue alpha: 0.5)
bill color: (Color red alpha: 0.5) "Makes bill transparent and red"
bill extent:(bill extent*1.1)

Tuesday, December 1, 2009

More Syntax

I finished another chapter in the book today. It was a fairly short chapter which dealt with the basic rules of syntax in smalltalk. One of the points it stressed continuously was how simple the syntax truly is. Eventually it boiled down all squeak programming to 5 simple rules
Rule 1. Everything is an object.
Rule 2. Every object is an instance of a class.
Rule 3. Every class has a superclass.
Rule 4. Everything happens by message sends.
Rule 5. Method lookup follows the inheritance chain.
One of the most difficult ideas to grasp was that even the classes were objects. This next chapter that I've just started deals with development in squeak. Hopefully this will provide greater insight into some of the more in depth details that previous chapters have left out.

11-30-2009

I stayed home sick today.

Tuesday, November 24, 2009

Syntax

I've completed the part of the tutorial in which you create the Quinto game. However there are several issues with it. When clicked on an object and the four surrounding it are supposed to change color but so far this only works on certain blocks. I've decided to skip over this for now and move on to the next chapter which deals with syntax. Hopefully I can go back and fix this as a side project after I learn more about what I've actually done in creating this game, as so far the tutorial simply says to trust it and it will explain what we are doing later.

Monday, November 23, 2009

Protocol Creation

With the game almost done I'm stuck on one part. The tutorial asks me to create a protocol called game logic in SBEGame. I dont believe the tutorial has told me how to do this yet but if it has I've simply forgotten. I ran a few google searches and havnt found the answer yet but will try again tomorrow. Hopefully I'll be able to solve this problem fairly quickly. Once I do I believe I'm only about an hour away from completing the game which means i would have it done before the break. I'll post the file as I complete it.

Thursday, November 19, 2009

More Class Creation

Continuing with the creation of the Quinto game, today I created a class named CellGame which will actually run the game. Another class I created, SBECell, is a rectangle of variable size which will make up the changeable pieces of the board. when the project is complete, ie at the end of the chapter, these will change color to blue when the nearby cell is clicked.

Chapter 2

I just finished the first chapter of the Squeak by Example book. So far it has been significantly more helpful than any other tutorial I have founds so far. I went through the process of creating a new method which i discussed in the previous post and an now just starting a game entitled quinto. Screenshots will follow when I'm further in to the chapter.

Wednesday, November 18, 2009

Class Creation

Today I was guided through the creation of a method. So far I have created a test for a program i am going to write and first thing tomorrow I will create the actual program. The goal of which is to convert a string into one that is "more frantic sounding" the testing document contains an example:
testShout
self assert: ('Don''t panic' shout = 'DON''T PANIC!')
which tests the input of Don't panic for the output of DON'T PANIC!

11-17-09

I've found a great free E-Book entitled Squeak By Example, the pdf of which may be found on http://www.squeakbyexample.org/ and I received help from Mr Elkner in solving a problem I had opening saved files in squeak. I have to open the files through a terminal. Not being able to open them properly has been an issue for several days and makes the tutorials much easier to follow.

Monday, November 16, 2009

Boolean

The part of the tutorial i covered today focused on Boolean operations. The basic syntax is
(Argument) ifTrue [^'Some Printed Output'] ifFalse [^'Some Printed Output']

Where the argument is something along the lines of 1 < 10 and the ^ (shown as an up arrow in Squeak) is the command to return a value. This is one of the code blocks i evaluated which was included in the tutorial:

| dir pos |
pos := 'Chalk Farm'.
dir := ''.
[dir isNil or: [dir isEmpty]] whileTrue: "loop Prompter until a char has been entered"
[ dir := FillInTheBlank request: 'Enter a one-letter direction: N,S,W,E' ].
( dir = 'N' )
ifTrue: [ pos := (Map at: pos) n.
Transcript show: 'Moved to ', (Map at: pos) description ]
ifFalse: [ Transcript show: 'This has not been implemented yet!'].

Ignoring some the the classes created earlier in the tutorial the code is basically creating two temporary variables (dir and pos), setting pos equal to the string 'Chalk Farm,' setting dir equal to nil and comparing a user input to deturmine the aspects of locations around the variables.

Friday, November 13, 2009

Hierarchy

Today I learned more about arrays and some of the more detailed syntax of Smalltalk, including how to return data and use variables. I also learned some about the Hierarchy of objects in Smalltalk. Looking up the Array class in the class browser I selected the Hierarchy for it and found it descended through several classes down directly from the Object class. I didn't make too much progress on the game today but did learn a significant deal regarding Smalltalk code.

Thursday, November 12, 2009

SmallTalk (cont'd)

I'm going on with the smalltalk tutorial listed in the previous post. It is slightly more in depth than i previously anticipated and on page two it actually takes you through the steps of creating a small maze game modeled after the london subway station. I'll be working on this for the next couple days and possibly into next week. hopefully ill have results to show in class on monday.

Tuesday, November 10, 2009

SmallTalk Tutorial

I'm on to page two of the Smalltalk tutorial (http://www.bitwisemag.com/copy/programming/smalltalk/smalltalk2.html). It focuses on the the syntax of SmallTalk programming which is fairly basic. It seems to build on a few basic commands. I've just gotten into creating arrays in the language which is fairly simple. One of the more interesting aspects of the code blocks it has me dealing with is the inclusion of primarily temporary variables which are defined only until the code is finished executing and then are destroyed.

11-9-09

I stayed home sick today but spent a minute or two thinking about smalltalk.

Friday, November 6, 2009

New Tutorial

I've found a new tutorial for squeak (http://www.bitwisemag.com/copy/programming/smalltalk/smalltalk1.html) which specifically focuses on smalltalk programming. So far it has been fairly useful in teaching me the basics and I'm getting a much clearer idea of squeak. It has been very clear, but as it is so short I'll most likely finish with it on monday and may go back to a previous tutorial with this newfound knowledge

Thursday, November 5, 2009

Squeak (pt2)

After looking over the Squeak tutorial a little longer i managed to figure out what it was asking me to do. I managed to do this but i still have a major problem with this tutorial as it is fairly unclear as to why it has me do certain things, and more importantly how to do them.

Wednesday, November 4, 2009

Tutorial Troubles

The tutorial I had been using to learn squeak seems to be either made from an old version or simply incomplete. It often asks you to do things without telling you how and all the images are of a version of squeak that i dont have. Even when the directions are fairly simple the expected result does not happen. Ill be looking for a better tutorial and in the meantime try to sift through this one.

Monday, November 2, 2009

Squeak

After finally getting squeak downloaded near the end of the period i looked over the first few pages of the "laser game" tutorial and tried out a few simple objects in squeak. I'll be working on it more on Wednesday and may download it on my home computer before then.

Friday, October 30, 2009

First Quarter Assignment

  1. How well did you meet your original goals for your project this quarter? Please be ''specific''. What were your original goals? What did you actually accomplish? How do these compare? Why?
I believe I did fairly well completing my goals for the quarter. My original goal was to learn the C language to the best of my ability. The brief one hour class periods didn't allow me to learn as much as i would have liked but still allowed me to get a firm grasp of the basics of the language. What I actually accomplished is, from no prior knowledge of the language, to have worked through the first chapter of the C Programming Language book and the majority of the second chapter. I had hoped to work through this language a little faster but am fairly pleased with my progress, especially in recent weeks.

2. Did your project turn out the way you planned? What unexpected things did you encounter during the quarter?

For the most part the project turned out as I planned. The most unexpected things i faced was the complexity of the C book I was using, and the expectation of prior knowledge it was built on. It was far more in depth when dealing with memory and often dealt less with actual programming.

3. What did you learn this quarter?

This quarter i learned the basic structure of C programming, along with the functions of several libraries and how to access them. These libraries include and

4. What can you do now that you couldn't do when you started?

I can now write programs in C which can solve a variety of problems and do many basics tasks. I have yet to write any programs of any real complexity but can generally write a long, simple program to accomplish basically the same thing.

5. What things did you hope to do that you can't do yet?

I hoped to get further into the C book and deal with longer and more complex programs. I especially wanted to learn enough useful programming to be able to get an internship working as a programmer. I know I am not even close to having this extent of expertise, but will continue to work towards this goal.

6. Will you continue with this project next quarter? Why or why not?

So far I am undecided whether to continue with C in class, or work with Java. I'm going to do some research over this weekend and try to determine which will be more useful in my professional life. If I continue with C I'll keep working on the C Programming book along with several online tutorials and most likely at least one other book from the classroom. If I switch to Java, or a different language, I'll request a book on the subject and most likely consult an online tutorial as well.

Thursday, October 29, 2009

Scratch

I'm still finishing the scratch project but im on the verge of completing it, at least to the current specifications. The program asks you how many bats there are and responds to the user input correctly every time.

10-29-09

I spent the entire period working on the scratch program that Mr Elkner asked me to try. Its almost done, all i have left is to have the game not start until the person chooses the correct number of bats and add in a background and maybe some sounds.

Wednesday, October 28, 2009

10-27-09

The class period ended yesterday before I had a chance to post in my blog so I'm posting it now: I started on Scratch yesterday. When asked to create a version of the fly counting game where the number of flies is random I had the idea to use the random number generator. It creates a random number, either 0 or 1, and shows the sprite if the number is one.

Monday, October 26, 2009

Previous Code

Here is the aforementioned Code which converts lower case letters to binary. I'll clean this up and find a way to write a function that will hopefully accomplish this with much less code. http://docs.google.com/Doc?id=dfbtpmh3_3dnkgvn4m
I read over most of chapter 2 today and looked at some of the exercises for chapter three.

Thursday, October 22, 2009

Text to Binary

Once again I spent the period working on exercises from the C Programming Language book. I've been struggling with a few of the exercises from the end of the first chapter but I'm confident that i can work it out soon. I also still had trouble copying the program i made from vim to google documents but will work on that.

Wednesday, October 21, 2009

Technical Trouble

I worked on a single program for the whole period. I'm making an English to Binary translater in C. Thus far the translater only converts lower case letters, but, given more time, I could easily have it convert upper case letters and numbers, as well as any special characters I choose. When trying to publish this code on a google document I ran into some trouble. I had it all but solved just as I had to leave for the bus and will post said code tomorrow.

Tuesday, October 20, 2009

Back to Basics

After perusing several other tutorials and books for the past week or so i finally feel confident enough to return to my 'The C Programming Language' book and pick up where i left off. I went over every exercise in the first chapter today and completed most of them. Those i didnt do were simply too bulky or simple to worry about.

Friday, October 16, 2009

Programming with C

I've been looking through a new book entitled Programming with C. More specifically I've been dealing with memory allocation and working grasp the concept more fully. I'm also now trying out new programming challenges from Cprogramming.com which are a nice change from the ones offered in The C Programming Language.

Thursday, October 15, 2009

Beginner's Guide to C

I spent the period reading through one the the C tutorial books entitled The Beginner's Guide to C. The book is somewhat helpful in certain aspects but after looking over the different sections all period I've concluded its probably better used as a reference book to supplement what I learn in the other books. It probably wouldn't be very useful as a main source as it skips around compared to other tutorials I've seen.

Tuesday, October 13, 2009

Tuesday October 13

Today I spent the period working on the Cprogramming website. I was introduced to several new functions including strcmp and strcat which i am still working to fully understand. I have the basic idea of both and am planning on reading up more on them at home as we have no class tomorrow.

Friday, October 9, 2009

Week 5

Monday 10-5-09

I stayed home sick today but took some time to read over basic Java script.

Tuesday 10-6-09

To avoid further confusion with the "C Programming Language" book I spend today supplementing my knowledge with a C beginner tutorial on http://www.cprogramming.com/tutorial.html This has been helping me a great deal as it fills in gaps left by the C book which assumes a proficiency in many things i have no experience in.

Wednesday 10-7-09

With what I've learned on http://www.cprogramming.com/tutorial.html I spend most of the period going back to the C book and determining which questions had been answered and which have still yet to be explained. I went back and forth between the two tutorials and so far it seems a much better method of learning than using one of the two on their own. The online tutorial give more detail on simple subjects while the hard copy counterpart give a more general challenge.

Thursday 10-8-09

I spent the majority of the period on the online tutorial. particularly helpful has been the explanation of strings it offers and a far more comprehensible section on arrays. however the Event functions were somewhat unhelpful so i reached out to third and fourth sources to help me. after reading the explanations offered by others i feel far more confident on the topic.

Friday 10-9-09

With my decision to create an artifical life program for my science fair project finally definite i consulted Mr Elkner. He said, and i agree, that it would be best to make this program in Python. My only concern so far has been which visual program to use. Most likely I will use Jython when writing the program so i can write the majority in Python with only the visual aspect being handled in Java script.

Friday, October 2, 2009

Week 4

9-28-09

I'm still working on having a more complete knowledge of functions in C. I'm particularly stumped by the function
int atoi(char s[])
{
int i, n;

n = 0;
for (i = 0; s[i] >= '0' && s[i] <= '9'; ++i)
n = 10 * n + (s[i] - '0');
return n;
}


9-29-09

Mr. Elkner is helping me better understand data types. I'm going to start to learn both binary and hexadecimal. I need to learn this to properly understand the previously mentioned atoi function. I was given Mr. Elkner's definition of a data type, "A data type is an interpretation of bit patterns." I'm still sorting through exactly what this means but what I've read so far in the Kernighan and Ritchie book is starting to make more sense.

9-30-09

I spent the whole period studying binary on http://www.math.grin.edu/~rebelsky/Courses/152/97F/Readings/student-binary. So far I know integer conversion and some basic arithmatic in binary though the part of the tutorial about multiplication and division is slightly unclear. I'm going to look through other sites to find a better, more detailed guide.

10-1-09

I've finished studying regular binary and am now working on hexadecimal. I'm using http://www.lyzrdstomp.com/binary/hex1.html as a tutorial I've just about learned everything I currently need on the subject for my purposes and am looking over the ANCII chart.

10-2-09

With my study of binary and hexadecimal done for the time being I spent a portion of the period discussing both the programming competition and java with Mr. Elkner. The idea seems to be a promising one as he described java as similar to C. We also discussed C++ and object oriented programming which I hope to explore further as my proficiency with C improves.

Friday, September 25, 2009

Functions

I'm finally starting to understand functions in C. Currently I'm going back through all of chapter one and making sure i can solve every exercise. If not I'm going through it step by step until i know what i was doing wrong.

Tuesday, September 22, 2009

C Programming - 1.5-1.7

Working on gaining a better understanding on arrays and functions in the C language.