Register    Login    Forum    Search    FAQ

Board index » Everything




Post new topic Reply to topic  [ 20 posts ]  Go to page Previous  1, 2
Author Message
 Post Posted: May 27th, 2012, 12:13 pm 
User avatar

Joined: May 19th, 2012, 11:38 pm
Posts: 814
Hi chilli,

Well I don't quite understand the theory behind how the rotation works. I can however modify bits to make it faster or slower. I know enough to make it do what I want, but don't understand why it works.

Anyway I thought I would randomize the colours. Now I run into a couple of problems here.
First of all the randomizing works, but much to fast.
I had a bit of fun with scope LOL. For a start I initialized r,g,b inside an if statement, and instantly found it wouldn't work outside of the if statement, and then so I had to take it outside the if statement for scope to work.

Anyway I got it to work. Now over a period of time the colours change. Next I would like the colours to slowly transcend from one colour to the next. So I am thinking that once the random number is picked, instead of instantly changing it should change slower. That is my next goal.
Of course this code will only work in time correctly on my computer. Also I have upped the rotation speed to some crazy speed to give a cool effect.

Also later I think this random colour generator should be made a function which returns the values of r,g,b and I think that would make my code cleaner, and also I can re-use this function in other parts of my code. Actually it might be better to make it a class and then I can incorporate all the timing information in the class itself. I am probably trying to run before I can walk heh heh.

I tried to send the zip file, but for some reason even though I only changed a few lines it is 17mb and the file limit here is 10mb.

Here is my code so far
Code:
if (colchange>100)
   {
      r=(rand() % 255);
      g=(rand() % 255);
      b=(rand() % 255);
      colchange=0;
   }

   colchange++;
   Draw( rotationAngle,400,250,r,g,b );


Asimov

_________________
----> Asimov
"You know no matter how much I think I have learnt. I always end up hitting brick walls"
http://www.asimoventerprises.co.uk


Top 
 Profile  
Reply with quote  
 Post Posted: May 27th, 2012, 12:38 pm 
User avatar

Joined: April 22nd, 2012, 12:33 pm
Posts: 1492
Location: Finland
The project is huge, because it generates all the files it needs once you run it (debug stuff).
Before you send it here, clear it from these files, as it will be generated for us again as well.
see: http://www.planetchili.net/forum/viewtopic.php?f=3&t=2

_________________
ʕ •ᴥ•ʔ


Top 
 Profile  
Reply with quote  
 Post Posted: May 27th, 2012, 1:09 pm 
User avatar

Joined: May 19th, 2012, 11:38 pm
Posts: 814
Hi Lux,

You are so right. Thanks. How stupid of me.

I have attached the file now. Only 450k.

I am now planning on making a colour Class rather than having all the code in the main game Class.
It's been a long time since I have made a Class, so I am a bit vague, but I am going to make a separate header file and cpp file like Chilli has done. Before I used to make them all in the header files, so this will be something new to me. So in theory I won't have to set my r,g,b values in the Game class, they will be set in the contructor of the Colour Class. I will probably screw this up LOL.

You won't believe this. Last night I was watching the Tic tac toe tutorial and I fell asleep and when I woke up I was up to lesson 18 LOL. Will have to re-watch now.

Asimov


Attachments:
File comment: Colour change wacky shape
SpirocrapColourChange.zip [449.06 KiB]
Downloaded 30 times

_________________
----> Asimov
"You know no matter how much I think I have learnt. I always end up hitting brick walls"
http://www.asimoventerprises.co.uk
Top 
 Profile  
Reply with quote  
 Post Posted: May 27th, 2012, 3:22 pm 
Site Admin
User avatar

Joined: December 31st, 2011, 4:53 pm
Posts: 3233
Location: Japan
Funky modification you made there Asimov! By the way, when you uploaded the project you forgot to delete the Debug folder from the Framework sub-folder.

Don't worry about screwing shit up, that's where all the real learning is done anyways. ;) I will be starting classes and stuff within the next three or four lessons, so you'll have a head start at least.

_________________
Chili


Top 
 Profile  
Reply with quote  
 Post Posted: April 1st, 2017, 7:19 pm 
User avatar

Joined: September 14th, 2015, 10:58 pm
Posts: 27
Location: Jena
Hi authors of spirocrap,

i modified the star code to make a cell out of it. I also added variables for positioning and resizing of star and also for making more lines in the drawing grid. I wonder though why the crap is being drawn so slow.

Attachment:
asimovs_star_plus_cell.zip [33.87 KiB]
Downloaded 5 times


Here a visual of how separate parts of star and cell are drawn according to code:
Attachment:
Lesson_10_asimovs_star.jpg [63.25 KiB]
Not downloaded yet

_________________
Kraut


Top 
 Profile  
Reply with quote  
 Post Posted: April 5th, 2017, 3:22 pm 
 

Joined: March 31st, 2017, 2:18 pm
Posts: 2
Well, minor time saving would be to make all Drawing function's parameters "const int& " instead of just ints, as it's copying these values for no good reason.

See image, at larger radius sizes it's taking 14 seconds to run through the while loop you have setup. There's alot to draw there :o


Attachments:
Capture.JPG [31.74 KiB]
Not downloaded yet
Top 
 Profile  
Reply with quote  
 Post Posted: April 5th, 2017, 3:25 pm 
Site Admin
User avatar

Joined: December 31st, 2011, 4:53 pm
Posts: 3233
Location: Japan
Are you running that in Release? With the debugger detached?

_________________
Chili


Top 
 Profile  
Reply with quote  
 Post Posted: April 5th, 2017, 3:58 pm 
 

Joined: March 31st, 2017, 2:18 pm
Posts: 2
Yes - but i just went and tried it again and it's down to 10 ms... my computer must've taken a poop.


Top 
 Profile  
Reply with quote  
 Post Posted: April 5th, 2017, 10:01 pm 
User avatar

Joined: May 19th, 2012, 11:38 pm
Posts: 814
Hi Mr Matt,

I would download and have a look, but had to uninstall visual studio 2010 to do some stuff. Only got QT installed at the moment because I am making some application software and it is a little quicker in QT to do what I want.

I will re-install visual studio 2010 and have a look at these soon.

_________________
----> Asimov
"You know no matter how much I think I have learnt. I always end up hitting brick walls"
http://www.asimoventerprises.co.uk


Top 
 Profile  
Reply with quote  
 Post Posted: April 6th, 2017, 1:17 am 
Site Admin
User avatar

Joined: December 31st, 2011, 4:53 pm
Posts: 3233
Location: Japan
Yeah I was gonna say! Anyways, as for optimizations, the pass-by-value vs. pass-by-reference is usually not that big of a win. In this case it is actually technically faster to pass by value (although it probably doesn't matter either way actually; the compiler is gonna inline that shit anyways).

_________________
Chili


Top 
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
 
Post new topic Reply to topic  [ 20 posts ]  Go to page Previous  1, 2

Board index » Everything


 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for: