byteCrunch

  • Archive
  • RSS

Well it’s been a while…

4 months or so to be roughly exact.

Quite a busy few months, Christmas, new year, etc.

Decided to write this post to help direct the few people who do follow me towards Kickstarter and the recent spate of games seeking funding.

I encourage you to donate what you can to support the efforts of these developers, to deliver a set of (hopefully) great games that have been much demanded, but sadly abandoned due to an apparent lack of demand nowadays.

Wasteland 2: kickstarter.com/projects/inxile/wasteland-2

The Banner Saga: kickstarter.com/projects/stoic/the-banner-saga

Shadowrun Returns: kickstarter.com/projects/1613260297/shadowrun-returns

Now reblog, tweet and do all those little social networking things people seem to like, spread the word far and wide, that is all.

(Well except this bit of C++ code, ah recursion, you are so fun even in a simple form. I’ll try to have something more interesting prepared next time.)

double power(double _base, double _exponent) {
    if(_exponent <= 0) {
        return 1.0;
    } else {
        return _base * power(_base, _exponent - 1);
    }
}
    • #kickstarter
    • #wasteland 2
    • #wasteland
    • #shadowrun
    • #shadowrun returns
    • #the banner saga
    • #banner saga
    • #video games
    • #games
    • #c++
    • #cpp
    • #programming
  • 1 year ago
  • Comments
  • Permalink
  • Share
    Tweet

More Processing

Playing around with processing some more, mostly with random motion. Again the source code can be found on OpenProcessing. The first two you can left click on to stop and start them.

Enjoy.

    • #art
    • #java
    • #processing
    • #processing.org
    • #generative art
  • 1 year ago
  • 4
  • Comments
  • Permalink
  • Share
    Tweet

Processing

Generative “Art”

Besides C# I have recently been playing around with Processing, the idea of Processing is to essentially make generative art easier in Java by providing simple methods that do the grunt work for you.

If you follow the link you can see the full source code, but I have provided it below anyway. The code will need to be run in the Processing IDE, it can be run in other IDEs such as Eclipse but needs modification if anyone wants that source code leave a comment.

//EllipseConnect
EllipseConnectDraw ellip1, ellip2, ellip3, ellip4;
boolean toggleLoop = true;

void setup() {
  size(500, 500);
  smooth();
  frameRate(10);

  ellip1 = new EllipseConnectDraw();
  ellip2 = new EllipseConnectDraw();
  ellip3 = new EllipseConnectDraw();
  ellip4 = new EllipseConnectDraw();
}

void draw() {
  ellip1.run();
  ellip2.run();
  ellip3.run();
  ellip4.run();
}


void mousePressed() {
  if (mouseButton == LEFT) {
    if (toggleLoop) { 
      noLoop(); 
      toggleLoop = false;
    }
    else { 
      loop(); 
      toggleLoop = true;
    }
  }
}
//EllipseConnectDraw
public class EllipseConnectDraw {

  //Declare Variables.
  float x, y, cx, cy;
  float _x, _y, _cx, _cy;
  float size;
  int col;

  //Constructor and Variable Initialization.
  EllipseConnectDraw() {
    x = width / 2;
    y = height / 2;
    _x = width / 2;
    _y = height / 2;
    cx = width / 2;
    cy = height / 2;
    _cx = width / 2;
    _cy = height / 2;
    size = random(10, 25);
    background(0);
  }

  //run() invokes the other methods in the class, called by draw().
  void run() {
    backgroundFill();
    ellipseDraw();
    curveDraw();
  }

  //backgroundFill(), fills the the background with a full screen rectangle with a sky blue colour and 5% opacity.
  void backgroundFill() {
    noStroke();
    fill(25, 150, 200, 5);
    rect(0, 0, width, height);
  }

  //ellipseDraw(), draws the ellipses based on a semi-random area, each ellipse point is within +- 50 of the previous ellipse.
  void ellipseDraw() {		
    size = random(10, 25);
    x = _x;
    y = _y;	
    cx = _cx;
    cy = _cy;

    col = color(random(100, 200), random(100, 200), random(100, 200));		

    _x = constrain(x + random(-50, 50), 0, width);
    _y = constrain(y + random(-50, 50), 0, height);				

    noStroke();
    fill(col, 75);
    ellipse(_x, _y, size * 1.5f, size * 1.5f);			

    fill(col*2);
    ellipse(_x, _y, size, size);

    fill(col);
    ellipse(_x, _y, size / 2.5f, size / 2.5f);
  }	

  //curveDraw(), links each ellipse with a curve, the curve control points are randomized within a limit so they stay within a reasonable distance.
  void curveDraw() {
    _cx = constrain(cx + random(-5, 5), 0, width);
    _cy = constrain(cy + random(-5, 5), 0, height);

    stroke(col*2);
    noFill();
    curve(cx, cy/2, x, y, _x, _y, _cx, _cy/2);
  }
}
    • #art
    • #code
    • #generative art
    • #java
    • #processing
    • #processing.org
  • 1 year ago
  • 8
  • Comments
  • Permalink
  • Share
    Tweet

The System.Console Class

Input and Output in the Console

I aim to start from the very basics though I will be aiming the posts at those with at least some programming experience. So let’s begin with simple input and output using the console.

First we need to create essentially the basic frame of our console program, consisting of a Main method (the Main method is what the computer looks for an executes first,) and a class in this case titled BasicIO, it should look something like this.

//BasicIO.cs
using System;

class BasicIO
{
    static void Main(string[] args)
    {

    }
}

Once we have this basic outline of our program we can use the System.Console class to get input from the user and then print a message back using this information.

using System;

The reason for adding using System is to give us easier access to System.Console, if we did not add this we would need to write out the entire name System.Console.WriteLine() in order to write information to the console, now we can simply use Console.WriteLine().

//BasicIO.cs
using System;

class BasicIO
{
    static void Main(string[] args)
    {
        string username;

        Console.WriteLine("Basic IO");
        Console.WriteLine("Please enter your username:");
        name = Console.ReadLine();
        Console.WriteLine("Welcome " + username);
        Console.ReadLine();
    }
}

We start by creating a string variable (I will cover the exact details of variables in another post for now think of them as storage for specific types of information) this string variable is named username, this will hold the input.

On lines 10 and 11 we have written some basic instructions to the user, in this case using Console.WriteLine() to inform the user the enter their username.

The following line, line 12 is where we get that user’s input via Console.ReadLine() and assign it to the string variable we created earlier, this means that whenever we use the string variable username it refers back to the information entered by the user. Line 13 make use of this username and prints out a welcome message containing the username.

That concludes our first “tutorial,” if you have an suggestions or require something clarified make sure to leave a comment below.

Also if you have any suggestions on subjects you may want covered in relation to C# or even Java, leave a comment.

    • #.net
    • #csharp
    • #c-sharp
    • #c sharp
    • #programming
    • #code
    • #tutorial
  • 1 year ago
  • 21
  • Comments
  • Permalink
  • Share
    Tweet

Where to begin…

Welcome, to start the aim of this blog is simple, to document the process of me learning C# and the .NET framework. The idea is to simply reaffirm my knowledge by writing what I learn as I learn it, whilst hopefully at the same time helping someone who is new to the language. And maybe even throwing in some Java and gaming from time to time.

Coming from a background primarily based in and around Java, C# is a relatively small leap but I think a logical one. Due to the its increasing popularity and it’s similarity to Java it should make the process of learning C# as painless as possible.

To kick things off lets start with the tried and tested ‘Hello World’ example that everyone enjoys so much.

// HelloWorld.cs
using System;

public class HelloWorld
{
   public static void Main()
   {
      Console.WriteLine("Hello World!");
   }
}
    • #.net
    • #c-sharp
    • #csharp
    • #c sharp
    • #programming
    • #java
    • #code
    • #welcome
  • 1 year ago
  • 3
  • Comments
  • Permalink
  • Share
    Tweet

About

My exploits in the world of programming and perhaps some gaming from time to time.
  • RSS
  • Random
  • Archive
  • Mobile

Effector Theme by Carlo Franco.

Powered by Tumblr