Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Dark GDK VS 2008+ and ShapDevelop 3.2+

Author
Message
pedrolvicente
User Offline
Joined: 17th Feb 2017
Location: Portugal
Posted: 19th Feb 2017 17:04 Edited at: 20th Feb 2017 14:38
Hello everyone,

I'm new here since yesterday I was trying c# with code snippets here for vs2008 up to 2015.

I got the project successful. I will give my code template for C# here as a community driven.

The project must be upgraded from 2008.

Every time everyone needs to create a new code template, you should call references inside c# vesion.

For instance DarkGDK, DGDKLib. You must make to get the code done and built.

I'm here to help. So, any doubt I will try to give an answer soon as possible.

[code lang=c#]
/*
* Criado por SharpDevelop.
* Utilizador: astro
* Data: 19/02/2017
* Hora: 16:52
*
* Para alterar este modelo usar Ferramentas | Opções | Código | Alterar Cabeçalhos Standard
*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
using DarkGDK;


namespace GDKCs.properties
{

/// <summary>
/// Description of Class1.
/// </summary>

public class Class1
{
Bitmap image1;
//variables
private static Boolean LeftMouseDown;
private static Boolean[] KeyDown = new Boolean[104];
private static int lastScanCode;

public static void SetupKeyEvents() // Must be called once before any of the following functions
{

for (int i = 0; i <= KeyDown.Length; i++)
KeyDown[i] = false;
}
public static Boolean SingleKeyPress(DarkGDK.IO.Keys kKey)
{

if (DarkGDK.IO.Keyboard.State(kKey) && !KeyDown[DarkGDK.IO.Keyboard.ScanCode])
{
KeyDown[DarkGDK.IO.Keyboard.ScanCode] = true;
lastScanCode = DarkGDK.IO.Keyboard.ScanCode;
return true;
}
else if (DarkGDK.IO.Keyboard.ScanCode == 0) // Means we aren't pressing any key
{
KeyDown[lastScanCode] = false;
return false;
}
else
return false;
}

public static Boolean SingleLeftClick()
{
if (DarkGDK.IO.Mouse.LeftClick && !LeftMouseDown)
{
LeftMouseDown = true;
return true;
}
else if (!DarkGDK.IO.Mouse.LeftClick)
{
LeftMouseDown = false;
return false;
}
return false;
}

public void NGame(){

}

public void LGame()
{


}

public void OGame()
{
}
public void OptGame()
{
}
public void qGame(){
System.Environment.Exit(1);
}

public void Menu()
{
do
{
int c = 1;
switch(c){
case '1': Console.Write("New Game\n");
break;
case '2': Console.Write("Load Game\n");
break;
case '3': Console.Write("Online Game\n");
break;
case '4': Console.Write("Options\n");
break;
case '5': qGame();
break;
default: Console.Write("Error... Quitting\n");
break;
}

}while(true);

}


//Bitmap Loader
private void Button1_Click(System.Object sender, System.EventArgs e)
{

try
{
// Retrieve the image.
image1 = new Bitmap(@"C:\Documents and Settings\astro\"
+ @"DarkBasic\ekron.bmp", true);

int x, y;

// Loop through the images pixels to reset color.
for(x=0; x<image1.Width; x++)
{
for(y=0; y<image1.Height; y++)
{
Color pixelColor = image1.GetPixel(x, y);
Color newColor = Color.FromArgb(pixelColor.R, 0, 0);
image1.SetPixel(x, y, newColor);
}
}

// Set the PictureBox to display the image.
//PictureBox = image1;

// Display the pixel format in Label1.
//Label = "Pixel format: "+image1.PixelFormat.ToString();

}
catch(ArgumentException)
{
MessageBox.Show("There was an error." +
"Check the path to the image file.");
}
}
}
}


Thank you.


Attachments

Login to view attachments
Morcilla
14
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 20th Feb 2017 11:02 Edited at: 20th Feb 2017 11:02
@pedrolvicente, Your post cannot be seen, or at least I cannot see any text, sorry
pedrolvicente
User Offline
Joined: 17th Feb 2017
Location: Portugal
Posted: 20th Feb 2017 12:31
It's on the zip.

Also I will give later the code snippet here.
Morcilla
14
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 21st Feb 2017 09:54
Ok, now I can see it. Thanks for the contribution

It looks like Dark GDK .NET code to me, isn't it?

So what is it used for?
pedrolvicente
User Offline
Joined: 17th Feb 2017
Location: Portugal
Posted: 21st Feb 2017 15:22
I had an issue on VS 2015 Community Edition. So, I saw a few topics with code snippets, a few tutorials about other versions and I decided to check them all and see what happened.

I saw a tutorial about sharpdevelop and VS 2010 and when I went on VS 2015 I got errors because the libraries.

I've studied sharpdevelop and VS 2010 after that I went to test the code interop between c# and VB.net and I got.
Morcilla
14
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 27th Feb 2017 12:57
So, does this allow us to use DGDK with C# or something like that, or does it just integrate DGDK with sharpdevelop IDE?
Looks cool by the way.

Login to post a reply

Server time is: 2017-11-25 11:06:22
Your offset time is: 2017-11-25 11:06:22