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 - Krice

Pages: 1 [2] 3 4 ... 154
16
Off-topic (Locked) / Corona virus
« on: March 22, 2020, 10:56:25 AM »
It has not changed a lot in my case. I live in a small village in middle of Finland which is pretty much the last place it's going to hit. We have one confirmed death, but there will be more. I think Finland is a bit different than many other countries, because we have strong social distancing already, which I think has become a joke even. Where I live we have not run out of anything, not even toilet paper. At least not yet. I'm not afraid to get corona even though I'm not sure how it's going to affect me. Corona has already revealed interesting things about the modern society, we were certainly not ready for this and didn't act soon enough to stop traveling which in many countries was the main way of spreading. It's simply too easy to travel around the world (if you are wealthy enough to do that) and catch viruses.

17
Classic Roguelikes / Re: Nethack 3.6.2
« on: March 18, 2020, 09:19:15 AM »
Should probably start a new topic, because this is about 3.6.6. release. Has anyone noticed that it seems to have a lot of problems in Windows console? It's acting really weird, sometimes scrolling the top text off the screen and it's slow (doesn't respond to keypresses fast). I wonder what happened. I guess they figure this out soon and release a fix, but this is quite special in Nethack's history.

Edit: I noticed that the console size was 120 x 9000 for whatever reason. I guess it's somehow updating the non-visible parts, because when manually changed it to 80 x 25 it seems like that problem was solved. Not sure which one is buggy, Nethack or Windows console.

18
Programming / Re: Programming in C#
« on: February 28, 2020, 07:24:27 AM »
The big difference between struct and class in C#, by the way, is that structs get allocated to the stack.

I actually knew that, the time of wonders is not over! That feature I believe was borrowed from D which has the same strange thing (value and reference types). I'm using mostly classes for that reason. I guess if you use a struct datatype as class member it gets allocated to heap as a whole object?

What do you mean Forms is easy to leak? C# is a garbage collected language, it can't leak. Right?

19
Programming / Re: Programming in C#
« on: February 26, 2020, 05:59:58 PM »
I'm wondering how to implement Level class here. Should it be a tile map of simple tiles with some kind of object id (or a list?) pointing to an object(s) in that tile? Or should terrain tiles be also objects? Maybe only walls and corridors could be actual objects and the empty spaces would be nulls.

20
Programming / Re: Programming in C#
« on: February 24, 2020, 01:24:12 PM »
The clipping -and- speed were somehow magically fixed by using something called BufferedGraphics class. I found this information totally randomly from the depths of internet. Also, when you set ClientSize (rather than Size) it properly sets the size of content, like this:

Code: [Select]
private void Form1_Load(object sender, EventArgs e)
{
Graphics g = CreateGraphics();
gui = new Gui(ref g);

//resize the form to match the size of virtual console
ClientSize = gui.GetPixelSize();
}

For drawing first I changed Gui class to use BufferedGraphics (this has only important parts of code):

Code: [Select]
Graphics g;
viewTile[,] console;
public BufferedGraphics graphicsBuffer;

public Gui(ref Graphics srcgrp)
{
graphicsBuffer = BufferedGraphicsManager.Current.Allocate
(srcgrp, new Rectangle(0, 0, viewGrid.Width * fontSize.Width, viewGrid.Height * fontSize.Height));

g = graphicsBuffer.Graphics;

Then in the OnPaint of form, use BufferedGraphics like this:

Code: [Select]
protected override void OnPaint(PaintEventArgs pe)
{
gui.Redraw();
gui.graphicsBuffer.Render(pe.Graphics);
}

At least it appears to be fast, but it might just look like it, because the whole buffer is flipped on screen rather than drawing each tile and showing it. Maybe the explanation is that when you draw a tile the whole window is updated which could explain why it's so slow.

21
Programming / Re: Programming in C#
« on: February 24, 2020, 10:03:00 AM »
Resizing the form manually seems to clip the output to original, but you can set the size in form designer. However, the sizes are off. When I set the size to 1280 x 600 the actual pixel size of the content is 1264 x 561 and even if you count in the borders the sizes don't match. Also, displaying 80x25 tiles of that window size is slow, you can't deny it. You can actually see it being drawn. I wonder what to do now.

22
Off-topic (Locked) / Re: Can I leave Finland?
« on: February 23, 2020, 12:27:16 PM »
Poland less warm than Spain but also mostly white - not sure about their jobs situation. Seems to be quite prolific in regards to gaming and roguelikes - you'll be able to meet Kornel Kisielewicz and other great devs if you move there.

Whee, I think it's hard to say anything about 'colored' or people can get wrong ideas. Actually could rephrase that Finland is taking in "bad" people, because that's what it is. Those people don't respect Finnish culture and I guess they don't plan becoming finnish, and even if they did it takes more than just wanting it. I wouldn't want to live in Poland I think, because it's very religious country if I'm correct. It's catholic which is even worse. I don't like Kornel as a person, I think he is too polish, just thinking about money all the time. In a weird way Poland is similar to Finland, the both people are smart but they find a way to ruin it for everyone.

23
Programming / Re: Programming in C#
« on: February 23, 2020, 08:32:11 AM »
The plant to imprint ascii into a bitmap was quite easy, although using C#'s internal Color values is bit strange, because DarkGray value is actually brighter than Gray, for some reason. I think I need to create my own set of colors.

Code: [Select]
public Gui(ref Graphics g)
{
//assign form's drawing surface for gui class
this.g = g;

const int amt = sizeof(Glyphs) - 1;

//tile data of glyphs
tiles = new Glyph[amt]
{
new Glyph ( ' ', Color.Black, Color.Black, "Darkness" ),
new Glyph ( '#', Color.Green, Color.DarkGray, "Wall" ),
new Glyph ( '.', Color.Gray, Color.Black, "Floor" )
};

//create glyph tiles source image
glyphs = new Bitmap(
fontSize.Width*fontGrid.Width,
fontSize.Height*fontGrid.Height);

Graphics bm = Graphics.FromImage(glyphs);
bm.Clear(Color.Blue);

Font fnt = new Font("Consolas", 16);
Point source = new Point(0, 0);
StringFormat drawFormat = new StringFormat();

for (int t=0; t<amt; t++)
{
//draw background slab
SolidBrush bgBrush = new SolidBrush(tiles[t].backgroundColor);
Rectangle rect = new Rectangle(source.X, source.Y, fontSize.Width, fontSize.Height);
bm.FillRectangle(bgBrush, rect);

//draw letter
string str = tiles[t].ascii.ToString();
SolidBrush letterBrush = new SolidBrush(tiles[t].color);

bm.DrawString(str, fnt, letterBrush, source.X, source.Y, drawFormat);

//move to next source location
source.X += fontSize.Width;
if (source.X>=glyphs.Width)
{
source.X = 0;
source.Y += fontSize.Height;
}
}

fnt.Dispose();
}

Two new observations I made were that enum isn't auto-converted into int even it's declared using int internal type. And also that even if you have a struct, you need to declare each variable 'public' if you want to use them outside the struct, even if the struct itself is declared public. I guess it makes sense, but it's a bit different from C++.

24
Programming / Programming in C#
« on: February 22, 2020, 03:52:26 PM »
I'm trying again something different and use C# which is relatively new and unknown language to me. This time (I'm sure I've done this before!) I'm trying to create a simple "engine" for a roguelike using graphics for ascii tiles. My plan is print the ascii chars to an image and then use that. I could have put this in my blog, but it's such a hassle for code examples. And maybe I can share something I've learned.

First "funny" thing when you start with a Forms project is that when you create an initialization routine for the form you -have- to double click the form in the designer window. It auto-creates Form1_Load method which is linked to the form. You can't just write it. The reason for that is unknown. But you can then override the OnPaint which is an event called when the window is repainted. It's I think the way to implement output from the event side of the form. So in code it looks like this:

Code: [Select]
private void Form1_Load(object sender, EventArgs e)
{
Graphics g = CreateGraphics();
gui = new Gui(ref g);
}

protected override void OnPaint(PaintEventArgs pe)
{
gui.Redraw();
}

You need "Graphics" to draw anything to a surface and in this case it's getting the surface from 'this' which is Form1 class (default name). Then I'm passing it as reference to Gui class which can use it to draw on the canvas of the form (another name for a window).

25
Programming / Re: My FOV Algorithm for Atari 2600 Game
« on: February 18, 2020, 11:11:50 AM »
That explanation is kind of vague, but if it works then it's quite clever! I have a faint recollection that this kind of routine has been discovered earlier.

26
Off-topic (Locked) / Can I leave Finland?
« on: February 14, 2020, 04:28:27 PM »
I'm wondering. Winters are long even they are getting hotter from climate change (which by the way can be clearly experienced in arctic regions). There are no jobs and Finland too is taking in colored people. If I went to somewhere like Spain at least it's warm, even if everything else would stay the same. I guess most countries are worse than Finland, but they can't be all bad?

27
Someone hacked Skeletor's account? I bet that link runs viruses. Don't click it.

28
Player's Plaza / Re: Ever felt weird playing a roguelike?
« on: February 02, 2020, 10:04:59 AM »
but really the existing roleplaying aspects are just flawed

The reason for this I think is that creating role-playing is hard. This is my experience when I've been developing both Teemu and Kaduria. In Teemu I'm almost desperately trying to create some kind of rpg system and in both projects it's certainly rpg system which is holding down the development pace. It's just difficult for whatever reason.

29
Programming / Re: Rogue Like Tutorial on Wikipedia
« on: January 31, 2020, 12:46:53 PM »
The easiest way is that you have IDE that comes with a compiler so you don't have to worry about makefiles etc. Code::Blocks is quite ok, but I would recommend Visual Studio Community (free version) if you are on Windows. Also, you should probably check Codelite's readme/manual/etc. to see how to compile and run a project from editor if it's possible.

30
Temple of the Roguelike / Re: The Temple is crumbling down...
« on: December 27, 2019, 02:39:12 PM »
Teemu, which was a pretty cute miniature crpg.

According to Berlin interpretation, Teemu has 7/9 of "high value factors" as roguelike which I find hilarious. In my opinion the current release version of Teemu is a roguelike-style adventure game. It doesn't yet have a RPG system (only very simple one).

Pages: 1 [2] 3 4 ... 154