So today I was able to complete the bouncing ball program. It is very interesting and somehow, surprisingly fun to watch. Here is the program:
% declaration section
const DELAY := 1
var character : char
var columnNumber : int
var rowNumber : int
var rowIndex : int
var columnIndex : int
% initialization section
columnNumber := 1
rowNumber := 1
rowIndex := 1
columnIndex := 1
% input section
put "Character: " ..
get character
colourback (black)
cls
% processing and output section
colour (yellow)
loop
locate (rowNumber, columnNumber)
put character ..
delay (DELAY)
rowNumber := rowNumber + rowIndex
columnNumber := columnNumber + columnIndex
% When column hits edges
if rowNumber = 1 or rowNumber = maxrow then
play ("8CDE")
rowIndex := -rowIndex
end if
if columnNumber = 1 or columnNumber = maxcol then
play ("8CDE")
columnIndex := -columnIndex
end if
end loop
So the programs output was simple but the programming was a bit 'mind-bleeding'. Today, I also worked on the next assignment where the task was to make a character run around the edges of the run window. Simple you think? Not from what I tried in class. Hopefully I can figure this out tonight.
Also, tomorrow is the last day! Can't wait for the break. But also I will be trying to master Turing. That would be very near-impossible but I can try, can't I? :D
Until next time fellow blog readers.
Masseullah Adel
No comments:
Post a Comment