Author Topic: What are you working on? :D  (Read 80615 times)

0 Members and 1 Guest are viewing this topic.

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 3
  • -Receive: 20
  • Posts: 917
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #510 on: September 05, 2011, 09:02:28 AM »
New post cuz this is a bit big. Taken from the top link in my previous post, second page of comments. Replace the Start() function in GlobalHook with this Start() function. Also, remember I know NO C#.

Quote
Class GlobalHook
 
public void Start()
{
      if (!_isStarted && _hookType != 0)
            {
 
                // Make sure we keep a reference to this delegate!
                // If not, GC randomly collects it, and a NullReference exception is thrown
                _hookCallback = new HookProc(HookCallbackProcedure);
 
                _handleToHook = SetWindowsHookEx(
                    _hookType,
                    _hookCallback,
                    System.Diagnostics.Process.GetCurrentProcess().MainModule.BaseAddress,
                    0);
 
                // Were we able to sucessfully start hook?
                if (_handleToHook != 0)
                {
                    _isStarted = true;
                }
 
            }
}

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 3
  • -Receive: 25
  • Posts: 1,512
  • They'll eat you next!
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #511 on: September 06, 2011, 06:08:45 AM »
So, I have another question(regarding C#) and that is:

How do I reset my screen, or remove all of the drawings I've done? I've treid to clear all the graphics and redraw the background, but it only gives flickering... So any idea?

kmercy

  • Seedling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 34
Re: What are you working on? :D
« Reply #512 on: September 06, 2011, 11:52:31 AM »
Graphics.Clear();

should clear them all then you redraw after presuming thats how you are doing it but i would need to see the code to see how you are drawing them

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 3
  • -Receive: 25
  • Posts: 1,512
  • They'll eat you next!
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #513 on: September 06, 2011, 01:14:12 PM »
No, you need a color, and setting it no color makes it black x.x

Also the flickering that's made by setting the background also makes it impossible to see anything...

kmercy

  • Seedling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 34
Re: What are you working on? :D
« Reply #514 on: September 06, 2011, 05:20:08 PM »
that makes no sense you since thats what you asked how to get rid of the drawings so you will need to post the code

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 3
  • -Receive: 25
  • Posts: 1,512
  • They'll eat you next!
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #515 on: September 07, 2011, 06:30:58 AM »
Here:

Code: [Select]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {

        public double Zoom = 4;
        public double CameraX = 0;
        public double CameraY = -100;
        public int XPos = 100;
        public int YPos = 100;
        public bool[] MDown;
        public int MouseClicks = 0;

        public Form1()
        {
            InitializeComponent();
        }

        public void Render()
        {

            Graphics g = Panel.CreateGraphics();

            g.DrawImage(Bitmap.FromFile("C:\\Users\\User\\Desktop\\C# Examples\\Test2\\WindowsFormsApplication1\\WindowsFormsApplication1\\Picture.png"), Convert.ToInt32(CameraX) + XPos, Convert.ToInt32(CameraY) + YPos, Convert.ToInt32(400 * Zoom), Convert.ToInt32(400 * Zoom));

        }

        private void Timer_Tick(object sender, EventArgs e)
        {
            Render();
        }


        protected override void OnMouseDown(MouseEventArgs e)
        {
            switch (e.Button)
            {
                case (MouseButtons.Left):
                    MDown[0] = true;
                    break;
                case (MouseButtons.Middle):
                    MDown[1] = true;
                    break;
                case (MouseButtons.Right):
                    MDown[2] = true;
                    break;
                case (MouseButtons.XButton1):
                    MDown[3] = true;
                    break;
                case (MouseButtons.XButton2):
                    MDown[4] = true;
                    break;
            }
            MouseClicks = e.Clicks;
        }

        private void Panel_Scroll(object sender, ScrollEventArgs e)
        {
            if (e.NewValue != 0)
            {

                Zoom = Zoom * (1 + (e.NewValue / (720*Zoom)));

            }
        }
    }
}

Have been focusing on other things since all the comments, I'll begin making progress soon hopelyfully :)

But I don't understand why the scrolling isn't working, the mouse clicking is fine though :P

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 3
  • -Receive: 25
  • Posts: 1,512
  • They'll eat you next!
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #516 on: September 11, 2011, 06:44:13 AM »
Ok, I've been going to java again, I know it very well too! But theres that one problem I face always!

You want to have classes to separate things easier and stuff, you don't use Arrays, like I did on Eufloria! So when it comes to check something with all the units from one class, you need an array to span over all of them to be able to select them. But I get a crash whenever doing that!

So, any idea of how to be able to select all of the different units from one class without any problems?

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 3
  • -Receive: 20
  • Posts: 917
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #517 on: September 11, 2011, 11:04:40 AM »
Thirteen and a half years old, but might be of use.

http://java.sun.com/developer/technicalArticles/ALT/Reflection/

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 3
  • -Receive: 25
  • Posts: 1,512
  • They'll eat you next!
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #518 on: September 14, 2011, 02:31:12 PM »
So this will leave me with something like this:

Code: [Select]

NumThings = 0
Text = {}

for i = 1,math.random(1,1000) do

NumThings = NumThings + 1
Text[i] = math.random(1,100)

end

for i = 1,NumThings do

print(Text[NumThings])

end

Considerd a basic example :)
« Last Edit: September 14, 2011, 02:34:34 PM by Aino »

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 3
  • -Receive: 25
  • Posts: 1,512
  • They'll eat you next!
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #519 on: September 27, 2011, 07:53:24 PM »
I believe I'll create a new map soon, It's gonna be weirder than weirdest!

An, what I meant was(in the previous posts): to run through the objects from a class, like say it's three objects from the same class:

Quote
Name: Betty
Income: 300$ daily
Taxes: 50
Children: 0
Quote
Name: Chuck Testa
Income: 999999999$ daily
Taxes: 0
Children: 35557968 dead animals
Quote
Name: Alex
Income: 750$ daily
Taxes: 100
Children: 2

Now each have their individual name, income, taxe and amount of children. But they all come from the same class... This is called polymorphism!

What I looked for was how do I check a field/run a method from every single object from the same class?

And whis is polymorphism, what you guys told about polymorphism is overloading methods :)
I also hope this is useful for newbies, polymorphism is a simple thing, but very hard to learn...

Orion63

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 73
  • We are the Knights who say... NI!
Re: What are you working on? :D
« Reply #520 on: September 27, 2011, 08:44:09 PM »
Now each have their individual name, income, taxe and amount of children. But they all come from the same class... This is called polymorphism!

Hum...Nope...That's just regular objected-oriented programming...

Quote
What I looked for was how do I check a field/run a method from every single object from the same class?

Store all objects created in a array, and loop through it....

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 3
  • -Receive: 25
  • Posts: 1,512
  • They'll eat you next!
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #521 on: September 28, 2011, 07:12:25 AM »
I knew it was called Object-orienting, but it's also called Polymorphism(atleast what I've learnt...).

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 3
  • -Receive: 20
  • Posts: 917
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #522 on: September 29, 2011, 05:06:41 PM »
*bzzzzt*

Nope, it's not.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 3
  • -Receive: 25
  • Posts: 1,512
  • They'll eat you next!
  • Eufloria: Yes
Re: What are you working on? :D
« Reply #523 on: September 30, 2011, 05:56:22 PM »
Well, Polymorphism is several things, and Object-orienting is one, Method/Function overloading is another(why call any of this polymorphism when they have indivdual names too?) and another thing. Read http://en.wikipedia.org/wiki/Polymorphism_%28computer_science%29!

So, Polymorphism is both overloading methods and functionad and object-orienting! Do we agree now? :)

Orion63

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 73
  • We are the Knights who say... NI!
Re: What are you working on? :D
« Reply #524 on: September 30, 2011, 08:22:44 PM »
You know, you're quoting an article that gives us reason, right?

Is Subtype Polymorphism, what you're confusing by Object Oriented programming?

An example of subtype polymorphism, the good old shape example(I have a Pascal(aka old) programming book with that example ^^)
Language is Python, because it's the closest thing to pseudo-code...

Code: [Select]
Class Shape(object):
    def getArea(self):
        pass

class Square(Shape):
    def getArea(self):
        return self.side ** 2)

class Circle(Shape):
    def getArea(self):
        return math.pi *self.radius ** 2

Since any shape can have his area measured, it makes sense, that the Shape class has a getArea method. But you can't determine the area of any random shape, by the same method, so you use different methods, with the same goal...