Showing posts with label Intermediate Web Based Programming. Show all posts
Showing posts with label Intermediate Web Based Programming. Show all posts

Sunday, September 7, 2008

5 Awesome Javascript Effects -- WBP

For some reason I am having extreme internet complications. So I cant load any web pages, hurray! Nah Really though, I need to put a pass on the wifi asap!

Browsing around on the net I found some dope things!!!

http://blog.nihilogic.dk/

This dude here is a Javascript Master!
Hes doing things, that should be considered straight voodoo!

But check it out. Super Dope!




1. Image zooom!



URL: http://www.nihilogic.dk/labs/mojomagnify/

I tried this, its pretty complicated. Super advanced. It looks like allot of functions triggered with variables that are placed as methods in other functions. Its crazy!!!

2. Mario Cart (GOODNESS!)



http://blog.nihilogic.dk/2008/05/javascript-super-mario-kart.html


This is super dope. I have no idea or want to know how this is done!

3. 14k mario Bros...



http://blog.nihilogic.dk/2008/04/super-mario-in-14kb-javascript.html


I hate this guy!!!

4. HURRAY I FINALY FOUND AN AWESOME EXAMPLE OF A PARTICLE SYSTEM



http://www.nihilogic.dk/labs/particles/

Dope. this is awsome cause it has a user definalbe widget that lets you modify the particles. Awesome, I want to get more into particle systems with flash. This may be an awesome example of in Javaskript!


5. JQuery
Whoo, whats easier than using someone else's code. Using a library of some one else's code. WHOOOOOO
Instead of having to write all these fast fun easy javascript effects, you can reference jquery. And it will save your life. Whoooo

http://jquery.com/

Jquery is pretty cool actually. I use it as a reference tool, by looking at how something could be achieved, and is accomplished in jquery.
Since jquery depends on classes and id's of the html document. All the effects are visualy pleasing, and most of them you can control fairly simple.
Check check check...

Tuesday, August 19, 2008

Date Object! --- WBP

okay to start off, the date object is pretty cool to use. The only thing I don't like, is that it is only as in depth as numbers. If you want to define anything any other way, you need to build an array or two. Which don't get me wrong, this could be very useful, but is very tedious.

Lets get started.
1.Wed Sept 10 00:00:00 PDT 2007
This was easy, basically create a new date and alert it.
var myDate = new Date();
alert(myDate)

you will need the myDate variable to accomplish each question


2.9/15/2007
In order to do this, you need to use a couple methods from the date object.
I used
getMonth
getDate
and getFullYear


Create variables for each of these that distract the value from the entire date.
an ex.

var day = myDate.getDate()
var month = myDate.getMonth();
var year= myDate.getFullYear();

then alert those in a sequence.
document.write(month + "/" + day + "/" + year);

3.
February 10, 2007
This question is wak, basically you have to create an array to hold each month.
Then you want to use the index number to pull which month it is from the array.

var monthArray=new Array(12);
//Create an Array to hold all strings of months of year
monthArray[0]="January";
monthArray[1]="Febuary";
monthArray[2]="March";
.....
var m = myDate.getMonth();
document.write(monthArray[m] + " " + day + ", " + year);
To write the string properly you need to build the string using the same concept as the last question

4.
Output today’s date in this format: Monday, October 15, 2007
This concept is exactly the same. You need to build an array for the days of the week, and the month. The only trick is to use the getDay method to get the number of the day in the month, rather than the getDate the day of the week. :D
good Luck!

5.Output the time in this format: 11:30:03 AM

Heres another fun fun tedious ass time thing blah!
easy enough though this holds all the exact same concepts as the last ones. Except you use the
getHours
getMinutes
getSeconds methods
also, to be fancy I created a little conditional statement to display the AM or PM
I started out by finding out what that means.
Meridiem its latin! crazy
then i wrote a conditional statement that takes the hour of the day and sees if its before or after 12. noon.


//Define meridiem of day
var meridiem = String;
if(hour <= 11){
meridiem = " AM";
} else {
meridiem = " PM";
}


Then document. write your string. Easy as that

The other questions were over my head. :D
comments comments...

Friday, August 1, 2008

Week 03 HW2 -- WBP

Homework assignment two was much easier than than the first one.
The assigment is two create a javascript Guessing number game.

First you need to start out by creating a random number 1-10.
I still am confused how to create a random number 1-10, but I found some documentation on W3Schools that writes like this

var rndNum = (Math.ceil(Math.random()*10));

This will create a random number 1-10 each time.
I suggest you alert your random number to test your guessing game.

You need to give the user 3 tries to guess the random number, and if they do not guess it correct they fail. But if they guess correctly they win!

I started out by creating a for loop that will occur 3 times.
This is simple by saying that 1 < 3 so keep going

for (i = 1; i <= 3; i++){

This will loop 3 times.
Next you need to get the users input and parse it into a number, like in the last assignment.

var userInp = prompt("Please Guess a Number from 1 - 10", "")
var userNum = parseInt(userInp);
//Notice im parsing variable userInp!

You can basically I copied that from HW1

Now we need to check if the UserNum is equal to our random number

Since our random number is in a variable called rndNum we can create a simple if statement that checks to see if userNum is == to rndNum

If (userInp == rndNum) {
then we go ahead and alert, "Hurray you got the correct number.

}
if else (userInp != rndNum){
then we need to say."You didnt guess the correct number"
}


I ran into a tricky position. I kept repeating the for loop 3 times regardless if they one or loss.

I figured out that if they won, I needed to break the for loop.
I did this by using
break;

The only question is...
Where did I put it?

Also, heres something else I added to my Guessing game.
If you get the message "You didn't guess the correct number"
3 Times, you will get a prompt saying that you have "Lost the Game"
How do you think this was done.

a Hint, it involves an if about my variable i


:D


-Franky

Thursday, July 31, 2008

Week 03 HW1 -- WBP

Homework part 1
Was ridiculous. This assignment deffinetly requires you, to think out side of the box!

The assignment is to ask the User to for a Number 1-10.
Then depending on what number they give you, you need to print out a Number pyramid.
So if the user gives you 4
you will print out
1
22
333
4444

And ect... This will go on and on!

The trick to this assignment is to use two for loops.
Start out by prompting the user for a number
Have what ever value they give you, be turned into a variable...

An example of this would be
var userInp = prompt("Please Give me a Number");

Next you need to parse their input into a Real Number value
So the overall is to create a new variable, that takes the users input and parses it into a number!
This can be done by using
parseInt();

var userNum = parseInt(what goes here?);

Next we create a for loop that will count until we reach the userNum

for (var ind= 1; ind <= userNum; ind++){
//In here we document write our ind
document.write(ind);
}

This will print out all the numbers before the user input
So how do we create the pyramid.
This is smartest think about it by using pseudo programming.

We use the same process as our first loop. But we in bed it in our loop. So we create a second for loop.

But we need to place it somewhere. How bout in the first loop.
notice what were conflicting...

for (var ind2= 1; ind2 < ind; ind2++){
document.write(ind);
}

ind vers ind2
This way they can corresponds with each other.

thats it.
Theres one more line to enter and thats
which writes an html break



Figure out where all these lines go, and you completed this weeks first homework assignment!

:D

-Franky

Week 03 Lab3 -- WBP

This lab was tricky at first, then I just had to think about it.
First of all, you need to understand what exactly a "for loop does.

heres the syntax of a for loop

for(initialize the for loop; give it a problem; tell it what it needs to do to fix its problem){

}

initialize the for loop -
You need to turn it on basically. For beginning, its always awesome to create a variable there. Something that usually is a number, that equals 1 or 0.

var aNum=1;

next you need to set a condition this is best when telling this aNum, that its smaller than another number.

aNum <=5;

Next how do we fix this problem, well we just need to + to aNum until it reaches 5
aNum++

This is how it would look.

for(aNum = 1; aNum <= 5; aNum++){
alert("we have looped " + aNum + " time.");
}

All we created was a loop that will run 5 times. See???
For loops are awesome if you want something to repeat several times, hence "loop".
Try it out.


The assignment calls for a document write that outputs.
01234

Basically I just showed you the exact way to do that

for (var aNum = 0; aNum<6; aNum++){
document.write(aNum);
}
This is less than 6 because the number is indexed. 012345??!!

Next we need to document write
1
2
3
4
5


This is trickier but a no brainer. Since we are document writing to an HTML page, we are allowed to use HTML tags as strings. This is awesome, because you could basically build a web page by just using javascript. WTFUNK!!!

for (var aNum = 1; aNum<=5; aNum ++){
document.write(aNum + "?");
}
what html tag do you use to create a break?


Last part
2, 4, 6, 8, 10


Basically this is the exact same thing. except,
we don't want to ++, we probably just want to add 2.
and We don't want to start out with 0 or 1. We probably just want to start with 2.

for (var aNum = 2; aNum <=10: aNum += 2){
//that was easy
// next we Document write
document.write(aNum + "? ");

//what would go there???
// 2, 4, 6, 8, 10



Thats it. For loops are dope! makes things much easier. as for While loops, and DoWhile loops???
Pfft. I have no idea how those work!

:D