collapse collapse

* Who's Online

  • Dot Guests: 40
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Board Stats

  • stats Total Members: 88
  • stats Total Posts: 11163
  • stats Total Topics: 1699
  • stats Total Categories: 4
  • stats Total Boards: 76
  • stats Most Online: 248

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Nathan

Pages: 1 [2] 3 4 5 6 7 ... 46
31
C / Re: CALL OF THE OCEAN "FORE": Underwater Warfare
« on: February 02, 2014, 08:11:21 pm »
I see in your code you are casting the return of malloc - technically you don't need to do that see this SO article:

http://stackoverflow.com/questions/1835193/is-it-a-better-practice-to-typecast-the-pointer-returned-by-malloc

I am not the C language police so I don't care - just be aware that other "undergrad C experts" may make a comment.

There is no history of commands (ie I can't hit up to go to previous commands) - somewhat annoying but not a big deal.

There appears to be a memory leak according to valgrind

Code: [Select]
==21907== HEAP SUMMARY:
==21907==     in use at exit: 856 bytes in 22 blocks
==21907==   total heap usage: 24 allocs, 2 frees, 912 bytes allocated
==21907==
==21907== LEAK SUMMARY:
==21907==    definitely lost: 88 bytes in 10 blocks
==21907==    indirectly lost: 768 bytes in 12 blocks
==21907==      possibly lost: 0 bytes in 0 blocks
==21907==    still reachable: 0 bytes in 0 blocks
==21907==         suppressed: 0 bytes in 0 blocks
==21907== Rerun with --leak-check=full to see details of leaked memory
==21907==
==21907== For counts of detected and suppressed errors, rerun with: -v
==21907== Use --track-origins=yes to see where uninitialised values come from
==21907== ERROR SUMMARY: 60 errors from 10 contexts (suppressed: 11 from 6)

32
Introductions / Re: Hello
« on: January 06, 2014, 08:19:50 pm »
Welcome to the forums! What language(s) are you using?

33
SDL / Re: SDL project
« on: December 01, 2013, 10:37:46 pm »
what do you mean by repo?

You can be my guinea pig! I've written some tutorials on using svn, mercurial and git. You can view them under videos and tutorials - https://app.box.com/lewisopsys

Let me know if you don't understand something - I would really appreciate your feedback as I'll be giving this to a class.

34
SDL / Re: SDL project
« on: December 01, 2013, 10:19:36 pm »
Hey um.. Maybe you can talk to Key or Nathan about setting up a repository or something, so I can actually run your program, and help when you update it.
I like where you are going with it, and it's one of those projects where you can ask a lot of questions and learn a lot of stuff. Very challenging.

@ Faoline - You can signup at https://srchub.org/ and request a repo - SVN is easiest but git is more powerful. mercurial sits somewhere in between.

35
SDL / Re: SDL project
« on: December 01, 2013, 05:40:47 pm »
Yeah, it would work that way, but I meant with the way he is doing it.

I'm not sure how one would go about utilizing bit operations for direction check, but there must be a better way than his first attempt.

Hmm I couldn't get BIT1 || BIT2 syntax working but here is two ways you could do bit fields:

http://codepad.org/Dzf12msf

http://codepad.org/lhQBjcU0

36
SDL / Re: SDL project
« on: December 01, 2013, 04:07:32 pm »
This doesn't actually work:
player_dir == DOWN || LEFT || RIGHT

You have to to do "player_dir == " for each equality check. No shortcuts for this.
i.e.: player_dir == DOWN || player_dir == LEFT || player_dir == RIGHT


Other than that, none of the code looks like it would produce an error.
But here is another thing:
switch(player_dir)
case UP:
if(player_dir == DOWN || LEFT || RIGHT)

The if statements in each case don't make any sense. You specifically know that player_dir isn't any of the directions in any if statement.

This would work if it was a bit field or bool values:

Example with bool values: http://codepad.org/Mycf7xuY

37
OpenGL / Re: SDL question
« on: November 26, 2013, 09:13:59 pm »
see what i mean about the why lol i knew that there had to be a reason why its a pointer!! and with what nate said in another post about passing the address of pointers as parameters it means we can deal with the new values on a more global scope rather than just within that function and im also gonna assume that this is why those variables are pointers so we can deal with their return values more globally

One of the reason why a pointer concept exists is to allow a variable life to exist outside of the current scope. Another is to give you the ability to allocate a chunk of memory that may be too big to fit into the stack (such as a large array). There is of course a trade off - heap is slower than using stack. However, there is limited amount of stack memory. Usually what happens is people use containers such as vector which maintains an array of objects on the heap. Using a vector may lead to poor performance depending on how you use it - this is due to the fact that in order to resize it performs a copy (if you haven't specified a move constructor) to a new array. Copy operations can be wasteful or cause issues with your code. Though the one cool thing about a vector is that if you need to pass it into a C function as an array you can do &vector[0] and the function can perform pointer arithmetic.

38
OpenGL / Re: SDL questioin 2
« on: November 26, 2013, 08:03:09 pm »
Code: C++
  1. int number = 5;
  2. int* p1 = &number // p1 would not have a value of 5 it would have the memory address something like 00000001 right?

Technically p1 is an address pointing to the address of number. Anything that happens to number will also technically happen to p1.

See this example: http://codepad.org/PxSKsHNE

The reason for & symbol is that you are saying "send the address of the variable instead of a copy" which will allow the function alter the contents of the variable so that when the function returns the variable may have a different value. Without the & symbol you are saying "send a copy of this variable to the function". The function can still alter the variable but the effect will only be for it's scope.

39
OpenGL / Re: SDL question
« on: November 26, 2013, 07:49:32 pm »
I think this explains the whitespace issue nicely - http://www.stroustrup.com/bs_faq2.html#whitespace

40
Win32 / Re: error trying to print text to the window
« on: November 23, 2013, 04:51:45 pm »
Ahh ok makes sense - I stumbled upon this page ( http://msdn.microsoft.com/en-us/library/office/cc842072.aspx ) and didn't notice it was for Office. This has a much better explanation - http://msdn.microsoft.com/en-us/library/c426s321(v=vs.100).aspx

41
Win32 / Re: error trying to print text to the window
« on: November 23, 2013, 03:46:15 pm »
Nevermind. A solution to an earlier problem from a tutorial that Valk provided was the cause. but what i dont understand is why?? why can't everything just be seemless? and why doens't this mess up everything else in the program?? why why why why is Win 32 api like bending me over and ramming me with a spiked gauntlet with no lube :(

To answer your why isn't C++ easier - the simple fact that we have a C++ FAQ and a C++ FQA paints a pretty clear picture. There are many different ideas in language theory - and since C++ is widely used everyone is going to have a different opinion. This is evident by different frameworks and how they are structured.

Win32 API actually isn't difficult. It's just C functions. However, Microsoft had foresight to include support for Unicode characters. This makes things a little big more interesting and introduces a "wide character" type. TCHAR is really just a char. I'm not sure why you got that error - next time you should post a complete sample of your program.

42
Beta Releases / Re: My DM Player tracker
« on: November 18, 2013, 05:49:40 pm »
well "Make Changes?" and "Create another character", i thought, were very straightforward yes or no questions.

For a Yes/No question:

Is it YES, or Yes, or Y or y? Or do you accept any one of them?

43
Introductions / Re: Saying hi
« on: November 18, 2013, 02:34:05 pm »
Hi! Welcome to celestialcoding! Please do post any questions or comments that you want to bounce off of us :) . I think we have a subforum for most major languages and technologies.

44
Beta Releases / Re: My DM Player tracker
« on: November 17, 2013, 10:23:25 pm »
I was very confused on what I should enter. Prompts that look like this would definitely help:

Code: [Select]
Make changes (I/A/W/M)?
Code: [Select]
create another charactor (Y/N)?

45
C++ / Re: [7] Defines and Macros
« on: August 15, 2013, 09:43:11 pm »
Does the header called, "windows.h", actually work on a Mac? I'm using C++ on Xcode 4.6.3. I started coding a new program and on the second line I wrote:

     '#include <windows.h>',
but my program just fails and the cause of it was the 'windows.h', header.
I don't understand, so does the header, windows.h, work on a Mac, or what's up?

This version should work on your Mac. It compiles for me with no errors/warnings on Linux with g++ with -Wall.

Code: C++
  1. #include <iostream>
  2. #include <string.h>
  3. using namespace std;
  4.  
  5. // Our first Define!!!!
  6. #define Message "The answer is "
  7.  
  8. // Our first Macro!
  9. #define ADD(a,b) (a+b)
  10.  
  11.  
  12. int main()
  13. {
  14.     int x;
  15.     int y;
  16.     int i;
  17.     cout << "Enter 2 numbers to add with 5!\n >";
  18.     cin >> x;
  19.     cin >> y;
  20.     i= ADD(x,y);
  21.     cout << Message << i << endl;
  22.     cout << "Press any key to continue" << endl;
  23.     cin.ignore();
  24.     cin.get();
  25.  
  26.     return 0;
  27. }
  28.  

46
C# / Re: C# 0x90 = 144?
« on: August 15, 2013, 09:36:34 pm »
...Since you told it to store an array of integers (base 10) it automatically converts it for you. You could output to base16 easily by saying Console.WriteLine(myarray2.ToString("x"));

Yeah! that's awesome haha C# is a great world to live in AHAHAH, Well I'm actually learning all this as a pre-phase to display sniffed packets to the console from a game :D

Also I found out if I type:

Console.WriteLine(myarray.ToString("X2"));

The output will be the Hex value displayed to the console as in 2 bytes :D Right?

I don't that controls how many bytes it displays - it just says "display the converted value left padded with 0s".

So:

1 = 01
5 = 05

10 = 0A
17 = 11

47
C# / Re: C# 0x90 = 144?
« on: August 14, 2013, 12:13:51 am »
Yup - 0x90 is the hex representation of 144.

Hex is base 16 and decimal is base 10 (how many fingers do you have ;)).

0x5 = 5

0xA = 10

Since you told it to store an array of integers (base 10) it automatically converts it for you. You could output to base16 easily by saying Console.WriteLine(myarray2.ToString("x"));

48
Projects / srchub - free source code hosting
« on: July 30, 2013, 09:50:41 pm »
Sourcehub is a free source code hosting service ran by yours truly.

I currently offer hosting for:

  • git
  • subversion
  • mercurial

To get a repo just register, login, click "Request project". Then I will need to go in and approve it :).

Sourcehub offers downloads (or also known as releases), issue tracker, wiki, and even code reviews. You can even add other people as contributors. The reason why I am doing this is simply because other free services have a habit of removing features (or shutting down in the case of google code) that you are using from under you - this will never happen at sourcehub.

Sourcehub is a fork of indefero with many bug fixes and new features. And as an olive branch - not only have I released the source code for srchub (something which is not technically required by the GPL), but I have also created a debian installer. So I have nothing to hide and I guarantee no PRISM backdoors to the NSA :). Also the installer will allow you to install either indefero or srchub. The srchub installer is naturally also open source.

12/23/2015 updates

  • 2 sets of backups - including:
    • tarsnap
    • rsync + attic
  • OTP has been intergrated
  • Project export and scrape of public projects
  • Service moved to gandi VPS
  • more than 170 projects hosted



Old thread



To show some evidence that I am somewhat capable of running this service: you can view stats here. Backups are performed using Backuppc to a readynas with 8TB of disk.

Where do I want to go with this?

* Offer jenkins hosting for every project as a continuous integration service
* Integrate OTP to passwords
* Openauth intergration
* Ability to export and import a project

Here are some FAQs:

1. Are you currently encrypting or are you going to encrypt repos?

I'm thinking about this - and currently I am not encrypting repos. This is something I would like to look into - however right now the drives in the KVM hosts are software RAID-1 7200RPM drives. So while I am already taking a hit from the software RAID, I wouldn't want to add another layer of potential bottlenecks. However, if I shoved some SSDs into the servers I think I could very well set that up.

2. Software RAID sucks!!! You should feel bad!

Yes, software RAID is much more resource intensive than hardware RAID but Linux software RAID works so well. For example - if a hardware RAID controller fails - I may have to purchase (or already have an extra) the same controller. With software Linux RAID I can take both drives, put them into another system - reconfigure some stuff like networking and I'm back up and running. I have personally done this before with great success. However SSDs would negate the performance hits (in my opinion).

3. You use backuppc to backup the repos as well?

Currently - yes. Since the repos are not under a high load - the probability of having a half-backup is very remote. I know about the KDE incident - which you can read about here and here.

4. I don't trust your service because [insert some vague reason here]. Would you assist me in setting up my own sourcehub/indefero instance?

To an extent. I'm not going to SSH to your box and set it up for you, but I will certainly point out documentation and answer questions about any issues you run into.

49
General Talk / Jenkins hosting
« on: April 18, 2013, 09:53:01 pm »
I would like to officially announce that I am hosting and supporting a jenkins instance.

Jenkins is a product that automatically compiles/builds your project, runs any tests, alerts you of failed tests and can even automatically deploy the compiled product to another location. This is huge when developing a project because you can see if your commit broke something AND jenkins can keep a copy of your successful builds. It can even build and push to your site automatically.

If you have any programming projects - you should contact me.

I currently have the following VMs ready to build:

  • Debian
  • CentOS
  • Windows

50
C++ / Re: [Sockets] Having some problems.
« on: February 28, 2013, 10:31:41 pm »
A bit off-topic but if you wish to support concurrency and you have no experience using winsock is an horrible idea. I would go for a library like Boost Asio or POCO, they both are very efficient and will take care of the concurrency behind a worker thread system. They don't enforce any premade protocol on you either, only give you an equivalent read / write system. This will most likely save you a lots of time and you won't run into errors like this one, and judging by your current code which is not using the most efficient way to handle networking on windows, you will gain performance, and also cross-platform ability.

http://www.boost.org/doc/libs/1_53_0/doc/html/boost_asio.html
http://pocoproject.org/

I recommend pytypes: http://www.melikyan.com/ptypes/

51
C++ / Re: C++ First Program
« on: February 06, 2013, 07:50:49 pm »
Speaking of which.. I've been trying to find a book that isn't 20 years old, that can help me out with windows programming. MSDN is great, but it pretty much has all three of those downfalls. And on top of that, they keep trying to push everyone to use some form of directx or mfc or other library. I would really just like a reference to the underlying code. No library that was created to make everything abstract and easy.


edit: This look like a good book? "Windows System Programming (4th Edition)"

Did you want native Windows API or something like C#?

52
Project Advertisment / Re: AI Bananza!
« on: November 13, 2012, 09:39:41 pm »
Nate... You got to take a calligraphy class or something man...

My handwriting is better than that I swear! I don't remember what I wrote that on - but it was probably a tablet.

53
Project Advertisment / Re: AI Bananza!
« on: November 12, 2012, 09:08:38 pm »
Here are my AI notes:

https://www.evernote.com/pub/adamsna/ai

Some of it is handwritten chicken scratch :P, I still have my AI book somewhere.

54
Project Advertisment / Re: Gunz The MMORPG [ Updated 6/3/2012 ]
« on: November 09, 2012, 10:31:00 pm »
You know, I've tried 5 different SVN software, and none of them can get the checkout working. What software are you guys using? Is it on Linux?

I'm pretty sure Justin uses Windows.
I have never had an issue with http://tortoisesvn.net/ . What URL are you using to checkout and what's the error? (screenshot might help too).

55
Request A Program or Tutorial / Re: Safedrv.exe
« on: October 27, 2012, 03:49:49 pm »
I'm sure it was not, It's just a movie  ;D

SafeDrv.exe and autorun.inf keep's popping in my flashdrive even though I've deleted it.
Sounds like one of those USB hopping viruses. What you can do is create a folder called SafeDrv.exe and autorun.inf on your flash drive. This way the virus can't write the file to the flash drive and they aren't usually smart enough to figure this out. I would also set the permissions on those files assuming you formatted your flash drive NTFS. If your flash drive is FAT32 you can't set permissions on files.

56
Request A Program or Tutorial / Re: Safedrv.exe
« on: October 25, 2012, 10:58:56 pm »
Well, there is no real way of doing #1. Best bet is to use safe mode, if that does not work, then you pretty much are forced to risk the chance, and put the anti virus on the computer and infect that flash drive as well. After you do that, you can always disable auto launch (should be done already) and plug it into another computer, then format the drive.


EDIT:
You could format it as NTFS and then add a permission of Everyone with read and your user on clean computer as full control.

More simply you could just use a CD-R(W). What I would do is boot with a live CD and run the anti-virus from there.

Nathan beat me, or do that. But live CD's for windows? Or is there a nix live CD that lets you run antivirus on windows systems? If so, does it work with bitlocker, if it does, you are a God.
Will setting permissions on the clean one to full and "Everyone" to read only really matter? The admin account that is infected on the compromised computer should still be able to overwrite that with the local admin. Pretty sure it lets you take ownership and do whatever you want to the file system after it is connected.

BartPE has been out forever:
http://www.nu2.nu/pebuilder/

DART could be useful:
http://technet.microsoft.com/en-us/library/ee532075.aspx

I would be surprised if DART didn't support bitlocker - but I wouldn't be so sure about BartPE.

As far as the USB idea:
The theory is that is Windows does not use usernames to identify users - at least not for permissions. It uses a kind of numeric ID (described here http://en.wikipedia.org/wiki/Security_Identifier ) - which has certain information such as computer ID and user ID. Just because you create the same username on two different computers - they will have different SIDs. This is supported by the fact when you delete a user it warns you that if you don't back up the user's key that you will never be able to restore their encrypted documents - EVEN IF you create it identically.
So on clean computer A if you assign a permission for "nathan" as full control - that SID won't resolve on computer 2 and thus you shouldn't have any rights (unless specified by the group "Everyone"). There are a few "well known" SIDs such as "Everyone", "Users" ect that will work on any system. (See a list here: http://support.microsoft.com/kb/243330 ).
In theory no two systems should have the same SID unless they were imaged or specifically set to that SID.

Side note: different SIDs sound like a problem in an enterprise environment - but that is what Active Directory is for. Using AD the user/computer/group/other accounts are stored in a central location.

Edit:
For a pre packaged ultimate BartPE - http://www.ubcd4win.com/

57
Request A Program or Tutorial / Re: Safedrv.exe
« on: October 25, 2012, 08:51:41 pm »
You could format it as NTFS and then add a permission of Everyone with read and your user on clean computer as full control.

More simply you could just use a CD-R(W). What I would do is boot with a live CD and run the anti-virus from there.

58
Updates / Forum Features
« on: October 21, 2012, 12:33:15 am »
I think we need this to point out some of the more subtle features of the forum.

First and foremost:

Code Tag
-----------------------------
Code: [Select]
[code]
The code tag does NOT require a language, it will attempt automatically figure out what language you typed and highlight accordingly:

Code: [Select]
print "hello, world";
Sometimes it can't figure it out like so:

Code: [Select]
cout << "hello, world" << endl;
So then you need to specify it using code=lang ex code=cpp

Code: C++
  1. cout << "hello, world" << endl;


Spoiler tag
-----------------------------

This tag will allow you to "hide" text from people who may not want to see it. It is call "spoiler" because it may spoil a surprise for a book/movie/show ect

Code: [Select]
[spoiler]testing[/spoiler]
(click to show/hide)

LaTex tag
-----------------------------

This tag allows to write LaTex code to draw/write out math symbols:

Code: [Select]
[tex]{\Delta t}=t_{2}-t_{1}[/tex]
{\Delta t}=t_{2}-t_{1}

Thread reviews
-----------------------------

Thread reviews all you to rate a thread. They will not appear for your own threads :).

1397-0

Inline attachments
-----------------------------

Inline attachments allow you to attach files, and images inline with the post without requiring a user to scroll down to the bottom to download/view it.

59
Code: [Select]
#pragma once

namespace Planets {

   using namespace System;
   using namespace System::ComponentModel;
   using namespace System::Collections;
   using namespace System::Windows::Forms;
   using namespace System::Data;
   using namespace System::Drawing;

   /// <summary>
   /// Summary for Form1
   /// </summary>
   public ref class Form1 : public System::Windows::Forms::Form
   {
   public:
      Form1(void)
      {
         InitializeComponent();
         //
         //TODO: Add the constructor code here
         //
      }

   protected:
      /// <summary>
      /// Clean up any resources being used.
      /// </summary>
      ~Form1()
      {
         if (components)
         {
            delete components;
         }
      }
   private: System::Windows::Forms::PictureBox^  pictureBox1;
   protected:
   private: System::Windows::Forms::Button^  btn_Start;
   private: System::Windows::Forms::Button^  btn_Stop;
   private: System::Windows::Forms::Timer^  timer1;
   private: System::ComponentModel::IContainer^  components;


   private:
      /// <summary>
      /// Required designer variable.
      /// </summary>


#pragma region Windows Form Designer generated code
      /// <summary>
      /// Required method for Designer support - do not modify
      /// the contents of this method with the code editor.
      /// </summary>
      void InitializeComponent(void)
      {
         this->components = (gcnew System::ComponentModel::Container());
         System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
         this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
         this->btn_Start = (gcnew System::Windows::Forms::Button());
         this->btn_Stop = (gcnew System::Windows::Forms::Button());
         this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));
         (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox1))->BeginInit();
         this->SuspendLayout();
         //
         // pictureBox1
         //
         this->pictureBox1->BackgroundImageLayout = System::Windows::Forms::ImageLayout::None;
         this->pictureBox1->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"pictureBox1.Image")));
         this->pictureBox1->Location = System::Drawing::Point(-2, 0);
         this->pictureBox1->Name = L"pictureBox1";
         this->pictureBox1->Size = System::Drawing::Size(587, 416);
         this->pictureBox1->SizeMode = System::Windows::Forms::PictureBoxSizeMode::StretchImage;
         this->pictureBox1->TabIndex = 0;
         this->pictureBox1->TabStop = false;
         //
         // btn_Start
         //
         this->btn_Start->Location = System::Drawing::Point(497, 12);
         this->btn_Start->Name = L"btn_Start";
         this->btn_Start->Size = System::Drawing::Size(75, 23);
         this->btn_Start->TabIndex = 1;
         this->btn_Start->Text = L"Start";
         this->btn_Start->UseVisualStyleBackColor = true;
         this->btn_Start->Click += gcnew System::EventHandler(this, &Form1::btn_Start_Click);
         //
         // btn_Stop
         //
         this->btn_Stop->Location = System::Drawing::Point(497, 42);
         this->btn_Stop->Name = L"btn_Stop";
         this->btn_Stop->Size = System::Drawing::Size(75, 23);
         this->btn_Stop->TabIndex = 2;
         this->btn_Stop->Text = L"Stop";
         this->btn_Stop->UseVisualStyleBackColor = true;
         this->btn_Stop->Click += gcnew System::EventHandler(this, &Form1::btn_Stop_Click);
         //
         // timer1
         //
         this->timer1->Interval = 50;
         this->timer1->Tick += gcnew System::EventHandler(this, &Form1::timer1_Tick);
         //
         // Form1
         //
         this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
         this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
         this->BackgroundImageLayout = System::Windows::Forms::ImageLayout::None;
         this->ClientSize = System::Drawing::Size(584, 412);
         this->Controls->Add(this->btn_Stop);
         this->Controls->Add(this->btn_Start);
         this->Controls->Add(this->pictureBox1);
         this->Name = L"Form1";
         this->Text = L"Planets";
         this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
         (cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox1))->EndInit();
         this->ResumeLayout(false);

      }
#pragma endregion

      // Static constants
      static const int xcenter = 200;
      static const int ycenter = 250;
      static double smajor = 150;
      static double sminor = 50;

      // Instance variable
      double angle1_degrees;
      double angle2_degrees;
      double angle3_degrees;

      // Drawing objects
      Drawing::Graphics^ g;
      Drawing::Brush^ yellowBrush; // Yellow for sun
      Drawing::Brush^ cyanBrush; // Cyan for planet

private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {

             // Construct drawing objects
             g = pictureBox1->CreateGraphics();
             yellowBrush = gcnew Drawing::SolidBrush(Color::Yellow);
             cyanBrush = gcnew Drawing::SolidBrush(Color::Cyan);
          }


private: System::Void btn_Start_Click(System::Object^  sender, System::EventArgs^  e) {
             angle1_degrees = 0;
             angle2_degrees = 0;
             angle3_degrees = 0;
             timer1->Enabled = true;
       }

private: System::Void btn_Stop_Click(System::Object^  sender, System::EventArgs^  e) {
             timer1->Enabled = false;
          }

private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) {

             // Declare local variables
             int x, y; // x,y coordinates of the planet
             double angle_radians; // angle measurement in radians

             // Refresh the picture box to remove old images
             pictureBox1->Refresh();

             // Draw the sun (use a rectangle as a guide)
             System::Drawing::Rectangle sunRect (xcenter,ycenter,16,16);
             g->FillEllipse(yellowBrush,sunRect); // draw sun

             // Draw the planet
             if (angle1_degrees >= 360) angle1_degrees = 0;
             if (angle2_degrees >= 360) angle2_degrees = 0;
             if (angle3_degrees >= 360) angle3_degrees = 0;

             angle_radians = ConvertToRadians(angle1_degrees);
             SetXY(x, y, angle_radians, 150,50);
             DrawPlanet(x, y);
             angle_radians = ConvertToRadians(angle2_degrees);
             SetXY(x, y, angle_radians, 30, 10);
             DrawPlanet(x, y);
             angle_radians = ConvertToRadians(angle3_degrees);
             SetXY(x, y, angle_radians, 80,20);
             DrawPlanet(x, y);

             // Increase angle by 5 degrees
             angle1_degrees +=5;
             angle2_degrees +=10;
             angle3_degrees +=15;

          }


   private: double ConvertToRadians(double angle_degrees){

             double angle_radians;
             angle_radians = angle_degrees * Math::PI /180;
             return angle_radians;
          }
   private: void SetXY(int& x, int& y, double angle_radians){

             x = xcenter + smajor * Math::Cos(angle_radians);
             y = ycenter - sminor * Math::Sin(angle_radians);

          }

   private: void DrawPlanet(int x, int y){

             System::Drawing::Rectangle planetRect(x,y,10,10);
             g->FillEllipse(cyanBrush, planetRect);
          };
   };
}


Here's the thing, if I don't put coordinates in behind SetXY(x, y, angle_radians then the planets are all on the same orbit and run into each other...these are planets not bumper cars...

Topazfae

This is your problem:
Code: [Select]
private: void SetXY(int& x, int& y, double angle_radians)It only takes 3 parameters.

Pages: 1 [2] 3 4 5 6 7 ... 46

Donate


* Search


* Recent Posts

Image Comparison by Shishka
[May 15, 2017, 01:18:02 pm]


Re: srchub - free source code hosting by Nathan
[December 14, 2015, 11:37:02 pm]


Re: srchub - free source code hosting by Celestialkey
[November 27, 2015, 08:51:42 am]


Updates by Nathan
[October 30, 2015, 08:27:36 pm]


Re: Client-Server Messaging by Nathan
[October 25, 2015, 05:48:57 pm]