William Hemsworth 1,339 Posting Virtuoso

Saw this and decided to make a little spinoff with some physics of mine. Enjoy!

William Hemsworth 1,339 Posting Virtuoso

I would definetely say Flash AS2. The absolute most important part is that the students are motivated, and flash allows you to be very creative with just a basic knowledge of math. I got into programming through AS2 when I was about 12, and then started C++ a year later, which to my surprise had very similar syntax to flash actionscript. AS2 doesn't give annoying errors which will put off students, its flexible, and good practice. Since then, I've had a passion for programming because I see it as a form of art, not just a school subject.

Having now started at university, many people who have never programmed before are being forced to learn programming through dull Java console applications, it takes away the good enthusiasm I usually have when programming.

William Hemsworth 1,339 Posting Virtuoso

I stopped most of my activity here a fair while before the big change, but now I have even less reason to come back, I totally agree with Jephthah, it's ugly and unwelcoming. The fonts are a mess, the colors are plain and dull, and everything seems to put strain on the eye. Even the giant submit button puts me off :icon_rolleyes: I think Daniweb needs a major makeover, but this time a good one.

William Hemsworth 1,339 Posting Virtuoso

I think it makes sense, when somebody says "Given an infraction", I interpret it as "Being given an infraction point" - a quantity of how much a user how violated the rules.

William Hemsworth 1,339 Posting Virtuoso

And do you have a program for hooking keyboard? or the shell?

Look at my other snippets, indeed I do ;]

I dont mind any changes people make to the code if it makes it compatiable with a wider range of compilers.

William Hemsworth 1,339 Posting Virtuoso

Look life is much simpler without women, and i think i agree with friedrich nietche(if i type it correct) about women. I am four times as productive than in those days that i used to seek for happiness in women.

Might be true, but there's more to life than personal productivity. Once you are happy with a girl, it's not all that complicated and life can seem a little less dull :P

William Hemsworth 1,339 Posting Virtuoso

I'm surprised the guy even had the ability to sign up.

tux4life commented: Yeah, they can't use Google, except for finding forums :P +6
William Hemsworth 1,339 Posting Virtuoso

Why the hell should we?

Salem commented: Hell Yeah!!!!!!!!!!!!!!! +17
William Hemsworth 1,339 Posting Virtuoso

What are these DEBUG and UNICODE? Can you give me an example?

If the compiler is set up to produce a debug executable (to allow the programmer to debug the program easier), then there's more information and instructions packed into the executable which would increase its size.

UNICODE is a type of character, normally a character in C++ is one byte, but if UNICODE is defined, then you would be using a two byte characters (capable of holding thousands more characters to support chinese and other types of symbols.

By resource files, do you mean to say header files?

By resource files, I mean files with the .res extensions which allow you to internally attach files such as images or videos into the executable. Nothing to do with header files.

The file size is dependant on so many things, If i statically link all the applications dependencies, then the program can turn from 10kb to 60kb.

William Hemsworth 1,339 Posting Virtuoso

cwarn23, the problem is you're limiting yourself to the digital world, there are no pixels or rectangles that make up our universe, That has about the same amount of logic as saying our universe has frames per second. This is maths not physics, numbers are continuous and don't have to be integers.

William Hemsworth 1,339 Posting Virtuoso

I wouldn't say that I'm ignorant but instead open minded.

I would say the exact opposite, being open minded means you accept certain facts and build on them, ignoring facts and making quick conclusions is stubborn.

tux4life commented: He must be narrow-minded then :P +0
William Hemsworth 1,339 Posting Virtuoso

Alright there mate.

I would definitely consider learning AS3. Fortunately for me I learned AS3 first so I won't have to unlearn any AS2, which is probably what you would have to do.

AS3 is considered a lot like other object orientated languages.

Plus the 3D stuff you can do outweighs all the cons...

Have you ever used stuff like papervision 3d? That's a whole heap of fun.

http://www.gotoandlearn.com/

Has a whole heap of vids for you to look at.

You can download cs4 trial for 30 days but it ain't cheap like...

Okay, cool :icon_razz:

In a way that gives me an advantage, I don't think I have to 'unlearn' much, I've been doing it for years, and probably will continue with it, but that wont stop me from trying a newer version.

Out of curiosity, have you uploaded anything you've made? And if you're interested [link] :P

I'll check out the site, seems good, thanks.

iamthwee commented: nice work +0
William Hemsworth 1,339 Posting Virtuoso

Sure, but I get the feeling you didn't search first. Try this:

#include <iostream>
#include <direct.h>
using namespace std;

int main() {
  _mkdir("C:\\My Directory");
}
William Hemsworth 1,339 Posting Virtuoso

Someone asked the exact same vague question not long ago.
Go and look for it.

William Hemsworth 1,339 Posting Virtuoso

It has to be this compiler being buggy or something.

Just because it doesn't work, doesn't mean the compiler has a bug. I changed it, and it worked. I just used the resource code from another project which had a auto-generated resource file.

There's one easy fix for all this, just don't do it manually :icon_lol:

William Hemsworth 1,339 Posting Virtuoso

I don't see your point, (2 / (2 + 1)) = 0.75, which is correct (edit, or not..).
Or, (Number of up-votes / Total number of votes)

jephthah commented: haha +0
William Hemsworth 1,339 Posting Virtuoso

If you're using windows then it's easy :)

void gotoxy(int x, int y) {
  static HANDLE hConsole = GetStdHandle( STD_OUTPUT_HANDLE );
  COORD c = {x, y};
  SetConsoleCursorPosition( hConsole, c );
}
William Hemsworth 1,339 Posting Virtuoso

You forgot the SND_FILENAME argument, change that line to:

PlaySound((LPCWSTR)"tone.wav", 0, SND_LOOP|SND_ASYNC|[B]SND_FILENAME[/B]);

and it should work.

Carrots commented: Thanks for the help :) +1
William Hemsworth 1,339 Posting Virtuoso

Really not the best way to detect keystrokes, I'd suggest a Windows hook, because you can actually change what the output of that key will be. For example, here's how you could turn the Space bar into the Return Key.

#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <iostream>
using namespace std;

LRESULT CALLBACK keyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam) {
	PKBDLLHOOKSTRUCT p = (PKBDLLHOOKSTRUCT) (lParam);
  if (wParam == WM_KEYDOWN) {
		switch (p->vkCode) {
      case VK_SPACE:
        {
          // Space pressed

          // Press ENTER instead
          keybd_event( VK_RETURN, 0, 0, 0 );

          // Dont let windows process SPACE
          return 1;
        }
        break;
    }
  }
  return CallNextHookEx(NULL, nCode, wParam, lParam);
}

int main() {
  // Set windows hook
  HHOOK keyboardHook = SetWindowsHookEx(
      WH_KEYBOARD_LL,
      keyboardHookProc,
      GetModuleHandle( 0 ),
      0);

  MSG msg;
  while ( GetMessage(&msg, NULL, 0, 0) > 0 ) {
    TranslateMessage( &msg );
    DispatchMessage( &msg );
  }
}

Hope this helps.

William Hemsworth 1,339 Posting Virtuoso

Well, something's sure happened to AD. [link] There's no way he deserved 6506 downvotes :P

William Hemsworth 1,339 Posting Virtuoso

Well in that case :P having a late breakfast followed immediately by lunch, then going iceskating with a friend.

William Hemsworth 1,339 Posting Virtuoso

Everybody's reply to this thread should ultimately be "Replying to this thread".

William Hemsworth 1,339 Posting Virtuoso

Quite a while ago, I made this snippet. This code is basically the same, except that it adds animation.

This method of blitting is very fast assuming you don't use a surface that's too large. On a 500 x 500 surface, I managed 350fps using only 0-1% of the cpu. This snippet may appear much slower because of the amount of CPU it's applying to each pixel, but the blitting itself is very fast. Also, don't forget that an average game will only redraw parts of the window that need redrawing, this redraws the whole surface every time.

So, as long as you know what you're doing, Windows GDI isn't actually that slow :icon_lol:

Attached executable:

GDI Animation.zip


Preview Image:

edit: Running in Debug may reduce speed by a lot, set it as Release.

William Hemsworth 1,339 Posting Virtuoso

I don't know anyone and haven't seen any posts where people make their own namespace.

Now you know another, my entire personal library is wrapped in a number of namespaces, without them it would be chaos.

William Hemsworth 1,339 Posting Virtuoso

I made a little snippet that allows you to directly access the pixels and save it as a .bmp. [link] I've simplified it a little for you.

#include <windows.h>
#include <iostream>
#include <cmath>

typedef unsigned long ulong;
typedef unsigned short ushort;
typedef unsigned char ubyte;

struct Pixel {
   union {
      ulong rgb;
      struct {
         // r, g, b share same memory as rgb
         unsigned char b, g, r;
      };
   };

   Pixel() {
      // Automatically set pixel black
      rgb = 0;
   }

   // Init pixel
   Pixel(byte _r, byte _g, byte _b) {
      r = _r;
      g = _g;
      b = _b;
   }

   operator ulong() {
      return rgb;
   }

   void operator ()(byte _r, byte _g, byte _b) {
      r = _r;
      g = _g;
      b = _b;
   }

   // Set pixel
   Pixel &operator =(ulong _RGB) {
      rgb = _RGB;
      return *this;
   }
};

template<short _Width, short _Height>
struct Bitmap {
   // Pixels
   Pixel *pixels;

   // Dimensions
   short width;
   short height;

   // Init
   Bitmap() {
      width = _Width;
      height = _Height;

      // Allocate Pixels
      pixels = new Pixel[width * height];
   }

   // Destroy
   ~Bitmap() {
      // Free all pixels
      delete[] pixels;
   }

   inline Pixel &operator()(short x, short y) {
      // Returns reference to pixel
      return pixels[(height - ++y) * width + x];
   }

   void save(const char *_FileName) {
      // Function to save as bitmap (no compression)
      BITMAPINFOHEADER bmpInfoHeader = {0};

      // Properties
      bmpInfoHeader.biSize = sizeof(BITMAPINFOHEADER);
      bmpInfoHeader.biBitCount = sizeof(Pixel) * 8;
      bmpInfoHeader.biClrImportant = 0;
      bmpInfoHeader.biClrUsed = 0;
      bmpInfoHeader.biCompression = BI_RGB;
      bmpInfoHeader.biHeight …
Nick Evan commented: Sweet! Bookmarked. +10
William Hemsworth 1,339 Posting Virtuoso

This is the implementation, firstly you can't do this in one line, and even if you could nobody would care.

William Hemsworth 1,339 Posting Virtuoso

We wont give you a free solution to what's probably homework, have you even tried it yet?

William Hemsworth 1,339 Posting Virtuoso

Yeah, pretty much. Calzones too. :)
Just as long as there is anything left when we close.

Awesome :icon_cool:

This is by far the most relaxed thread on Daniweb.

William Hemsworth 1,339 Posting Virtuoso

put something, such as getchar(), at the end of main() to prevent the window from closing.

Maybe re-read the question :) I think he said he has already done that part.

William Hemsworth 1,339 Posting Virtuoso

I have to remove my hands from the keyboard, find the mouse, move it to the button, click it, move the cursor between the two tags, move my right hand back to the keyboard, and begin typing again. All that's just too much effort.

Simply put, "I have to click the button" :icon_wink:

To use the keyboard, it takes 15 actions, one for each letter you type, you only listed 7 for using the button :) Also, I usually select the code first then click the button, seems easier.

The only tags I type are the [b][/b] and [I][/I] tags, because they're short.

edit: You're welcome niek ;]

William Hemsworth 1,339 Posting Virtuoso

People who want less disk space will pay less for a smaller hard drive. What are you worried about? that the world will have too much free fisk space? :icon_eek:

majestic0110 commented: lol good post +0
William Hemsworth 1,339 Posting Virtuoso

If you place a static variable inside a function lets say, it is declared once, and is only destructed once the program is closed. For example, try compiling this:

#include <iostream>
using namespace std;

// Returns the static variable 'total'
int addNum(int num) {
  static int total = 0;
  total += num;
  return total;
}

int main() {
  cout << addNum( 2 ) << '\n'; // outputs 2
  cout << addNum( 3 ) << '\n'; // outputs 5
  cout << addNum( 6 );         // outputs 11
  cin.ignore();
}

The example should be clear enough.

William Hemsworth 1,339 Posting Virtuoso

If i am that bored i go and garden. Or practice piano

Sounds good :) I'll be starting piano lessons soon, expensive though. When I'm bored, I'll try something new, for example i've started getting into photography now, here are some I've taken fairly recently.

Why do people limit themselves to the PC only sometimes? :icon_lol:

William Hemsworth 1,339 Posting Virtuoso

The Pirate Bay is not a Warez site, it's a Torrent Tracker, and carries a wide selection of legal content, such as the movie Nasty Old People which is being torrented by it's Director, Hanna Sköld (note that the movie is in Swedish with English subtitles). A lot of people are using The Pirate Bay as a content distribution platform now, including Nine Inch Nails who torrented their last album there.

The rules go:

do not post anything warez related

The pirate bay primarily links to torrent files (almost always to illegal files), "anything warez related" covers alot, including your link.

William Hemsworth 1,339 Posting Virtuoso

mmm, I'm getting bad rep now

You can expect it :P
It's a good thing you want to help, but to really help the OP you have to make him learn something, giving him the answer is ultimately making him dumber when he gets his next piece of homework.

tux4life commented: Agreed :) +6
William Hemsworth 1,339 Posting Virtuoso

I don't like games. I don't have a free time even a single minute in these days. How can i play games. But when i 'll free than i 'll try to play these falsh games.

Yet you clearly have time for the geeks' lounge..

William Hemsworth 1,339 Posting Virtuoso

oh well i guess no help on here then.
instead of outright just gettin on someone i think yall shouldnt be as harsh.... u coulda at least tell me where to start first i didnt say write the whole thing for me.

What did you expect? You copy your question here word for word and expect a solution?
The first thing you do on any new forum is read the rules, you didn't show any effort.

We're here to help you with more specific problems, so show us what you have so far, and exactly what you're stuck with.

William Hemsworth 1,339 Posting Virtuoso

I hate it when they write the assignment word for word and don't even try to venture a guess.

Yup, he should just keep watching this until he gets the message.

Grn Xtrm commented: LOL That is great :) +1
William Hemsworth 1,339 Posting Virtuoso

What part of no don't you understand, it's against the rules, we can't help you do that.

William Hemsworth 1,339 Posting Virtuoso

That would still be helping you. What's wrong with you? it's just a Dog talk forum, get over it.

William Hemsworth 1,339 Posting Virtuoso

Yep. If you donate or are staff, they go away. If you have a free account, then you will have the ads. Thats the only way it can be. If we didnt have ads we would have to become a pay-site like experts exchange, and nobody wants that.

Never liked experts exchange, so you're right there. Heh, if you remove the dash from their site, and split it up yourself..
experts-exchange -> expert-sex-change. Gosh I'm immature.

majestic0110 commented: lol +0
William Hemsworth 1,339 Posting Virtuoso

My only suggestion is that you do away with the ads for registered users.

They're there for a reason, without them there wouldn't be any funding for the site.

William Hemsworth 1,339 Posting Virtuoso

OK, so Crunchie and PaulThom think I should let myself get screwed again by a company that I have zero respect for, just to make them happy. NOT.

You wont know until you've tried, and until you do, you're in no position to judge it.

William Hemsworth 1,339 Posting Virtuoso

You have to admit, for an 8 year old that's a pretty well presented post compared to some people on here who are in Uni.
Stick to something easier for a while, believe me you're not ready for C++ yet, maybe in 3/4 years, in the meanwhile stick to VB or Flash, you know... the sort of things a normal 8 year old would do ;)

William Hemsworth 1,339 Posting Virtuoso

I actually only started using the computer when I was about 8/9 years old, the earliest game I cam remember playing is Age of Empires :P

On my old Sega Master System (which I still have), the first I can remember playing in Portugal when I must have been about 4 years old, was Sonic the Hedgehog. Good times.

edit: found it with an emulator attached :)

Grn Xtrm commented: The old Sonic games rule! +0
William Hemsworth 1,339 Posting Virtuoso

And your nickname doesn't seem to fit with your attitude. Curious.

If you don't have anything decent to add, then shut up with these pointless remarks.
Just accept that you're not going to convert anybody who reads this away from Windows, it's a waste of time.

William Hemsworth 1,339 Posting Virtuoso

I took this as a challenge, and managed it. I'm sure there's better ways, but.. it work perfectly for me. Compile this code, put your program in the same directory with the correct name, then run it.

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

int main() {
  ifstream in( "infile.exe", ios::in | ios::binary );
  float toFind = 60.0f;
  float toReplace = 50.0f;

  if ( !in ) {
    return 1;
  }

  union {
    float f;
    struct {
      char bytes[ sizeof(float) ];
    };
  };

  int counter = 0;
  while ( in.read(bytes, sizeof(float)) ) {
    if ( toFind == f ) {
      in.seekg( ios_base::beg );
      break;
    }
    counter += sizeof(float);
  }

  ofstream out( "fixed.exe", ios::out | ios::binary );

  while ( counter-- ) {
    out.put( in.get() );
  }

  out.write( (char*) &toReplace, sizeof(float) );

  in.ignore( 4 );
  char ch;
  while ( in.get(ch) ) {
    out.put( ch );
  }

  cout << "Done.\n";
  cin.ignore();
}

Hope this helps.

sinnerFA commented: Nice job, works! +0
William Hemsworth 1,339 Posting Virtuoso

Windows has advantages?

Yup, you implied so yourself.

Oh, they may repair it for other people, but they won't use it for themselves, except possibly for gaming.

But that's obviously the comeback most Windows users would make, but besides that, there's plenty. One major advantage is that it's currently the most widely used OS, and has the most software available.

Now, I would like to hear some real reasons as to why recent versions of Windows are so bad that you felt the need to create this rant, not your current response of "It's garbage".

lllllIllIlllI commented: zing +0
William Hemsworth 1,339 Posting Virtuoso

the MacBook Pro is virus and spyware proof, networks like a dream (I don't have an IT department - don't need one), and just works.

One thing PC users can do that Mac users can't.

Your whole post was just plain annoying, if people are comfortable with Windows, why do you care? Just give it a rest, you will always get people with different opinions, and as Tom Gunn said, rants like these are a waste of time.

My opinion is that all three operating systems are fine, each with their own advantages which appeal to different people.

majestic0110 commented: Nice link :) +0
jasimp commented: Yes!! LOL I was hoping someone would link that. +0
William Hemsworth 1,339 Posting Virtuoso

Each page is taking me 20-30 seconds to load, it's pretty frustrating :icon_neutral:
Is there a reason for this?

nav33n commented: Its frustrating indeed.. +0