Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 272 273 [274] 275 276 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 883073 times)

Siquo

  • Bay Watcher
  • Procedurally generated
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4095 on: March 05, 2013, 06:27:18 am »

@Siquo: What else needs to be there? XD Everything vector already does? Like size, an iterator, ...?
Whatever your application needs, I'd say. Making your own std::container compliant implementation is usually not necessary :)
Logged

This one thread is mine. MIIIIINE!!! And it will remain a happy, friendly, encouraging place, whether you lot like it or not. 
will rena,eme sique to sique sxds-- siquo if sucessufil
(cant spel siqou a. every speling looks wroing (hate this))

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4096 on: March 05, 2013, 06:32:04 am »

For example, if you had a 'DoubleVector' that contained tiles that needed to be updated, you could just call tiles.Update(params) rather than pulling each of them out for updating. Much neater.

EDIT: Wow... That feeling when you suddenly remember that openGL goes off the bottem left, not top left, and that you shouldn't have taken as long fucking about with the issues you had before the clearly obvious solution presents itself.

I really do need more sleep and less alcohol right now.

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #4097 on: March 05, 2013, 07:03:41 am »

Hmm. :S For my application, at() is better than update(). It's a vector of pipeCell classes, which all have their own getters and setters XD Too many getsetgetset @_@
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

GlyphGryph

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4098 on: March 05, 2013, 07:57:00 am »

Man, JS canvas rotation is NOT the easiest thing to wrap your head around. You see, you can't rotate object that you want to draw before you draw them - no, you need to rotate and translate REALITY, draw the object relative to the new coordinate system, and then reset reality.

It's not terrible intuitive, but I think I've figured out a pretty simple way to do it and some scaling, where x and y are the desire object positions:
  var translate_x = x + .5 * scale * OBJECT_WIDTH;
  var translate_y = y + .5 * scale * OBJECT_HEIGHT;
  context.save();
  context.translate(translate_x, translate_y);
  context.rotate(rotation_in_degrees*Math.PI/180;);
  object.draw(context, (-.5 * scale * OBJECT_WIDTH), (-.5 * scale * OBJECT_HEIGHT), scale); //Just have the object draw itself normally, yay, with these brand new x and y positions.
  context.restore();

Just wanted to share. ^_^
Logged

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4099 on: March 05, 2013, 09:10:59 am »

Man, JS canvas rotation is NOT the easiest thing to wrap your head around. You see, you can't rotate object that you want to draw before you draw them - no, you need to rotate and translate REALITY, draw the object relative to the new coordinate system, and then reset reality.

It's not terrible intuitive, but I think I've figured out a pretty simple way to do it and some scaling, where x and y are the desire object positions:
  var translate_x = x + .5 * scale * OBJECT_WIDTH;
  var translate_y = y + .5 * scale * OBJECT_HEIGHT;
  context.save();
  context.translate(translate_x, translate_y);
  context.rotate(rotation_in_degrees*Math.PI/180;);
  object.draw(context, (-.5 * scale * OBJECT_WIDTH), (-.5 * scale * OBJECT_HEIGHT), scale); //Just have the object draw itself normally, yay, with these brand new x and y positions.
  context.restore();

Just wanted to share. ^_^
That's how old OpenGL does coordinate transformations too, by transforming the coordinate system you draw your object in. It's insanely more useful than only rotating the objects, because otherwise you couldn't easily rotate your whole view without calculating the transformations for every single object you draw.
Logged

GlyphGryph

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4100 on: March 05, 2013, 09:23:14 am »

I imagine the difference is that OpenGL also had some /other/ rotation model.

This is the only type of rotation you can do with javascript and canvas.
Logged

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4101 on: March 05, 2013, 03:22:35 pm »

It is funny how somebody can be so happy with a blank screen. I mean it isn't just any blank screen, it is a resizable blank screen that will stretch to any resolution, assuming there is a graphic to draw on it, and there isn't, but if there was, oh boy! It is the most perfect blank screen really... Like making your own canvas to paint on.

Programming java is so fucking zen. I forgot how much it makes you want to grow a beard.

I started growing a beard around when I started really working with Java. Coincidence? I think not.

Also, I no longer hate Java with a burning passion. The title of "worst language I've ever had to work with" now belongs to VB.

Btw, >> is okay in C++11. :D Or I think it is.

This is true. C++11 -compliant compilers have to be smart enough to figure out the difference between nested templates and stream operators.

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4102 on: March 05, 2013, 03:25:16 pm »

VB isn't a language, it is a learning tool to help the young'ns understand control structures and such before they learn their first language.
Its like saying crawling is the dumbest way of walking.

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4103 on: March 05, 2013, 03:47:21 pm »

I imagine the difference is that OpenGL also had some /other/ rotation model.

Before vertex shaders happened, OpenGL only had this one rotation model, and it was perfectly enough, but given the nature of OpenGL, I can't really imagine any other possible way of rotating stuff.
Logged

Virex

  • Bay Watcher
  • Subjects interest attracted. Annalyses pending...
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4104 on: March 05, 2013, 04:09:51 pm »

I suppose that when using the old OpenGl, one could just multiply matrices to get the compound operation one wants, while Java doesn't use matrices to compute translations/rotations/scaling. That makes quite a difference in the ease of use.
Logged

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4105 on: March 05, 2013, 08:50:14 pm »

VB isn't a language, it is a learning tool to help the young'ns understand control structures and such before they learn their first language.
Its like saying crawling is the dumbest way of walking.

Except it's actually taught as a "real" programming language here at my uni. Either alongside or after Java.

Makeitstopmakeitstopmakeitstop

Max White

  • Bay Watcher
  • Still not hollowed!
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4106 on: March 05, 2013, 09:00:14 pm »

I actually have the best memories of VB.
Back in highschool we were learning it, and the teacher gave us sheets of paper with code for us to copy into Visual Studio. That was his teaching method. I hated it because looking at this obscure arrangement of letters and symbols I didn't understand what any of it actually meant, and felt that just copying the code from paper to compiler I wasn't picking up on anything. Everybody else seemed content with their progress, so I assumed they actually understood what was in front of them.

After about two weeks of this class, I had a sudden moment of brilliance and the code actually started to make sense. I looked over all the past lessons and found I could actually read them! For the rest of the year, while everybody else was struggling to actually solve problems, I was doing incredibly well and finishing programs faster than the teacher expected anybody to be able to.


That was how I learnt that most people don't care about understanding something, and if you are frustrated at your lack of ability to grasp something, it is a good thing, because it means you are still trying.

Good times...

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4107 on: March 06, 2013, 03:34:57 am »

That was how I learnt that most people don't care about understanding something, and if you are frustrated at your lack of ability to grasp something, it is a good thing, because it means you are still trying.
Wise words, Mr. White.
Logged

Sirus

  • Bay Watcher
  • Resident trucker/goddess/ex-president.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4108 on: March 06, 2013, 03:50:19 am »

Anyone have some ideas on how to record minimum and maximum values in C?

I have an assignment where the user enters as many positive integers as he or she wishes, and the program adds them all up, averages them, and displays the smallest and lowest value entered. The only idea I've had for the last two is to give default values for smallest and highest, and then compare entered values to see if they exceed those values, something like this:
Code: [Select]
largest = 0;

if (number > largest)
   largest = number;
Problem is, to determine if a number is smallest, the only way I can think of to make it work is by giving the "smallest" variable the largest possible value for integers and working off of that. I assume there's another way to make it work.
Logged
Quote from: Max White
And lo! Sirus did drive his mighty party truck unto Vegas, and it was good.

Star Wars: Age of Rebellion OOC Thread

Shadow of the Demon Lord - OOC Thread - IC Thread

olemars

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4109 on: March 06, 2013, 04:07:46 am »

That's the standard method. What seems problematic about it?
Logged
Pages: 1 ... 272 273 [274] 275 276 ... 796