Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

RulerOfNothing

Member Since 08 Nov 2011
Offline Last Active Today, 02:03 AM
-----

Posts I've Made

In Topic: Assigning special number to each class type at compile time

08 March 2013 - 11:16 PM

Not really. You just need:

class Base
{
   virtual int getSpecialNum();
};

class A : public Base
{
   int getSpecialNum(){return 0;}
};

class B: public Base
{
   int getSpecialNum(){return 1;}
}

although it has been a while since I've had to do this.


In Topic: Allegro bitmap problems

27 February 2013 - 07:23 AM

If you redraw the entire screen (or at least all parts of the screen that change) every frame then removing clear(screen) won't make any difference otherwise part of the old frame will still be on the screen.


In Topic: Allegro bitmap problems

27 February 2013 - 06:25 AM

I have a question: what exactly does clear(my_pic); do? If it clears the loaded image you probably want clear(screen); or whatever clears the screen instead.


In Topic: Linked List Node Corruption Problem

27 February 2013 - 05:28 AM

I think the problem here is that your delete function gets rid of the associated node data, so this happens:

  1. Program decides to delete s.
  2. Program deletes s and its associated node n.
  3. Program tries to get the next member of n, but can't because that node has been deleted and can no longer be assumed to hold valid data.

How I would solve this is by moving the line n=n->next; to immediately after the program extracts the element from n, so that n will always be valid when you extract the next member from it.


In Topic: dot product

07 February 2013 - 08:27 PM

I'm not exactly sure what you are trying to say, so correct me if I misinterpret you. You are saying that you are analysing dot products between the x unit vector (1,0) and a collection of vectors representing points in 2D space. In this case the dot product is simply the x co-ordinate of the vector, so if you had vectors (3,0), (3,10) and (3,-10) then they would all have the same dot product. If you normalise the collection of vectors you still have problems if some of the vectors are parallel with each other (for example, the vectors (3,4) and (6,8) would both normalise to (0.6,0.8)). Hopefully this helps.

PARTNERS