Jump to content


EXPScoreBoy

Member Since 30 Nov 2009
Offline Last Active Aug 24 2012 05:59 PM

Topics I've Started

File Editing Error

19 August 2012 - 03:45 AM

Hi, this might be a dumb question, but I am having problems with a certain piece of code and I cannot figure out how to fix it. In fact, I think it might be a problem with the current version of GameMaker itself.

So, here's a run-down of what's going on:

I'm trying to make a program as sort of a random cryptogram decoder. At this point it is very unspecific and does not work very well, but I have come to a particular bump in the road.

On pressing the Enter key the program will write 26 different "options" (which are individual strings) to a specific file. This seems to work without error.

However, on pressing the space key, the program is to copy each "option" in the file to a particular array of a variable, generate 26 more, non-matching options, and add them to the text file.

When I press the Enter key, enter my text to encode/decode, and then press the space key, an error message stating that, in the <Space> Key Pressed event for object1, the file is not open for reading. It does not give a particular line of code where the error occurs, it just states exactly that. Then, when I click Abort, the game crashes instead of closing and returning to the game editor.

Here's the code for the Space Key Pressed event, and sorry about my bad, confusing scripting habits. I tend to use single letters often:

file0=file_text_open_read("words.gmdc");
h=0;
do
{
   fs[g]=file_text_read_string(file0);
   file_text_readln(file0);
   h+=1;
}
until file_text_eof(file0)=true
file_text_close(file0);//Program adds the words in the text file into its currently running instance

file1=file_text_open_append("words.gmdc");

ii=0;
for (ii=0; ii=26; if permis=true ii+=1)//I do not even know if I can do that "if permis=true" thing 
{
   permis=false;//Code set to not allow another iteration
   code1="abcdefghijklmnopqrstuvwxyz";//Used to compare scrambled letter sequence to
   code2="abcdefghijklmnopqrstuvwxyz";//Used to scramble letter sequence
   letter[0]="";
   i=0;
   repeat(26) {
      foo=irandom_range(1,26-i);
      letter[i]=string_char_at(code2,foo);
      code2=string_delete(code2,foo,1);
      i+=1;
   }//Scrambles each letter into an array (There was probably an easier way to do this. Oh well.)
   
   i=0;
   code3="";
   repeat(26) {
      code3=code3+letter[i];
      i+=1;
   }//Puts scrambled letters into one string

   i=0;
   repeat(len) {
      if string_letters(string_copy(str,i+1,1))="" 
         ch[i]=string_copy(str,i+1,1);
      else
         ch[i]=string_copy(code3,string_pos(string_copy(str,i+1,1),code1),1);
      i+=1;
   }//Replaces each letter in the string which the user provided with the corresponding letter in the jumbled sequence

   i=0;
   str2[ii]="";
   repeat(len) {
      str2[ii]=str2[ii]+ch[i];
      i+=1;
   }//Puts the new letters together into one string

   l=0;
   j=0;
   repeat(g) {
      if str2[ii]!=fs[l]
         j+=1;
   }//Checks to see if the new string matches any of the old ones

   if j=0
      break;//Makes sure there are still options
   
   if j=g {
      permis=true;
      file_text_write_string(file1,str2[ii]);
      g+=1;
   }//If the string is new, it should add it to the file and allow the loop to iterate
}

file_text_close(file1)

It would be very helpful if somebody could tell me what is wrong with this script for what I am trying to do, or at least confirm that this is a bug in GameMaker. I can provide more source code from the other events if necessary. Thanks!

Math Help

04 May 2012 - 08:53 PM

Hello. I'm not good at starting topics, so I'll cut to the chase

In a game I'm making I want to use a script to make an object (at any point in the room) point towards the mouse and be able to shoot lasers in that direction.

A lot of the game is going to be based on this formula so I cannot use any scripts that directly tell the object to point to the mouse, but I want to use arc degrees of a circle to find where it should be pointing.

This is the script I have so far:

a=distance_to_point(mouse_x,mouse_y) //finds the distance to the mouse
c=sqrt(sqr(a)-sqr(x-x))+y //finds the y value the top point of a vertical line with the bottom end point being the object and the distance the same as the distance to the mouse
b=sqrt(sqr(x-mouse_x)+sqr(c-mouse_y)) //finds the distance between the mouse and the y value from the above line
d=round(radtodeg(arccos((sqr(a)-(2*sqr(b)))/(-2*sqr(b))))) //finds the arc degrees of that triangle (as if it were part of a circle)
image_index=d //sets the image index (out of 360)

The object is pointing up at image index 0

I am pretty sure that one of the problems is that the y axis on this coordinate plane is inverse to the one I would be using, but I do not know how to fix that.

If someone can please correct my math and help me make this work I would be really grateful.

Thanks,
EXPScoreBoy

Platform Collision Death Problem

07 July 2010 - 12:10 PM

Hello, I am trying to make a platform game and I want the character to die when it hits a block. I tried doing it as a regular collision death but it will only kill the character if he is falling from above. The character could walk over it as if its a regular brick or walk right into it the same way, no death. This is the code I tried using:

Under the Collision Event
x=xstart; y=ystart

Or in other words, the jump to start action.

I have GM 8 Pro so any help should work. I recently began using code and I often refer to The Ultimate DnD to GML Converter if I don't know something, or I use the GM help file.

If anyone could tell me how I can make it so that no matter how the character hits or touches the block it will die.

Thank you for reading and I hope you will have some advice.

I have solved the problem. Look at my post below to see the solution (my last post).

The Command Code Project

03 July 2010 - 05:58 PM

Command Code

I need help on a big project. The game is called Command Code. Before you read further it is recommended you click on the following link to play the game.

Command Code

Command code is a game about entering in codes and watching the results. I have inserted about 40 "command codes" by now ("command codes" hence the name Command Code). Only 10 are initially given, though. By now you may be wondering "How am I supposed to get the full effect of the game if I don't even know all the codes?"

I will give you 2 answers:

1. That's the fun of it. I want people to try to figure out command codes on their own. Then they can share with friends and other YoYo users the codes they've found. Finding codes should not be a problem since my overall goal is 2000 command codes (now you see why I need collaborators XD).
2. Once finished, I will post daily (or weekly) codes on my website, www.expscoreboy.com, where you can cumulatively collect command codes.

For this game I can have collaborators in the following ways:

*text documents containing scripts
*text documents containing ideas
*a downloaded and reposted version of the game with updates
*any variations of the above (e.g. PMing me an idea)

This game really has no specific type so I would say it's other.
It is 381 kilobytes and was made with GM 8 Pro (scripted).
I'm pretty sure its Vista compatible and it doesn't do anything to the screen resolution.

Here are some screenshots:

Posted Image
Game Screen

Posted Image
Custom Snow Effect

Posted Image
Title Screen

Posted Image
Game-play Image 1

Posted Image
Game-play Image 2

I need all the help I can get, and if you do help. Thank you for the support.

Favorite Kirby Game

18 December 2009 - 08:40 PM

Hello. I would just like to hear what people have to say about kirby games. They can be from anywhere, the sky's the limit.

You may tell about your favorite Kirby game, a reccomended kirby game, or just kirby in general.

Kirby, kirby, kirby. That's all there is.

So post about kirby all you want right here.