Menu

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.

Show posts Menu

Topics - KamikazeHighland

#1
I wrote a program to multiply or add any two numbers where neither is negative or has a decimal.  It's the equivalent of pen and paper arithmetic, so it's slow but at GameSpeed 40 it can multiply two 155 digit numbers 100 times in under a minute and is never wrong.

I don't -really- need to use numbers beyond maybe 20 digits each or do it very often, my only concern is that when I script to multiply or add two numbers the answer is never wrong.  Normally ints will be wrong beyond â€"2,147,483,648 to 2,147,483,647 and I cannot trust floats.  I don't need to use negative numbers or decimals at this point.

I've come up with better ways to multiply, subtract and divide, but I'm stuck on addition because carrying is slow and I can't find many resources on how to do that quicker.

I'm mostly just looking for tips or hints at this point.  Maybe someone's already had to do this and come up with ways how?
#2
This works fine:

float float1 = 3.75;
float float2 = 0.25;

Even FloatToInt(float1, eRoundNearest)


This, however:

if (3.0 >= float1 >= 2.0 && 3.0 >= float2 >= 2.0){
}

Type mismatch: cannot convert 'int' to 'float'

What am I not seeing?
#3
I'm wondering if anyone's ever had to arrange ints, floats or strings in numerical, alphabetical or alphanumerical order?  And if so how did you do it?

Not the names of the variables but the actual values.

Edit:  I see how to do it with strings using CompareTo.  Any hints or tips are appreciated.
#4
There've been a few topics on this, but I'd like any new information anyone might have.  This is the code that works fine:

struct Example {
 int PropertyAofSubstruct[256];
 int PropertyBofSubstruct[256];
 int PropertyCofSubstruct[256];
 float Property1ofSubstruct[2560];
 float Property2ofSubstruct[2560];
 float Property3ofSubstruct[2560];
 float Property4ofSubstruct[2560];
 float Property5ofSubstruct[2560];
 float Property6ofSubstruct[2560];
 float Property7ofSubstruct[2560];
 int PropertyDofSubstruct[256];
 int PropertyEofSubstruct[256];
 int PropertyFofSubstruct[256];
 float Property8ofSubstruct[2560];
 float Property9ofSubstruct[2560];
 float Property10ofSubstruct[2560];
 float Property11ofSubstruct[2560];
 float Property12ofSubstruct[2560];
 float Property13ofSubstruct[2560];
 float Property14ofSubstruct[2560];
 int PropertyA[256];
 int PropertyB[256];
 float PropertyI;
 float PropertyII;
 float PropertyIII;
 };
Example examples[256];

If I make either of two changes:

Replacing each [256] with [2560] or replacing the number of instances of the struct:
Example examples[2560];

I get this, which many have probably encountered:
Error: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Version: AGS 3.2.1.111

Or if I have just enough room I can store a few floats before the running program crashes saying the error is in the line it stopped writing.

The only reason I started a new thread is because it's been said there should be no limit so I'm a little confused on that.  I was able to bump the limits up once I deleted some pictures.  I realize I could settle for less but what's the problem?
#5
Is there a way or method to round floating point values without converting them to integers?  Other than by doing this:

IntToFloat(FloatToInt(var1, eRoundUp))

Unless this isn't inefficient, or if it's the most efficient way.  This is rounding the float value and then using it again in a function.
#6
I don't understand how text files to store stats.  I'd open the file, append it and WriteInt with a new stat, then save it.  But how would I read from it?

All the numbers would be in order (i.e. 56, 78, 43, 97, etc...), but how would I then write a script that says something like: stringStat = value at line 7, or so?

How do I store information in sequence and then read it back based on it's position or line number?  I.e. Line 1 = 56, Line 2 = 78, Line 3 = 43, etc...

Or, if all the information was saved in sequence, how could I convert the text file into something AGS could read in order?

EDIT:
I guess, for now, I could save all the information as one long appended string and truncate it accordingly.  It'd be nice to use outside files, though.
#7
AGS cannot detect a color's RGB or draw in every color, so I wrote a script that allows you to draw with any color, including blue 0-32 and magenta 255,0,255.

You'll need to download a large picture that has every possible color on it.  This increases the size of an otherwise empty game to about 78mb, and might be slow (I haven't tried it on other computers), but no drawing game can be complete if any colors aren't allowed.

You will need the following picture.  I haven't used this as I've made my own, so reply if this one somehow doesn't work as I've described.
http://thomasinterestingblog.files.wordpress.com/2011/06/fullrgbcompressed.png


All that's required to make this script work is this picture, a trigger (hotspot or GUI), three sliders (min = 0, max = 255) or perhaps a prompt, and a sprite with a pixel of transparency.  This transparency goes on top of otherwise transparent magenta and cancels it out, allowing the game to display true magenta.

DynamicSprite* sprite is the large picture.  CopyTransparencyMask is for the picture with one pixel of transparency (when testing I used an alpha channel and NOT transparent magenta).

You'll probably also want to change the sprite.resize from 1024x768.  Reply if you have any questions:
Code: ags

function Sixteen()
{
  Red = Red - 16;
  Row = Row + 1;
}

function ColorPrompt()
{
  Red = SliderRed.Value;
  Green = SliderGreen.Value;
  Blue = SliderBlue.Value;
  while (Red > 15) {
    Sixteen();
  }
  Column = Red;
  RGBX = (Column * 256) + Green;
  RGBY = (Row * 256) + Blue;
  DynamicSprite* sprite = DynamicSprite.CreateFromExistingSprite(9);
  sprite.Crop(RGBX, RGBY, 1, 1);
  sprite.Resize(1024, 768);
  sprite.CopyTransparencyMask(10);
DrawingSurface *surface = Room.GetDrawingSurfaceForBackground();
surface.DrawImage(0, 0, sprite.Graphic);
surface.Release();
sprite.Delete();
Display("Color is in Row %d, Column %d.  RGBX is %d, RGBY is %d", Row, Column, RGBX, RGBY);
Row = 0;
Column = 0;
}
#8
I have a while script that, for now, I have running before the fade-in, just so the player knows something's happening.  It's something that loads in the room that takes ten seconds to load.  My question is:  Does everything need to stop while something else is loading?

Pretty much any while script makes everything stop, even the clock I put in the corner.  Other games will have stuff loading while you're playing.  Is there something I can do?
#9
float Value = int1 * (3/4);  returns cannot convert 'int' to 'float'.

float int1float = IntToFloat(int1);
float Value = int1float * (3/4); returns cannot convert 'float' to 'int'.

float float1 = 1
float Value = float1 * (3/4); returns cannot convert 'float' to 'int'.

Using (.75) returns Parse error in expr near "."

All I want is for a number with a decimal.  What am I doing wrong?
#10
Game.GetColorFromRGB(255, 0, 0); is Red, Game.GetColorFromRGB(0, 255, 0); is Green.  Game.GetColorFromRGB(0, 0, 255); is... light grey...?

Game.GetColorFromRGB(0, 0, 100); is some sort of red.
#11
Hi.  In AGS I can draw lines between points, but I'd also like to be able to flood fill the areas between those lines, if possible.  It's odd that I can't find this, since the room editor has this feature...  ::)

Mostly because I can't /skew/ a rectangle in-game... unless I can?
#12
Mostly solved.  I just need to make an on / off button.  :-\

0 to 1 and back to 0 each time the button is pressed.  I tried [if (var1 = 0) var1 = 1;] and vice versa but nothing happened.
#13
What I want is for an npc character to walk around a square, but not just walking the same loop over and over.  My idea is that each time it hits a corner, it'll randomly decide where to go from there.

My corners are at A. 80,80 (NW) B. 200,80 (NE) C. 80,200 (SW) and D. 200,200 (SE).  So lets say it starts at point A.  Let's say each is true of the points.

A. 100% chance of walking to B.
B. 25% chance of walking back to A, 75% chance of walking to D.
D. 75% chance of walking to C, 25% chance of walking to B.
And C. 25% chance of walking straight to A, and a 75% chance of waiting 5 seconds first. ::)


I know I could make it completely random, but I've played Tale of Two Kingdoms and I don't want my npcs going all over.  Besides, I'd like to do other things with percent/fractional odds, and I don't know how to do a rand statement when the odds are 1:4.

Think you can help me? 8)
SMF spam blocked by CleanTalk