BroGrammer Hero;
Tuesday, October 22, 2013
Is this mine?
So I guess that's what a blog is for. Creating out of some burst of creativity and/or motivation, then for- getting alllllllllllll about it. And of course , again, remembering it for the exact same reasons.... So in these late early months of the year, I have been working a way at many projects, one being this.
This is a game that iv been working on. It deals with GLSL shaders and OpenGL... You might look at it and go, pfff..This crap... Well, when programming even the simplest of games can get complicated. Anyway, for those who care, I had to go in an render my own graphic in different software and create sprite sheets, write code and test it on may android system(Emulators suck) and that sort of fun so.... yea.... Maybe ill post some code up on git...
Thursday, December 13, 2012
Today it would seem that a tutorial is in order. But before I start, I think we should outline a few things. Classes, Objects , Constructors and Methods. All languages have these, and they pretty much mark the keystones of writing a application.
What is a "thing"? Things are Objects. When your blue print is production ready and meets all the requirements of the chosen compiler, it is ready to produce that one "thing/Object" you need. As many times a you need it. The beauty of this is, since a class is a blue print, each object you create from this blue print is independent of the others. An example of this will follow shortly.
Constructor and methods
What are these? Well, consider this. When you create a object, using your new class there are things
that you want to happened as a default reaction, or as we call it variables you want to have set. This, unfortunately has to be seen in a example to be understood entirely. Methods are use to retrieve information about each object. For example, if I were to create a ball and wanted to check or set the buoyancy of this ball mostly like likely I would write a method inside of my class that would be designed to divulge that information.Typically this is were all the confusion happen. The class method conversation as claimed many of would be programmers. Don't let it cast you into the ether, Ill demonstrate how all this works.
Classes
A class is the blueprint for an Object. Since we are in the computer world and starting from scratch, it is obvious that nothing yet exist. So, in order for things to exist we have to create a blueprint for a "thing". Consider the class to be a defined space as well as a thing. And in this space you can specify the properties of this "thing" so that it may "eventually" interact with other "Things."Things
What is a "thing"? Things are Objects. When your blue print is production ready and meets all the requirements of the chosen compiler, it is ready to produce that one "thing/Object" you need. As many times a you need it. The beauty of this is, since a class is a blue print, each object you create from this blue print is independent of the others. An example of this will follow shortly.
Constructor and methods
What are these? Well, consider this. When you create a object, using your new class there are things
that you want to happened as a default reaction, or as we call it variables you want to have set. This, unfortunately has to be seen in a example to be understood entirely. Methods are use to retrieve information about each object. For example, if I were to create a ball and wanted to check or set the buoyancy of this ball mostly like likely I would write a method inside of my class that would be designed to divulge that information.Typically this is were all the confusion happen. The class method conversation as claimed many of would be programmers. Don't let it cast you into the ether, Ill demonstrate how all this works.
Hello World?
Yeah see, I don't want to do that one. I think there are 1000 of this tutorials online and we all know them well. Even the non-programmer types. And hello world doesn't teach you anything about what makes a program .Instead, lets try something that a little be more useful and tiny bit more difficult while still pretty easy to follow.
In this example I'm using eclipse, you can down load it here and it works on any platform. I want to warn you in advance my keyboard is toast and most of my keys stick so bear with me.
I made mistakes, nothing major, but a few none the less. Still, this is the basic start to individual object creation. I created a world(Project) called cyberspace. In it i decided to create the blueprint for a chair. I mean ,if I'm to function in a world void of things, certainly i will be needing a chair. However, in order for this chair to have meaning, I have to add the variables that matter. For example, I want my chair to have 4 legs and a weight limit as well as who is sitting in it. These thing are relevant to my cyberspace but for your project perhaps you want to know the chairs height and width as well a material type. This will all depend on how your world will be programmed.
But there is one thing that does remain the same. You will need to either have all your variable public, have methods set you access the variable or have your variable set the way the will be the entire time your application is running. Of these choices, there is only one that's practical. Using methods. Here's the source code, play around with it for a bit.
package DeleteMe;
public class Cyberspace
{
// Main class. Every project has only one.
public static void main(String[] args)
{
// We have nothing
// So we create something!
Thing chair = new Thing();
// Now what? Lets see what we have.
Thing anotherChair = new Thing("MyChair",4,300);
chair.getDetails();
anotherChair.getDetails();
}
}
package DeleteMe;
public class Thing
{
// These are the variables of my chair
//They are all 0
private String thingName;
private int legs = 0;
private int weightLimit = 0;
// This is my constructor. I does nothing.
Thing()
{
}
// You don't want to do this because it breaks encapsulation, but its fine here
Thing(String thingName, int legs, int weightLimit)
{
//The variables inside these brackets can't see the ones out side, so the this
//Command set them = to one another
this.thingName = thingName;
this.legs = legs;
this.weightLimit = weightLimit;
}
//Time to write a method
public void getDetails()
{
System.out.printf("This is %s it has %s legs and the weight limit is %s",thingName,legs,weightLimit);
}
}
Wednesday, December 12, 2012
Finally, I am here.
I R A BroGrammer.
It took me a while to do this. I mean, finally make my mid up on just HOW I wanted to do this. Given the state of social media and how widely excepted blogging has become, I decided this would be the perfect way chart my journey into the abysmal world of programming.What Language Should You Start With?
Contrary to popular belief , programming is actually quite simple. With the advent of object based programming it couldn't be easier. For this reason, if your new to programming, I recommend you start with a language that is strongly suited in the object base programming area such as java or C#.Exhibit A, typical class in Java(Not main).
public class MyClass {
int num = 0;
double frac= 0.0;
String word= "Me"
public MyClass()
{
}
}
Exhibit B, typical class in Java(Not main).
namespace MyApp
{
public class MyClass
{
int num = 0;
double frac= 0.0;
string word= "Me";
public MyClass()
{
}
}
Exhibit C( Ironically ), typical class in C++ (Not main and Console).
MyClass::MyClass()
{
this->std::string word = word;
}
.... Plus the header
public:
string word;
You chose how and how MUCH you want to code. personally, I recommend you start with java. C is just as easy , however, you mostly likely will end up having to use visual c# and that's somewhat round about. By programming java in eclipse, the syntax you learn is about 80% identical to most other object based languages so when your deep enough, switching to other popular languages is pretty simple, all things considered that is.
Subscribe to:
Comments (Atom)