h1

Setting Up SFML.NET 2.0 to Work With Visual Studio 2012 C# Projects

May 12, 2013

(For those of you unfamiliar, SFML is one of the best alternative libraries to SDL and provides high-level access to graphics, sound, input and networking. It’s perfect for 2D games and other multimedia applications. You can check it out over at their website)

Special thanks to LA and Tyson for pointing out some details in the comments! :)

So SFML 2.0 recently went out of RC and is now the official stable version. As I found out about the news I decided to try it out, and since I just installed Visual Studio 2012 I also wanted to see if SFML would work on such an IDE. I saw that the SFML library also had updated bindings for the .NET languages (Visual C++/Basic, C#, etc.) and wanted to take my hand at getting SFML to work with it. It was a bit of a hassle since the tutorials at the main website only listed instructions for getting SFML to work with C++ projects, so I had to do some fuddling around to get it to work with a C# project (it should, since it’s a .NET binding for the library)

Anyway, for those of you still having trouble adding SFML to your C# projects in Visual Studio 2012, here are the steps to get you up and running (before anything else, make sure to download the SFML.Net binaries here (make sure to download the right version for your project, as there are both 32 and 64-bit versions), and extract them somewhere on your drive–it doesn’t matter where.):

  1. Create a new C# project in Visual Studio 2012. It can either be a Console or Windows Forms project– the difference is that a Console project displays a console when you run the application. If you create a new Windows Forms project, you can safely remove the pre-generated Form1 item in the project.
  2. Right-click your project in the Solution Explorer and click on ‘Add Reference…’
  3. When the Reference Manager window appears, browse to the folder where you extracted the SFML.net archive and go to the ‘bin’ ‘lib’ folder. Select the .dll files in the ‘lib’ folder and Click on ‘OK’ in the Reference Manager window to add them to your project.
  4. Once the .dll files appear in the References section of your project, right-click your project again and click on ‘Add’ > ‘Existing Item…’ Navigate to the ‘extlibs’ folder this time and add the .dll files there (you may have to select .dll files as file filter in the Open dialog box).
  5. Once these .dll files appear on your Solution Explorer, right-click on them and select ‘Properties’ (or press Alt-Enter). In the Copy to Output Directory property, set it to ‘Copy if newer’.
  6. That’s it! SFML.net is now set-up for your project.

To test if SFML.net has been fully set up for your project, you can try to run this code snippet (add it to your project’s main file):

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

using SFML;
using SFML.Graphics;
using SFML.Window;

namespace SFML_Test {
   static class Program {

   static void OnClose(object sender, EventArgs e) {
      // Close the window when OnClose event is received
      RenderWindow window = (RenderWindow)sender;
      window.Close();
   }

   static void Main() {
      // Create the main window
      RenderWindow app = new RenderWindow(new VideoMode(800, 600), "SFML Works!");
      app.Closed += new EventHandler(OnClose);

      Color windowColor = new Color(0, 192, 255);

      // Start the game loop
      while (app.IsOpen()) {
         // Process events
         app.DispatchEvents();

         // Clear screen
         app.Clear(windowColor);

         // Update the window
         app.Display();
      } //End game loop
    } //End Main()
  } //End Program
}

When you run your project the output should be similar to this (see screenshot):

Visual Studio 2012 running test C# code with SFML.net 2.0

Visual Studio 2012 running test C# code with SFML.net 2.0

For those of you who still need help, feel free to ask in the comments! :)

h1

Well this is surprising

April 21, 2013

I come back after almost a year and find that my blog’s hits have skyrocketed to 10K. All without me posting new content since last year. LOL.

Well, at least that has further motivated me to write for this blog more (also because I am in need of a new hobby)

Segue: If you’re interested in some old school gaming, or general gaming videos, head on to my YouTube page. My current project is uploading some Crash Team Racing videos, so if that’s your thing, go watch my new videos, and subscribe if you would so like. Thanks! :)
h1

The problem with an overactive mind

June 1, 2012

A wild blog post appears! (For those of you who are still irate over my blogging schedule, read my previous post.)

So what are we talking about today? Nothing much, really. I just wanted to transfer a couple of thoughts in text form so I can reread them later and laugh at my immature writing style. Just me blogging while listening to my obscure music tastes.

I lied. That is the problem, and the topic of this blog post. There is too much to talk about. I didn’t want to transfer a couple of thoughts in text form. Well, no, not that I didn’t want to; the problem is I can’t. Allow me to elaborate.

The main crux of the problem lies in the fact that I have an overactive mind. No I don’t do any substances–or vices for that matter–so I’m clear there. See, it took me an hour to write the next sentence. I have a short attention span, and that’s dangerous if you have a lot of ideas. The ideas go to waste because you forget about them or aren’t interested in them anymore–I nearly threw away this idea of a blog because I was bored writing it. I see blogging, and writing in general, as a way to “preserve” the ideas in my mind before I throw them away. And I need to finish writing this one before my mind drifts away again.

Focus and discipline are needed, to a degree, when thinking of ideas. Short attention spans and overactivity don’t help. If you have an idea–for a writeup, a story, a painting, a game, anything–write it down. Take care to highlight and visualize the idea entirely. At least preserve the idea permanently and only then can you set it aside before moving on to your next idea. Don’t get bored too easily for that wastes valuable thoughts. Focus and discipline.

So I guess I’m focused now on finishing up this blog post, however I’m out of ideas now. I suppose this is where I’m supposed to end the writeup now. Sure, I expected a better (and longer) post, but with elusive ideas jumping in my mind within microseconds, it can’t be helped that a few paragraphs is all I can spew out about the overactivity.

Either that or I seriously need to cut down on caffeine and get more regular sleep.

h1

How your schedule affects your blog

May 13, 2012

Well, I decided to have a different topic today and write something related to general blog writing. I try to make this blog cover a variety of topics that interest me and I try to write about stuff that I actually know about. I know the content I write about like the back of my hand, though I don’t really have a definite schedule of when I post, which I believe somehow affects the quality of The Ultimate Nerd. But, meh, I promised to myself that this would be a laid-back blog and I’d only write quality stuff when I feel like it.

My blog is an example of a website that has no concrete, recurring schedule of when content is updated or added. Most personal blogs seem to fall into this category, when its authors are laid-back, busy with more important priorities or simply lazy (i.e., me). There are many reasons why blog owners choose to update their blogs whenever they want. Perhaps it is a personal choice of the writer (usually connected to the reasons stated above) or maybe there are limitations, technical or otherwise, that hinders the writer (e.g., limited Internet connectivity). Personally, I don’t feel like sticking to a set schedule, so I only write when I feel like it. While my content is very limited and scarce, it allows me to write with quality. Because I only write when I feel like it, I am motivated to write blog posts with great quality, rather than being stressed and pressured to write with a schedule. This is the option that I believe is a good choice for personal blogs, or RL-busy bloggers.

Of course, there are a lot of blogs (and websites, in general) that do stick to a schedule. These schedules are either daily, weekly or monthly (who writes blog posts once a year?) depending on the topic, genre and interest in the niche of the blog. Writing with a schedule entails discipline. You are responsible for updating the blog for the designated schedule. A well-followed and consistent update schedule generally invites more interested followers, as they know when to come back to your blog in case they want to see something new (keep in mind you need to let your readers know when the blog actually updates, usually in the home or about page of your blog). Still, I believe that a schedule pressures the writer into churning out content. There are moments of last-minute write-ups to meet schedule deadlines. Thus, the quality of the articles is compromised. Well, maybe there are people who tend to write better under pressure, but whatever floats your boat I guess.

Well, that outlines what I believe to be the pros and cons of a blog schedule. With a free update schedule, the blog generally has better content. With a consistent one, on the other hand, the blog has more followers. As the blog author, you decide which option to follow, and you should stick to it. Consistency definitely invites readers, knowing that the writer is a responsible one. Maybe my blog visitors think I’m a lazy bum, but when I feel like writing, I make sure to write the best content. :)

h1

2,000 hits after a long while

May 13, 2012

2,000 hits. Wow, that’s a lot of legit traffic, and very amazed that I achieved this after, um, 2 years after I opened the blog. Judging from my statistics, the programming posts seem to be popular (especially to the searchers) so maybe I should put more stuff like that if I want more hits.

 

Anyways, I just wanted to dedicate a little post to thank all those who visited my blog so far, and I hope that more and more people would read and subscribe (it helps because you get all the new content!) to this blog in the future.

h1

Double-bordered <div>’s using CSS

May 5, 2012

Hey guys. Today I’m going to demonstrate a very simple CSS/HTML coding trick that allows you to get double-bordered boxes on your webpage, without using images, scripts, or whatever. The technique we’re going to code up today uses pure CSS(2) and (X)HTML. If you’re excited to see how the final page looks like, you can view a live demo here.

The Markup

The idea, basically, is to wrap around the main <div>, which will house the text and/or image contents, within another <div>. While we could use another element like a <p> or a <span>, I believe that would render your HTML code invalid to W3C standards, and in my personal opinion, box elements of a page should be defined solely by <div>’s.

Anyway, here’s the base markup that you should have. Take note of the two <div>’s and how they are defined here:


<html>
  <head>
    <title>CSS Double Border test</title>
  </head>
  <body>
    <div class="mainwrap">
       <div class="maindiv">
          <h1>Hello World</h1>
          <h2>A test of double-bordered &lt;div&gt;'s using only HTML markup and CSS styles</h2>
          <p>This webpage may look absolutely plain or bland to you, but that was what it was meant to be; this is nothing more than a test.
 This single webpage was made to demonstrate a simple CSS trick, wherein you could actually display double-borders on a seemingly single box
 If you will observe the source you will see that there are actually two &lt;div&gt;'s at work with their respective styles defined in the internal CSS.</p>
          <p>Feel free to use the HTML markup and CSS styles of this page for your personal learning. You can use it as reference or even copy it verbatim, so to speak.
 I won't really care.</p>
       </div>
     </div>
   </body>
</html>

The “mainwrap” class denotes the wrapper <div> while the “maindiv” class denotes the, well, main <div> that contains the actual page content.

Now that we’re done with the basic HTML markup, let’s move on the next, and fun, part.

Styling the markup

We’ll be using vanilla CSS2 for this one. No special @imports, no hard-to-understand libraries or scripts, so don’t worry about those. :)

The idea for this part is that we assign the background that we want our actual content to have to the  “maindiv” <div>. Meanwhile, we assign the color of our “inner” border to the background color of the “mainwrap” <div>.

But how will that look like a border? If you think about it, we can define a small padding of 2px to the “mainwrap” <div>, which pushes the “maindiv” <div> inward, creating the appearance of a pseudo-border of sorts. :)

Finally, we set the border style of the outer “mainwrap” <div> to the outer border we want to have. And voila, two borders for one box!

Here’s the CSS I made for the example markup above. The only thing that really matters here are the styles for .maindiv and .mainwrap. The rest are there for the aesthetic purposes of the webpage.


body {
 background-color: #AA7720;
 font-family: Calibri, Tahoma, Helvetica, Verdana, Arial, sans-serif;
 text-align: center;
 color: #201000;
 text-shadow: 1px 1px 0px #F0F0C0;
 }

 a:link, a:visited {
 color: #0040C0;
 text-decoration: none;
 }

 a:active, a:hover {
 color: #1088FF;
 text-decoration: underline;
 }

 h1, h2 {
 margin-top: 5px;
 }

 .mainwrap {
 border-top: 1px solid #502000;
 border-left: 1px solid #502000;
 border-right: 1px solid #502000;
 border-bottom: 1px solid #502000;
 background-color: #F0E090;
 padding: 2px;
 width: 800px;
 margin: 20px auto;
 }

 .maindiv {
 background-color: #EEBB20;
 width: 780px;
 padding: 10px;
 }

It generally looks good if your color choices are similar for the box. I.e., you want a vivid midtone color for the content box, a light but similarly hued color for the inner border, and a dark outer border. It pays to use HTML color mixers like the one here.

And there we go, we are done coding our double-bordered <div>. You can now copy and paste this code onto your actual webpage. :D

Finishing touches

I added some extra <div>’s to my demo page, to show that the style is actually reusable and doesn’t need much duplicated code to get it to work. Just copy it onto your HTML/CSS file and assign the class to two related <div>’s, and it works. I encourage you to reuse and expand on this code. Let me know in the comments if it helps you. :)

Extra credit homework: The same (and probably better) effect can be achieved using border styles and colors instead of background-colors in the CSS. Find out for yourself how. ;)

h1

Javascript RPG Calculator

April 12, 2012

Oh look, filler stuff while I’m not working on my real website. :D

http://instilledbee.co.cc/rpgcalc

All of the source is available on the HTML file by the way.

Follow

Get every new post delivered to your Inbox.

Join 167 other followers

%d bloggers like this: