Topic:   imagefile collide   (Read 31189 times)


0 Members and 2 Guests are viewing this topic.

GMG Kurt


  • GMG-er

  • **


  • Posts: 682

  • Sorry for being such a noob
imagefile collide
« on: March 09, 2011, 04:58:32 PM »
Some of you may know I've been making a remake of TRON.
IF you didn't, well now you know
I've finished the movement, and have hit a road block
yes thats right IMAGEFILE COLLIDE.
I need to find a way to detect if a sprite has hit an imagefile.
so far I tried this:

ON TIMER 20
 Â xco = x - 5
 Â xco = xco / 21
 Â prexco = prex - 5
 Â prexco = prexco / 21
 Â yco = y - 5
 Â yco = yco / 21
 Â preyco = prey - 5
 Â preyco = preyco / 21
 Â string$ = string$ + "( prexco , preyco )"
 Â IF string$ CONTAINS "( xco , yco )" THEN
 Â   ALERT oh dear your dead
 Â END IF
OFF TIMER

This doesn't seem to work, when I enter $string$$ it returns as ( prexco , preyco ) repeated over, and over again.
Please help me :'(
« Last Edit: March 09, 2011, 04:59:01 PM by KurtManion »
Just your average Weekend Warrior.
Yes I know I have bad spelling, it's what makes me such a good programmer!

"Old art, weather magnificent or wretched, is always the raw material of new art. The artist's job, though, is to

Zoo


  • GMG Extraordinaire

  • ***


  • Posts: 1686
    • My Bandcamp
Re: imagefile collide
« Reply #1 on: March 09, 2011, 08:20:12 PM »
I can't answer your question, but wasn't TRON some kind of an 80's Sci Fi movie? I'm confused.
Kirby, your pudgy buddy from dream land, is back again on the game boy®!

Charlo


  • GMG-er

  • **


  • Posts: 451
Re: imagefile collide
« Reply #2 on: March 10, 2011, 06:29:39 PM »
If I understand what you're trying to do, I think you have to use the str$ method to convert a numeric value to a string.  Right now, the way you're referencing the prexco/preyco variables, they're being treated as the literal strings "prexco" and "preyco".  

Al Staffieri


  • GMG-er

  • **

  • no avatar

  • Posts: 452

  • I love GameMaker
Re: imagefile collide
« Reply #3 on: March 10, 2011, 08:42:27 PM »
Can you put the IMAGEFILE as a sprite instead?

Al Staffieri


  • GMG-er

  • **

  • no avatar

  • Posts: 452

  • I love GameMaker
Re: imagefile collide
« Reply #4 on: March 11, 2011, 01:30:29 PM »
For GameMaker 3.9.95 I just added
bool = SPRITECOLLIDE spriteNum x1 y1 x2 y2

so you can check if a sprite collides with the rectangle area in x, y, x2, y2.

GMG Kurt


  • GMG-er

  • **


  • Posts: 682

  • Sorry for being such a noob
Re: imagefile collide
« Reply #5 on: March 12, 2011, 08:21:21 AM »
Quote
I can't answer your question, but wasn't TRON some kind of an 80's Sci Fi movie? I'm confused.
yes, it was also a very popular arcade style game, based on the movie.
If you want to try it out heres a link: http://www.fltron.com/
This is only one of the modes though, most people think that this the only mode, but those people are wrong. The original game had a tank mode, a disc throwing battle, and something about a plane type thing, I think. I've never played the actual version, I only know about the other versions from my dad.
« Last Edit: March 12, 2011, 08:35:49 AM by KurtManion »
Just your average Weekend Warrior.
Yes I know I have bad spelling, it's what makes me such a good programmer!

"Old art, weather magnificent or wretched, is always the raw material of new art. The artist's job, though, is to

GMG Kurt


  • GMG-er

  • **


  • Posts: 682

  • Sorry for being such a noob
Re: imagefile collide
« Reply #6 on: March 12, 2011, 08:24:53 AM »
Quote
Can you put the IMAGEFILE as a sprite instead?
No, I can't. every time the players sprite moves, it also places an imagefile behind him, so that it looks like the light cycle is leaving a trial, of light. Just like in the most famous TRON mode, where you have to box people in with your light cycle, so they hit your trail, and die. There are way over 8 Imagefiles, I can't do it with the current version of gamemaker, plus this seemed like a fine way I could recreate one of my favorite games, and try out this method.
« Last Edit: March 12, 2011, 08:26:51 AM by KurtManion »
Just your average Weekend Warrior.
Yes I know I have bad spelling, it's what makes me such a good programmer!

"Old art, weather magnificent or wretched, is always the raw material of new art. The artist's job, though, is to

GMG Kurt


  • GMG-er

  • **


  • Posts: 682

  • Sorry for being such a noob
Re: imagefile collide
« Reply #7 on: March 12, 2011, 08:31:00 AM »
Quote
If I understand what you're trying to do, I think you have to use the str$ method to convert a numeric value to a string.  Right now, the way you're referencing the prexco/preyco variables, they're being treated as the literal strings "prexco" and "preyco".  

yes exactly, I need a way for the prexco (previous X coordinate) and the preyco (previous Y coordinate) to be added into the string$ as the number it's currently representing. (which would be the coordinate of the imagefile)

Quote
If I understand what you're trying to do, I think you have to use the str$ method to convert a numeric value to a string.  Right now, the way you're referencing the prexco/preyco variables, they're being treated as the literal strings "prexco" and "preyco".  

So tried that like this:


 Â xco = x - 5
 Â xco = xco / 21
 Â xco$ = CHR$ xco
 Â prexco = prex - 5
 Â prexco = prexco / 21
 Â prexco$ = CHR$ prexco
 Â yco = y - 5
 Â yco = yco / 21
 Â yco$ = CHR$ yco
 Â preyco = prey - 5
 Â preyco = preyco / 21
 Â preyco$ = CHR$ preyco
 Â string$ = string$ + "( $prexco$$ , $preyco$$ )"
 Â IF string$ CONTAINS "( $xco$$ , $yco$$ )" THEN
 Â   ALERT oh dear you died
 Â   ALERT $string$$
 Â END IF
END TIMER

IT didn't work ( $prexco$$ , $preyco$$ ) was just repeated over, and over again, but I think your onto something. I'll keep experimenting with this, but I'm not sure if I'm adding to the string$ correctly, are you supposed to surround the variable in '$' marks?
« Last Edit: March 12, 2011, 09:09:47 AM by KurtManion »
Just your average Weekend Warrior.
Yes I know I have bad spelling, it's what makes me such a good programmer!

"Old art, weather magnificent or wretched, is always the raw material of new art. The artist's job, though, is to

GMG Kurt


  • GMG-er

  • **


  • Posts: 682

  • Sorry for being such a noob
Re: imagefile collide
« Reply #8 on: March 20, 2011, 10:29:00 AM »
I re-worked the code, and found
the problem is in the CHR$ variable,
so heres my code, remember that everything here is in TIMER 20, along with other irrelevant code, but I'm only showing you the relevant code:

LET
x = x value on the grid
y = y value on the grid
xco = x-coordinate (a smaller x value which is easier to understand
yco = y-coordinate as the latter
prex = x-value before the last keydown
prey = y-value before the last keydown
precos = prex, and prey coordinates in the form: (prex,prey)
aftcos = xco, and yco in the same form as above

TIMER 20
 Â xco = x - 5
 Â xco = xco / 21
 Â xco$ = CHR$ "xco"
 Â prexco = prex - 5
 Â prexco = prexco / 21
 Â prexco$ = CHR$ "prexco"
 Â yco = y - 5
 Â yco = yco / 21
 Â yco$ = CHR$ "yco"
 Â preyco = prey - 5
 Â preyco = preyco / 21
 Â preyco$ = CHR$ "preyco"
 Â precos$ = "("
 Â precos$ = precos$ + "$prexco$$"
 Â precos$ = precos$ + ","
 Â precos$ = precos$ + "$preyco$$"
 Â precos$ = precos$ + ")"
 Â aftcos$ = "("
 Â aftcos$ = aftcos$ + "$xco$$"
 Â aftcos$ = aftcos$ + ","
 Â aftcos$ = aftcos$ + "$yco$$"
 Â aftcos$ = aftcos$ + ")"
 Â string$ = string$ + $precos$$
 Â IF string$ CONTAINS $aftcos$$ THEN
 Â   ALERT oh dear you died
 Â   ALERT $string$$
 Â END IF
END TIMER
« Last Edit: March 20, 2011, 10:30:12 AM by KurtManion »
Just your average Weekend Warrior.
Yes I know I have bad spelling, it's what makes me such a good programmer!

"Old art, weather magnificent or wretched, is always the raw material of new art. The artist's job, though, is to

Connors


  • ^ This guy is amazing.

  • ****


  • Posts: 2374

  • It's a secret to everyone...
Re: imagefile collide
« Reply #9 on: March 20, 2011, 11:52:30 AM »
So what is this code doing exactly? (I'm curious because I made a TRON game in TNT). How does it draw the lines?
Warning: The above post may have been modified multiple times.

"In a great game, the character must never perfectly obey the user's command"
 - Tim Rogers

http://connorspuzzles.tumblr.com/

GMG Kurt


  • GMG-er

  • **


  • Posts: 682

  • Sorry for being such a noob
Re: imagefile collide
« Reply #10 on: March 20, 2011, 01:50:44 PM »
it's kind of hard to explain, the lines are drawn with imagefile, while the box that says 'use IMAGEFILE as an overlay' is selected. The computer finds out how to draw them with the previous keydown, and the current keydown.

The code I selected in the previouse reply controls the variables to log places the cycle has been, and whether it is currently on them. It's the code thats been giving me problems.

here's what I have so far. Its not done. I test codes in card 3, and card 4 has the actual game, and all the stuff we've talked about here.
http://www.mediafire.com/?v6yqwtf9eczyx

The code to draw the lines, is in the KEYDOWN block
« Last Edit: March 20, 2011, 01:56:46 PM by KurtManion »
Just your average Weekend Warrior.
Yes I know I have bad spelling, it's what makes me such a good programmer!

"Old art, weather magnificent or wretched, is always the raw material of new art. The artist's job, though, is to

GMG Kurt


  • GMG-er

  • **


  • Posts: 682

  • Sorry for being such a noob
Re: imagefile collide
« Reply #11 on: March 22, 2011, 03:46:59 PM »
I still have no clue how to correctly use the CHR$ command. Can someone please give me a syntax example?
Just your average Weekend Warrior.
Yes I know I have bad spelling, it's what makes me such a good programmer!

"Old art, weather magnificent or wretched, is always the raw material of new art. The artist's job, though, is to

Al Staffieri


  • GMG-er

  • **

  • no avatar

  • Posts: 452

  • I love GameMaker
Re: imagefile collide
« Reply #12 on: March 22, 2011, 06:30:56 PM »
Quote
I still have no clue how to correctly use the CHR$ command. Can someone please give me a syntax example?

Leave out the quotes. You have:
preyco$ = CHR$ "preyco"

It should be:
preyco$ = CHR$ preyco

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: imagefile collide
« Reply #13 on: March 22, 2011, 06:31:09 PM »
Code: [Select]
var1 = 50
var2$ = CHR$ var1

var2$ will now have a value of "50".
I survived the spammage of 2007

GMG Kurt


  • GMG-er

  • **


  • Posts: 682

  • Sorry for being such a noob
Re: imagefile collide
« Reply #14 on: March 27, 2011, 04:36:25 PM »
Quote
Code: [Select]
var1 = 50
var2$ = CHR$ var1

var2$ will now have a value of "50".

When I tried this, plus a line that said: ALERT $var2$$
the alert box that came up said that var2$ was '2' so I tried it with another number. when I replaced 50 with a value of 100, and var2$ returned as 'd'  .
« Last Edit: March 27, 2011, 04:38:29 PM by KurtManion »
Just your average Weekend Warrior.
Yes I know I have bad spelling, it's what makes me such a good programmer!

"Old art, weather magnificent or wretched, is always the raw material of new art. The artist's job, though, is to