Math | Was bored

/ 15 Mar 2014 /

My speech, is 7 minutes, it's supposed to be 5, kill me (not edited)

/ /

Identity 
[To this day, All the world's a stage, Woman of the future]

Good morning/afternoon and thank you for having me today to talk to all of you about the ways in which texts support and assist us in understanding the concept of identity. Some of you may ask, what influences your identity? Your identity is impacted by a diverse anthology of experiences that you've accumulated through out your life. One of the major aspects influencing your identity is cultural classifications, this refers to your nationality, race, religion and gender. Another focus of your identity is your societal characterizations, these include family, career, position or title.

Identity is prone to develop over time as we grow and thrive, expand our relationships, conjure new personalities and encounter new escapades. Although we are the representation of our identities, in no way, shape or form can we obtain knowledge as to what will occur to us in the near future. Texts from the Elizabethan Era like William Shakespeare's “All the world's a stage”, and others from the Post-modern era such as Cathy Warry’s “Woman of the future” and Shane Koyczan's “To this day”, support the concept of identity by providing an informative and precise judgement on what being human is all about.

In the text “All the world's a stage”,  Shakespeare supports this theory by emphasising that we live a destined life, in which we are actors, merely playing a role. “They have their exits and their entrances”, what this is referring to is the abundance of appearances a man make in his life, followed by an unforeseen departure. This quote is comprised of a wide range of techniques, its use of diction and connotation exempts the peculiarity that the poem is trying to exude.

Shakespeare convinces us to feel inclined to stray away from the assumption that we're living an independent and unique life. Just because we possess a peculiar identity, it doesn’t mean that we live an individual life, there are many others out there doing the same things we do. “And all the men and women merely players;”, the explicit utilization of symbolism and euphemism helps convey his message to always act humble, regardless of your social hierarchy.  This quote's strict impartiality, implies that men and women are in fact of equal standard.

What Shakespeare is trying to imply is that our endeavours, pleasures and pains may just be a form of entertainment to an audience, rather than a tornado of emotion. The audience is everyone around us, the people who are capable to judge, laugh and watch us humiliate ourselves. Shakespeare states, '”And one man in his time plays many parts”, this suggests that people have no objection of the stages they go through, only the way they choose to act while a part of the particular scene of their life. Shakespeare uses allusion along side word play in this quote, to teach us that we don't choose what we do in our lives, instead we rely on a script written by those who possess much greater power. 

Shakespeare's intended audience must have been all the men of varying ages, since this defines a man in every portion of his life. Understanding that this poem was written in the Elizabethan era we know that literature was all-pervasive, and the authors were me of almost every class, which shows why this poem reflects mainly upon men. 

Upon reading Shane Koyczan's “To this day”, it is obvious that he insists at an early age, we are exposed to a diversity of social factors that influence our perception of identity and who we really are. The author points out that while adults ask us to assume our future self, others our age destroy and sabotage our hopes and aspirations by derogating us with name calling. “They asked me what I wanted to be, then told me what not to be”, in this part of the poem, an instructive language technique is situated to define the emptiness of a child's intention for the future. Shane Koyczan answers the adults question, telling them he aspires to be a writer, then he gets highly advised not to do so. 


These social and external incentives restrict our psychological capacity to establish our identities by manipulating what we think society treats as admissible. He takes a turn to the past and explains how he got his first nickname, “Pork-Chop”. The impact that this had on his childhood is immense, it gave kids a reason to degrade him, humiliate him and make him feel as though he didn't matter. Shane Koyczan says,    “But the school halls were a battleground”, this metaphor illustrates the visual techniques intended, and shows that at a young age, children aren't aware of the amount of cruelness and wicked behaviour they exhibit towards their fellow peers. Actions like these have a great impression on one's childhood and world view while growing up.

In the last stanza, Shane Koyczan explains that “our lives will only ever always continue to be a balancing act”, what he is suggesting is similar to Shakespeare's “All the world's a stage”, in which life is a collection of acts, portrayed by the characters we play. Regardless of the post-modern literary devices used in Shane Koyczan's “To this day”, the morals and motifs still remain the same, proposing similar ideas and representations to contemporary society. Shane Koyczan metaphorically symbolises life as a balancing act, and conveys that no matter what part we play, our final stage is wholly dependent on the other actors' influence towards our self hood. 

This poem is intended towards an audience of all ages. For the adults, to remind the that they weren't they only ones, and not to let their brutal experiences define who they are, while also being for the children, to tell them that there is always someone out there that will accept them regardless of their external factors. This poem's intentions compare congruently with Cathy Warry's “Woman of the future”, since she also reflects upon identity as a concept made up of previous experiences.

Cathy Warry's “Woman of the future, is written around a post-modern context, implicating that she is made up of all she experiences. “I am all the things of my past”, this supports the previous statement, and highlights the author's understanding of the concept of identity. The quote illustrates a metaphorical point of view, while also using a hyperbole to exaggerate the extent to what your identity comprises of. Her focus on identity explicitly resembles that of William Shakespeare and Shane Koyczan.

The author is wrapped in a cocoon of endeavours constructed of the good and evil of the past and present, hoping to one day break out of the shell, and evolve as a woman of the future. This poet makes us think back to our childhood with ease, due to their terminology and word play. The repetition of “I am” is an easy way to obligate the reader to think back and put themselves in the shoes of the poet, generating a more intricate relationship with the poem it self. “Deep down inside me, I am all those things”, what this emotionally driven quote is deducing is all that she is, depends on what she did and what she sees herself as, whether it be the mere representation of what her parents wanted her to be, or the woman she aspires to become.

With the simple language integrated within this poem, it is obvious that it is targeted at an audience of all age groups. Its calm, yet complicated theory of identity opens many doors to whether identity is who we choose to be, or who we were chosen to behove. In the second-last stanza, Cathy Warry states, “I am like a caterpillar, and these things are my cocoon, but one day I'll bite my way out, and be free.” This simile aids the author in advocating that everyone is a caterpillar. It proposes that things we experience as children make up our cocoon, and by “free”, the author is referring to becoming a woman and possessing the power necessary of being able to choose whether or not certain aspects of her life influence her identity.

All these texts represent the concept of identity similarly, and have distinct motifs, yet convey homogeneous ideas. The meaning has been communicated in the texts to the reader by stating that one's peculiar self-hood represents a medley of experience, along side the decisions we choose to make or not to make. All these authors understand what it means to be an individual, and yet be no different than the rest of humanity, since we are all living to find the reason to live.                                               -Samir Chahine 

English | All the world's a stage

/ 8 Mar 2014 /
All the world's a stage

Your identity is impacted by a diverse anthology of experiences that you've accumulated through out your life. One of the major aspects influencing your identity is cultural classifications, this refers to your nationality, race, religion and gender. Another focus of your identity is your societal characterizations, these include family, career and position or title.

Identity is prone to develop over time as we grow and thrive, expand our relationships and encounter new escapades. Although we are the representation of our identities, in no way, shape or form can we obtain knowledge of the things that will occur to us in the near future. Everything is preordained, and we have absolutely no control on how our identities will be moulded.

In the text 'All the world's a stage', Shakespeare supports this theory by emphasising that we live a destined life, in which we are actors, merely playing a role. 'They have their exits and their entrances;', what this is referring to is the abundance of appearances a man makes in his life, followed by an unprecedented departure. Also, the number of people who approach and influence our nature of living is infinite, and wholly dependent on the experiences we confront.

Shakespeare convinces us to feel inclined to stray away from the assumption that we're living an independent and unique life. Just because we possess a peculiar identity, it doesn't mean that we live an individual life, there are many others out there doing the same things we do. This conveys his message to always act humble, regardless of your social hierarchy.

One of the most powerful quotes in this text is as follows, 'Last scene of all, that ends this strange eventful history, is second childishness and mere oblivion, sans teeth, sans eyes, sans taste, sans everything.'. His emphasis on the last part reflects upon what it means to be human. We all amount to age, and become oblivious to everything around us, but the one the thing that preserves our identity is the way we choose to live our life, since no one will every know us due to our true identity, instead, they will identify us based upon the many characters we portrayed.

What Shakespeare is trying to imply is that our endeavours, pleasures and pains may just be a form of entertainment to an audience, rather than a tornado of emotion. The audience, is everyone around us, the people who are capable to judge, laugh and watch us humiliate ourselves. Shakespeare states, 'And one man in his time plays many parts', this suggests that people have no objection of the stages they go through, only the way they choose to live and act while a part of the particular scene of their life. Shakespeare teaches us that we don't choose what we do in our lives, we just rely on a script written by those who possess much greater power.


Since this was published in 1623, people's perceptions of identity might have changed, but the idea's still the same. Features of our identities that we have control over are the things we let them affect. For example, we might let our identities choose our paths in our life's future, or we might leave that decision to someone else. Shakespeare obviously had a distinct understanding of how to distinguish an identity by representation in for of a stage.




This is unfinished, yolo get over it.

Math | All-in-one (Integrating a logarithm to the power of an imaginary number multiplied by a trigonometric function, nifty)

/ 15 Jan 2014 /
This is wrong, but it is also my new favourite problem to solve, indeed.

Math | Amazed yet again.

/ 13 Jan 2014 /
\[\int cot(x)cos(x)sin(x)tan(x)sec(x)csc(x)dx = x + C
\\ \int \frac{cos(x)}{sin(x)}  \frac{cos(x)}{1} \frac{sin(x)}{1} \frac{sin(x)}{cos(x)} \frac{1}{cos(x)} \frac{1}{sin(x)}dx = \int 1dx = x + C
\]

Goodbye

Math | Look at this

/ /
\[\sum\limits_{i=1}^∞ (n^2 + \frac{n}{n+3}) = 1\frac{1}{4} + 4\frac{2}{5}+9\frac{3}{6} + 16\frac{4}{7} +25\frac{5}{8}...\]

What does this equal, help. This looks like the most amazing thing, i'm just gonna keep making things till I die

MathJax | Just testing

/ /
\( \frac{\int xe^xsin(x)dx}{2x(acos(x))} \)

I have finally installed MathJax, praise the lord.

Math | I did it.

/ /
After three days of torture, all I'm gonna say is,


Math | So damn close

/ /
Nope, still wrong, don't worry lads, I will not stop trying, nevar.


Physics | Atwoods Machines | Part 1

/ 12 Jan 2014 /
I love accidents, so I was finished bucky's (thenewboston) physics lecture tutorials (45 of them, pheeww), and I was looking at the related videos, all these complicated shapes and machines were there, with a lot of numbers n stuff, anyway, I watched a few, found it amAZING, then clicked on 'Atwoods Machines', and died. So like, I have to make a post about it, pretending I have discovered it from my good mate Atwood. Pulley 1:
So this is basically a pulley bolted to the ceiling, balancing two different objects of different masses each. Let's assume the rope and pulley have no mass, or just very little of it, enough so it doesn't interfere with the end result, and let's say there's no friction. You would want to find the acceleration of the objects as they fall and drag the other, plus you would definitely want to find the tension of the rope (g is the variable reffering to gravity, 9.8m/s, but 10 would work just fine if you're doing it off the top of your head. So, first off, this is the formula for the acceleration, good job atty:



I know, it's amazing, but now, for the friction, you choose m1 or m2, doesn't really matter. Let's pretend m2 is 8kg for this example: 

 




That is the first pulley example, sooner or later I'll upload an explanation of the second machine model, bye bye




Math | What have I done

/ /

So that's the question I thought up of, and I didn't even have a clue on how to solve it, I was just bored, but then like 2 days later (yesterday) it came to me, i'll just make the [e^(x)sin(x)] = v', and u = x, so I did, little did I know, it was the most FRUSTRATING THING I COULD HAVE EVER IMAGINED, but I go really close to the answer, the last equation isn't completely right, but it's very similar, don't worry, soon enough new working out and a new (correct) answer will be uploaded. I talk as if someone other than myself actually knows about this abomanation of a blog, anyway, adios, enjoy. (The first page is only filled on the right side because I knew I couldn't fit anything else on the left side...)



Can anyone even read my handwritting?

Math | My favourite thing in the world, so beautiful

/ 27 Dec 2013 /
I made this question up, not sure if it's valid but..


On the first one I used integration by parts to find the integral:


Then I found the second integral, but it was tricky heheh..









For the third integral i'm gonna skip all the working out, because it was just simple integration by parts, and get straight to the answer..


Then the last integral was just another case of integration by parts twice, the result:


At last I joined all the integrals together and simplified them (probably could be simplified more but idc deal with it):


Yes, sometimes I do get very bored, no, i'm not sure if this is right, no, I don't care, i'm 16, what do you expect? Ok gtg more one piece

Math | I found a way, we're gonna be okay

/ /
Look :O

Math | How

/ /
Help what's the best way to show my math ain't nobody got time for writing it all in code lol you wish, god life is so hard, I just want to math
hm

Python | Polynomial finder (factors of x)

/ 16 Nov 2013 /
Yes, this is great :'), at first it printed all the numbers with what they were equivalent too, but I just made it so it only spits out the ones that equal 0, I'l try to make is so if there's only 2, it will find the third one by looking at (n) and seeing what else could be used to equal (n) by division or something, but that's for another day, adios amigos. (I know it's simple, but it works)



def f(x):
    ans = 2*x**3 - 3*x**2 - 5*x + 6
    if ans == 0:
        print(ans, "=", x)

for x in range(-10, 10):
    f(x)

Python | wxPython

/ 2 Nov 2013 /
I'm just gonna leave this here...





import wx

class bucky(wx.Frame):
    def __init__(self, parent, id):
        wx.Frame.__init__(self, parent, id, 'Title.xom', size=(600, 400))
        pos1 = 10
        panel = wx.Panel(self)
        button = wx.Button(panel, label='Touch Me', pos=(pos1, 10), size=(60, 30))
        self.Bind(wx.EVT_BUTTON, self.closebutton, button)
        self.Bind(wx.EVT_CLOSE, self.closewindow)

        status = self.CreateStatusBar()
        menubar = wx.MenuBar()
        first = wx.Menu()
        second = wx.Menu()
        first.Append(wx.NewId(), "New Window", "This is a new window")
        second.Append(wx.NewId(), "Open", "This will open me... :)")
        menubar.Append(first, "File")
        menubar.Append(second, "Edit")
        self.SetMenuBar(menubar)
        
        
    def closebutton(self, event):
        self.Close(True)
    def closewindow(self, event):
        self.Destroy()

        

        

app = wx.App()
frame = bucky(parent=None, id=-1)
frame.Show()
app.MainLoop()

Trinomial Solver

/ 27 Oct 2013 /
Aaaaaaand here is my first program in like 3 weeks, well, in Python at least, pretty simple but idc, till next time.



from math import sqrt
def tri(a, b, c):
    x = (-b)-sqrt(b**2-(4*a*c))
    y = 2*a
    x2 = (-b)+sqrt(b**2-(4*a*c))
    q = x/y
    q2 = x2/y
    print('{:.2f}'.format(q))
    print('{:.2f}'.format(q2))

C++ | this

/ 26 Sept 2013 /
No not that, this...

#include <iostream>
#include <string>
using namespace std;

class Han{
 public:
  Han(int num)
  : h(num)
  {
  }
  void printCrap(){
   cout << "h = " << h << endl;
   cout << "this->h = " << this->h << endl;
   cout << "(*this).h = " << (*this).h << endl;
  }
 private:
  int h;
};

int main() {
 Han ho(23);
 ho.printCrap();
}

C++ | Friends :')

/ /
Why have people friends, when you can have function friends?




#include <iostream>
#include <string>

using namespace std;

class Stank{
 public:
  Stank(){
   stink=0;
  }
 private:
  int stink;
  
 friend void stinkfr(Stank &sfo);
  
};

void stinkfr(Stank &sfo){
 sfo.stink = 99;
 cout << sfo.stink << endl;
}

int main() {
 Stank bob;
 stinkfr(bob);
}

C++ | Bucky freakin Roberts

/ /
#include <iostream>
#include <string>

using namespace std;

class Birthday
{
 public:
  Birthday(int m, int d, int y) {
   month = m;
   day = d;
   year = y;
  }
  void printDate() {
   cout << month << "/" << day << "/" << year << endl; 
  } 
 private:
  int month;
  int day;
  int year;
};

class People {
 public:
  People(string x, Birthday bo)
  : name(x), date(bo)
  {
   
  }
  void printInfo(){
   cout << name << " was born on ";
   date.printDate();
  }
 private:
  string name;
  Birthday date;
};

int main() {
 Birthday bobj(12, 28, 1986);
 People bucky("Bucky the king", bobj);
 bucky.printInfo();
}

C++ | Multi-Dimensional Arrays, and printing them

/ /
This is pretttty cool, think of all the possibilities :')



#include <iostream>
#include <ctime>
using namespace std;

int main() 
{
  int sally[2][3] = {{2, 3, 4}, {8, 9, 10}};
  
  for(int row = 0; row < 2;row++){
   for(int col = 0; col < 3; col++) {
    cout << sally[row][col] << " ";
   }
   cout << endl;
  }
  
}

C++ | Printing arrays

/ /
Nothing much, just wanted to post this so I don't have to spend a whole 30 seconds navigating through my C drive to find my C folder, so Im gonna post it here, and ask questions about it on s-o tomorrow. I have seen 35/72 of Bucky's C++ tutorials, hopefully by sunday night, I'l see at least 3 GUI C++ tutorials, same channel, wanna make me sum `o dat window'd apps, k lel...

oh , and yes, I did call the array name my name, why? because?? (can i just do sizeof(a)/4;) :((



#include <iostream>
#include <ctime>
using namespace std;

void printa(int a[], int b);

int main() {
 int samir[5] = {1,2,3,5,4};
 printa(samir, 5);
}

void printa(int a[], int b){
 cout << endl;
 for(int i = 0; i < b; i++) {
  cout << a[i] << endl;
 }
 
}

C++ | Recursion, arrays and for loops

/ /
Look what I made :'), at first I couldn't be bothered, then I thought, wait, what if I can't do it, so I tried it, and it worked :'), but I only got up to a certain number of factorials, because I only used int, i'm guessing if I used a long or a long long, or even a double,(how ever that works) I could of done it, but yep, program4theday..





#include <iostream>
#include <ctime>
using namespace std;

int factorial(int x) {
 if(x==1) {
  return 1;
 } else {
  return x*factorial(x-1);
 }
}

int main() {
 
 int samir[31];
 
 cout << "Element - Value" << endl;
 int a = 0;
 for(int x = 1;x<=30;x++){
  a++;
  samir[x] = factorial(a);
  cout << endl << x << " = " << samir[x] << endl;
 }
 
}

C++ | Average Age

/ 25 Sept 2013 /
This is just a simple c++ program using a while loop, not dependant on the code's number of loops, but the user's amount of input, then it just gives the average of the "ages" entered. (Can be any number really.. )




#include <iostream>
using namespace std;

int main() 
{
 int allages = 0, age = 0, numofppl = 0, avage = 0;
 int x = 0;
 while(age != -1) {
  cout << "Please enter age, or 0 to exit: "; cin >> age;
  allages = allages + age;
  numofppl++; 
 }
 allages --;
 numofppl--;
 avage = allages / numofppl;
 cout << "The number of ages entered is: " << numofppl << endl;
 cout << "The average age of all the people: " << avage << endl;
 return 0;
}

C++ | Classes, more fun than I thought..

/ /
So for some reason, I'm enjoying classes in C++, surprise, OOP, here I come................... k.



#include <iostream>
#include <string>
#include <sstream>

using namespace std;

class Person{
 public:
  Person(string n, int a, string g) {
   setName(n);
   setAge(a);
   setGender(g);
  }
  void setName(string x) {
   name = x;
  }
  void setAge(int x) {
   age = x;
  }
  void setGender(string x) {
   gender = x;
  }
  string get() {
                        ostringstream os;
                        os << "\nName: " << name 
                  << "\nAge: " << age 
                  << "\nGender: " << gender 
                  << endl;
                        return os.str(); 
 private:
  string name;
  int age;
  string gender;
};


int main() {
 Person samir("John Applessed", 16, "Male");
 cout << samir.get();
 Person justin("Justin Bieber", 15, "Female");
 cout << justin.get();
 return 0;
}

C++ | add()

/ 22 Sept 2013 /
Yup, C++, why not C? Because it was boring, for me, I'm enjoying C++ much better, and going to attempt the famous pythagorus calculator for my next program, just as soon as I learn the sqrt() and the pow() functions, unless that's just what they are, then ha.



#include <iostream>
using namespace std;

int add(int a, int b){
 return a + b;
}

int main()
{
 int a, b;
 cout << "Enter first number: "; cin >> a;
 cout << endl << "Enter second number: "; cin >> b;
 cout << endl << "The answer is " << add(a, b) << endl;
 return 0;
}

HTML/CSS | New Web design

/ 20 Sept 2013 /
So I figured I would make a website, with just pictures, why? Because Lorium ipsum is ugly text. I'm gonna try to make as many as I can in this 2 week break, as well as grasp C and a lot of math, (why am I talking about math, this is computers stuff, get out of here math, just go home), ANYWAY, I'l post the CSS, and the html, and how it looks, k.

SO, not much html is implemented, my main focus is just CSS.
<!DOCTYPE HTML>
<html lang="en-US">
<head>
 <link rel="stylesheet" type="text/css" href="style.css" media="all" />
 <link href='http://fonts.googleapis.com/css?family=Overlock:400,400italic' rel='stylesheet' type='text/css'>
 <title>samir</title>
</head>
<body>

 <div id="head">
  <h1><small>The</small>Black <br>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& <small>The</small>White</h1>
 </div>
 <br />
 <div id="nav">
  <li><a href="#">home</a></li>
  <li><a href="#">about</a></li>
  <li><a href="#">portfolio</a></li>
  <li><a href="#">images</a></li>
  <li><a href="#">contact</a></li>
 </div>
 
 <br />
 <br />

 <center>
 <div class="wrap">
 <img src="img/head.jpg">
  <div id="left">
  <img src="img/1.jpg" width="265" height="200px">
  </div>
  
  
  
  
  <div id="middle">
  <img src="img/2.jpg" width="265" height="200px">
  </div>
  
  
  
  
  
  <div id="right">
  <img src="img/3.jpg" width="265" height="200px">
  </div>
  

 <img src="img/head2.jpg">
 </div>
 
 
</body>
</html>


AND here is the CSS code.
body {
 margin:20px 0px; padding:0px;
 text-align:center;
 font-family:sans-serif;
 width:80%;
 margin:auto;
 
 }
 
#head h1 {
 font-size:60px;
 margin:auto;
 font-family: 'Overlock', cursive;
}

#head h1 small {
 font-size:40px;
 color:black;
}
 
#nav {
 width:500px;
 margin: auto;
 text-align:center;
 top:1px;
 border:1px;
 }

#nav li {
 display:inline;
 list-style-type:none;
 
}

#nav a {
 text-decoration:none;
 text-transform:capitalize;
 font-size:20px;
 padding:15px;
 color: inherit;
 
}

#nav a:hover {
 color: gray;
 font-size:19px;
 border:1px solid black;
 border-radius:5px;
}

.wrap {
 width:800px;
 font-size:12px;
}

#left {
    float:left;
    width:265px;
}

#middle {
    display: inline-block;
    margin:0 auto;
    width:265px;
}

#right {
    float:right;
    width:265px;
}

AND HERE oops no bold? AND HERE is the screenshot.




Yes, it's black and white, SO WHAT, i like dem colers

C | Fibo

/ 11 Sept 2013 /
Here it is folks


#include <stdio.h>

main() 
{ 
 int n, first = 0, second = 1, next, c;
 
 
 for ( c = 0; c < 20; c++)
 {
  
  if ( c <= 1 ) next = c;
  else 
  {
   next = first + second;
   first = second;
   second = next;
  }
  
  printf("%d\n", next);
 
 }
 
 return 0;
}

C | Ah, alas, we are here.

/ /
Here is my first C program. I KNOW. Ok, i'm gonna attempt to write the fib sequence, without any help, in C, I know it in python, so it won't be that hard, but yes. This is great.



#include <stdio.h>

main() 
{
 printf("\n");
 
 int a = 1, b = 100;
 while(a < b)
 {
  printf(" %d\n", a);
  a *= 2;
 }
 
 return 0;
}

Python | Pygame | True

/ 8 Sept 2013 /
All I can say, is finally.



import pygame, math
from pygame import *

DISPLAY = (800,640)
DEPTH = 32
FLAGS = 0

##############################################################

# Classes!

class Entity(pygame.sprite.Sprite):
    def __init__(self):
        pygame.sprite.Sprite.__init__(self)

##############################################################

class Player(Entity):
    def __init__(self, x, y):
        Entity.__init__(self)
        self.xvel = 0
        self.yvel = 0
        self.onGround = False
        self.image = Surface((32, 32))
        self.image.convert()
        self.image.fill(Color("#FF0000"))
        self.rect = Rect(x, y, 32, 32)
        
##############################################################

    def update(self, up, down, left, right, platforms):
        if up:
            # Only jump if on the ground
            if self.onGround:
                self.yvel -= 10
        if down:
            pass
        if left:
            self.xvel = -5
        if right:
            self.xvel = 5
        if not self.onGround:
            # Only accelerate with gravity if in the air
            self.yvel += 0.3
            # Max falling speed
            if self.yvel > 30:
                self.yvel = 30
        if not (left or right):
            self.xvel = 0
        # Increment in x direction
        self.rect.left += self.xvel
        # Do x-axis collisions
        self.collide(self.xvel, 0, platforms)
        # Incrememnt in y direction
        self.rect.top += self.yvel
        # Assuming we're in the air
        self.onGround = False;
        # Do y-axis collisions
        self.collide(0, self.yvel, platforms)

##############################################################

    def collide(self, xvel, yvel, platforms):
        for p in platforms:
            if sprite.collide_rect(self, p):
                if isinstance(p, ExitBlock):
                    event.post(event.Event(QUIT))
                if xvel > 0:
                    self.rect.right = p.rect.left
                if xvel < 0:
                    self.rect.left = p.rect.right
                if yvel > 0:
                    self.rect.bottom = p.rect.top
                    self.onGround = True
                    self.yvel = 0
                if yvel < 0:
                    self.rect.top = p.rect.bottom

##############################################################
                    
class Platform(Entity):
    def __init__(self, x, y):
        Entity.__init__(self)
        self.image = Surface((32, 32))
        self.image.convert()
        self.image.fill(Color("#DDDDDD"))
        self.rect = Rect(x, y, 32, 32)

    def update(self):
        pass

##############################################################

class ExitBlock(Platform):
    def __init__(self, x, y):
        Platform.__init__(self, x, y)
        self.image.fill(Color("#0033FF"))


#########################################################################################################################


def main():
    pygame.init()
    screen = display.set_mode(DISPLAY, FLAGS, DEPTH)
    display.set_caption('Use arrows to move!')
    timer = time.Clock()
    
    up = down = left = right = False
    bg = Surface((32, 32))
    bg.convert()
    bg.fill(Color("#000000"))
    entities = pygame.sprite.Group()
    player = Player(32, 32)
    platforms = []

##############################################################

    x = y = 0
    level = [
"PPPPPPPPPPPPPPPPPPPPPPPPP",
"P                       P",
"PP                      P",
"P PP                    P",
"P   PPP                 P",
"P      PPPP             P",
"P          PPPPP        P",
"P               PPPPP   P",
"P                       P",
"P                       P",
"P                      PP",
"P                    P  P",
"P                PPPPP  P",
"P         PPP           P",
"P             EEE       P",
"P                       P",
"P                  P    P",
"P                       P",
"P                       P",
"PPPPPPPPPPPPPPPPPPPPPPPPP",]

##############################################################

    for row in level:
        for col in row:
            if col == "P":
                p = Platform(x, y)
                platforms.append(p)
                entities.add(p)
            if col == "E":
                e = ExitBlock(x, y)
                platforms.append(e)
                entities.add(e)
            x += 32
        y += 32
        x = 0

##############################################################

    entities.add(player)
    running = True
    while running:
        timer.tick(100)
        for e in pygame.event.get():
            if e.type == QUIT:
                running =  False
            if e.type == KEYDOWN and e.key == K_UP:
                up = True
            if e.type == KEYDOWN and e.key == K_DOWN:
                down = True
            if e.type == KEYDOWN and e.key == K_LEFT:
                left = True
            if e.type == KEYDOWN and e.key == K_RIGHT:
                right = True

            if e.type == KEYUP and e.key == K_UP:
                up = False
            if e.type == KEYUP and e.key == K_DOWN:
                down = False
            if e.type == KEYUP and e.key == K_LEFT:
                left = False
            if e.type == KEYUP and e.key == K_RIGHT:
                right = False

##############################################################

        # Draw the background

        for y in range(20):
            for x in range(25):
                screen.blit(bg, (x * 32, y * 32))

        # Update the player, draw everything else

        player.update(up, down, left, right, platforms)
        entities.draw(screen)

        pygame.display.flip()

##############################################################

main()
pygame.quit()


##############################################################
 
Copyright © 2010 M(ath)+me, All rights reserved