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

Messages - suicidal pencil

#101
I'm not familiar with the old SNES 'passing-out' idea. I thought it was about the character falling over :P
#102
I do not think you are using the Maths.Sin() function correctly. I think a quadratic function would serve your purposes better than a trigonometric function.

so, instead of using f(x) = sin(x), a better equation for this might be f(x) = -x^y, because the motion of someone passing out better represents a parabola, then a sine wave.
#103
That is actually very easy. the frequency of sin θ can simply be changed by writing it as sin xθ, where x is the magnitude of change. x = 2 doubles the frequency, and x = 0.5 halves it.

So, what are you actually trying to accomplish with it?

edit: To see this for yourself, go the the link provided by Khris (thanks, Khris. That's a really helpful little tool.) and type in: sin(x), then sin(2*x), then sin(0.5*x). Here's what you get:



#104
Quote from: Ghost on Wed 16/12/2009 04:39:49
I bet there is a more elegant way to script the whole thing...

a Ternary Operator and a quick function call would do it...if AGS supported them.

However, DoOnlyOnce() is perfect :)
#105
Quote from: NsMn on Tue 01/12/2009 05:47:11
Are sure it's that easy pencil? Don't you usually have animations?  ;)

the question was: "Is it possible to make a game with the AGS editor where the player character's movement can be directly controlled, i.e. by keyboard..."

I think I answered it  :P
#106
I'm not 100% sure about what you're asking about glass.

And, you can make a mirror for characters, but I don't think it would be easy. You'd need to draw the mirror, and what it's reflecting in the background image. Then at run-time, create a drawing surface, and draw the player's current graphic on to it, wherever his reflection may be.
#107
Quote from: Khris on Mon 30/11/2009 23:21:36
A jump-n-run would require pretty extensive gravity, movement and collision code, for example.

Very true. Coding in physics is hard work, and can easily break your game if you did anything wrong.

Anyways, to code in movement by keyboard, just put this in the repeatedly execute function:

Code: ags

if(IsKeyPressed(eKeyUpArrow))
{
  player.y -= 5;
}

if(IsKeyPressed(eKeyDownArrow))
{
  player.y += 5
}

if(IsKeyPressed(eKeyLeftArrow))
{
  player.x -= 5;
}

if(IsKeyPressed(eKeyRightArrow))
{
  player.x += 5;
}


you can substitute the number 5 for anything, depending on how fast you want your character to move. (EG. moving at 5 pixels per frame, at a resolution of 640x480, it would take 128 frames (or 3.2 seconds at 40 fps) to move from the top of the screen to the bottom, and 96 frames (2.4 seconds at 40 fps) to move from one side to the other.)
#108
Quote from: Lyaer on Sat 28/11/2009 08:30:40
You could do an infinite while loop, though it'll lock up before crashing, which might be annoying.  Or is that the same as a stack overflow?

No. A stack overflow is when too much memory is used in the call stack.

Like so:
Code: ags

function sub1()
{
  sub1();
}


Calling that function will result in an infinite recursion loop, and a Stack Overflow.
#109
Quote from: Calin Leafshade on Thu 26/11/2009 18:58:27
The above code will make time move 40 times faster (or what ever the game speed)

Remember that rep_ex runs every game loop, not every second.

updated :)
#111
Quote from: Rocco on Sat 21/11/2009 19:42:10
Maybe someday developers with more physic and math knowledge can enhaunce the module.

challenge accepted!

I'd gladly write the physics in for you.
#112
yes, programing is required. You'd need to keep track of the seconds in time with a variable, and figure out how many minutes (if it takes that long)

Code: ags

int Loops = 0;
int Seconds = 0;
int Minutes = 0;

function repeatedly_execute()
{
  Loops++
  if(Loops == 40) Seconds++;
  Change_Time(Seconds);
}

Change_Time(int time)
{
  if(time == 60)
  {
     Minutes++;
     Second = 0;
     Label1.Text = String.Format("%d:00", Minutes);
     return 0;
  }
  else
  {
     Label1.Text = String.Format("%d:%d", Minutes, Seconds);
     return 0;
  }
}
#113
Quote from: Khris on Mon 23/11/2009 19:35:05
...why go through all the trouble of downloading/adding the module and using it when all is needed are a simple GUI and a few lines of code?

Because it's apparently easier to take five minutes searching and downloading a module you'll only use once, so that you don't need to build a quick GUI, and write a few lines of code

NsMn, do you not like GUIs?Blasphemy!...and you shouldn't attempt to call out someone who probably has much more coding and programming experience, since they might actually know more than you.
#114
I think that having the 'for' and 'foreach' loops in AGS would help with scripting.

The 'for' loop is good for having a counter attached to a loop. In AGS, it would look like this:
Code: ags

int counter = 0;
while(counter <= 100)
{
  //do stuff
  .
  .
  .
  counter++;
}


Now, the same stuff, but in a 'for' loop instead:

Code: ags

for(int counter = 0; counter <= 100; counter++)
{
  //do stuff
  .
  .
  .
}


I find that much easier to deal with, rather than the while loop.

The 'foreach' loop is much like the 'for' loop, except that it iterates through all of the elements in an array (It would be a good way to find the size of your dynamic array, monkey)

As above, so below: here's the same thing in AGS (in AGS, this works only if you already know the length)
Code: ags

int counter = 0
while(counter <= 23)
{
  array[counter] += 5;
}


Now with 'foreach'

Code: ags

foreach int counter(array)
{
  counter += 5
}


the 'int counter' in the foreach loop is what the value of the current element of (array) is.

Thoughts? (I feel as if I wrote a tutorial...)
#115
Advanced Technical Forum / Re: I broke AGS...
Sun 15/11/2009 07:56:45
Quote from: wonkyth on Sun 15/11/2009 06:46:54
Well, an integer can only be so big, and if the player was accelerating then it wouldn't take long to reach the limit.

yes, but the acceleration was limited. I did a data test using my native language (Perl), using the same values as in my script, and got the following results (because the ending number was the amount of pixels to move, I totaled it as well):
Code: ags

code:

#!/usr/bin/perl -w
use strict;

my $acc = 0;
my $stv = 0;
my @total;
open FILE, ">>", "data.txt" || die $!;
for(my $counter = 1; $counter <= 26; $counter++)
{
	my $fv = ($acc*1)+$stv;
	push(@total, $fv);
	my $total_pixels = 0;
	foreach my $element(@total)
	{
		$total_pixels += $element;
	}
	print FILE "Loop $counter: $fv Total: $total_pixels pixels\n";
	$stv = $fv;
	$acc >= 3 ? print "" : $acc++;
}
close(FILE);


output:

Loop 1: 0 Total: 0 pixels
Loop 2: 1 Total: 1 pixels
Loop 3: 3 Total: 4 pixels
Loop 4: 6 Total: 10 pixels
Loop 5: 9 Total: 19 pixels
Loop 6: 12 Total: 31 pixels
Loop 7: 15 Total: 46 pixels
Loop 8: 18 Total: 64 pixels
Loop 9: 21 Total: 85 pixels
Loop 10: 24 Total: 109 pixels
Loop 11: 27 Total: 136 pixels
Loop 12: 30 Total: 166 pixels
Loop 13: 33 Total: 199 pixels
Loop 14: 36 Total: 235 pixels
Loop 15: 39 Total: 274 pixels
Loop 16: 42 Total: 316 pixels
Loop 17: 45 Total: 361 pixels
Loop 18: 48 Total: 409 pixels
Loop 19: 51 Total: 460 pixels
Loop 20: 54 Total: 514 pixels
Loop 21: 57 Total: 571 pixels
Loop 22: 60 Total: 631 pixels
Loop 23: 63 Total: 694 pixels
Loop 24: 66 Total: 760 pixels
Loop 25: 69 Total: 829 pixels
Loop 26: 72 Total: 901 pixels


Resolution is 640 x 400, and the integer goes over 640 at loop 23, but I've used locations outside resolution before without a problem.  

edit: Figured it out. The limit on player.y is 32767 (being a signed int), and that happy little script of mine exceeds that limit at loop 150:

Code: ags

Loop 1: 0 Total: 0 pixels
Loop 2: 1 Total: 1 pixels
Loop 3: 3 Total: 4 pixels
Loop 4: 6 Total: 10 pixels
Loop 5: 9 Total: 19 pixels
.
.
.
Loop 145: 429 Total: 30889 pixels
Loop 146: 432 Total: 31321 pixels
Loop 147: 435 Total: 31756 pixels
Loop 148: 438 Total: 32194 pixels
Loop 149: 441 Total: 32635 pixels
Loop 150: 444 Total: 33079 pixels


At a speed of 40 loops per second, then it would take 3.75 seconds to hit that limit. :-\ It's worse if acceleration was unbounded: it would take 59 loops, or 1.475 seconds to hit the limit  :-[
#116
Quote from: RickJ on Sun 15/11/2009 02:31:31
Here is a module that does what you want...

There's always a module of what you want. If you cant find it, you're not looking hard enough

edit: That link is broken. Very, very, broken.

edit2: http://demo.agspace.ws/project/archive/GamePlayTimer-M0101-000.zip
#117
Advanced Technical Forum / I broke AGS...
Sun 15/11/2009 06:07:54
---------------------------
Illegal exception
---------------------------
An exception 0xC0000005 occurred in ACWIN.EXE at EIP = 0x00506B3B ; program pointer is +5, ACI version 3.12.1074, gtags (0,50)

AGS cannot continue, this exception was fatal. Please note down the numbers above, remember what you were doing at the time and post the details on the AGS Technical Forum.



Most versions of Windows allow you to press Ctrl+C now to copy this entire message to the clipboard for easy reporting.

An error file CrashInfo.dmp has been created. You may be asked to upload this file when reporting this problem on the AGS Forums. (code 0)
---------------------------
OK  
---------------------------

Here's what happened: I have a function that accelerates the player downwards, and is eventually stopped when they hit the ground.

Code: ags

function Downward_acceleration(int Acceleration, int StartingVelocity)
{
  //a = (v2-v1)\t 
  //Acceleration equals Final Velocity minus Initial Velocity over Time
  //v2 = at+v1
  //Final Velocity equals Acceleration multiplied by Time plus initial velocity
  int FinalVelocity = (Acceleration*1)+StartingVelocity;
  return FinalVelocity;
}
.
.
.
function repeatedly_execute() 
{
  if(Ground_collision == false)
  {
    player.y += Downward_acceleration(YA, YV1);
    YV1 += Downward_acceleration(YA, YV1);
    if(YA <= 3) YA++;
  }
}


Only, when I tested it, I had accidentally put '-=' instead of '+=' in the line 'player.y += Downward_acceleration(YA, YV1);'. So instead of traveling downwards, where the player would have stopped, the player launched into the sky, and eventually produced the error above

thoughts?
#118
Quote from: Victor6 on Sat 14/11/2009 20:09:17
I believe AGS doesn't support 2d arrays, but you probably can use multiple arrays to simulate the same effect.

you can cheat using struct
Quote from: Khris on Sat 24/10/2009 10:40:04
Code: ags
// header

struct str_x {
  int y[100];
};

// script

str_x x[100];

// now one can do:
  x[40].y[20] = 3;

#119
You'd have to script it in yourself.

Code: ags

function repeatedly_execute() 
{
  Loops++; //Global Variable
  if(Loops >= 40)
  {
    Seconds++; //Global Variable
  }
}

function TellTime()
{
  while(Seconds >= 60)
  {
    Minutes++;
  }
  while(Minutes >= 60)
  {
    Hours++;
  }
  while(Hours >= 24)
  {
    Days++;
  }
}


For save games without closing the game in between, this would do. But if the game is closed over save games, you'd need to get the computer time from before it's closed, then when it's played again, and then compare the numbers.
#120
You basically described the problems I ran into (and worked around) when I made this (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=39156.0).

I solved the problem by limiting the bullet to using one object only, and making sure that the object is not in use when the player is not firing again.

Code: ags

//Assume that Object 39 is reserved as a bullet
function shoot_bullet()
{
  if(object[39].Graphic == 0)
  {
    object[39].Graphic == 1; //sprite no.1 is the bullet (1x1 transparency)
  }
  else
  {
    //do nothing
  }
}


You can use objects to do what you need, just make sure that the script will ever hit the limit
SMF spam blocked by CleanTalk