Game Maker's Garage Forum

Game Creation => SilverCreator => Topic started by: Connors on February 25, 2010, 06:08:53 PM

Title: More Questions
Post by: Connors on February 25, 2010, 06:08:53 PM
Well, I tried to find it myself, but I still don't know exactly how to do collision checks in SC.
Can I get some help?? ???
Title: Re: Collision
Post by: Xiphos on February 25, 2010, 06:56:41 PM
Code: [Select]
IF spritestouching(1,2) = true THEN

or something along those lines, btw I'm my iPod so forgive my mistakes!
Title: Re: Collision
Post by: Connors on February 25, 2010, 07:08:45 PM
Yes, actually i found that in the Mario example game after I posted this. It has good examples. (my bad! -_-). Of course, I can still use this post for ANOTHER question - isn't there some code that outputs the x or y of a specific sprite? (not just for collision purposes)
Title: Re: Various Questions
Post by: EqwanoX on February 25, 2010, 07:49:32 PM
spritex(spritenumber), spritey(number)

theres also IF spritetouchingxy(sprite, x, y)= true THEN, to see if a sprite is colliding with a specific coordinate
Title: Re: Various Questions
Post by: Connors on February 25, 2010, 08:00:48 PM
ok, thanks again! ;D I think I will be able to post a build of this game pretty soon now. There's a few more things I need to review but I think it's all in recent posts.
Title: Re: Various Questions
Post by: Connors on February 26, 2010, 09:16:33 PM
HEY i got a question - what code can you put into the "Mouse Move" area??
Can you control stuff with the mouse? that would be cool
Title: Re: Various Questions
Post by: Xiphos on February 26, 2010, 09:45:23 PM
The code is executed when the mouse changes x or y position.
Title: Re: Various Questions
Post by: Silverwind on February 27, 2010, 02:28:17 AM
You could create the illusion of controlling the mouse by simultaneously hiding the curser and drawing a sprite that looks like it.
Title: Re: Various Questions
Post by: WarHampster on February 27, 2010, 10:24:17 AM
Can SC hide the mouse cursor yet?
Title: Re: Various Questions
Post by: Connors on February 27, 2010, 07:00:47 PM
Quote
You could create the illusion of controlling the mouse by simultaneously hiding the curser and drawing a sprite that looks like it.
Or you could see if things collide with the point mousex, mousey

BTW, I can't find out how to make SC respond to the spacebar or letters.
I tried IF key$ = space$.
Title: Re: Various Questions
Post by: Connors on March 02, 2010, 06:52:13 PM
I got a good question - I'm trying to find a good way to add a lot of sprites continuously without repeating the same sprite number. It's mainly to have enemies or shots enter the screen on command without causing a glitch. I'm gonna try a few things myself but I'm sure there's more than one way.
Title: Re: Various Questions
Post by: Connors on March 02, 2010, 07:25:53 PM
Quote
try this, basically if the sprite doesnt exist it creates it
 
for x=1 to enemies
if spritevalid(x)=false then
createsprite x, "enemy"
movesprite x, 1, 1
end if
next
Yeah, that works fine, but what if it makes more than 1 sprite? Can you make a FOR loop stop running?
Title: Re: Various Questions
Post by: EqwanoX on March 02, 2010, 07:31:51 PM
Quote
try this, basically if the sprite doesnt exist it creates it
 
for x=1 to enemies
if spritevalid(x)=false then
createsprite x, "enemy"
movesprite x, 1, 1
exit
end if
next
yea add "exit"
Title: Re: Various Questions
Post by: Connors on March 02, 2010, 07:37:09 PM
COOL thanks a lot!  8)
Now I can put this together even better.
Title: Re: Various Questions
Post by: Connors on March 02, 2010, 09:41:37 PM
I made some major changes to my project, a big one is I found out that using more than one timer makes it run faster. The thing is the UFO sprites aren't moving or colliding anymore. I think it's a problem with one FOR loop because they don't collide anymore either.
This is the entire open card section:
Code: [Select]
CREATESPRITE 1, "BG"
MOVESPRITE 1,0,0

CREATESPRITE 2, "Ship"
MOVESPRITE 2,100,180

LET enemies = 10
LET other = 4
LET shots = 1
LET numy = enemies+other

FOR x = 4 to 14
   CREATESPRITE x, "UFO"
   MOVESPRITE x, random(100)*20+700, random(300)
NEXT

ON TIMER 1
  
   IF fail = true THEN
      
      EXPLODE 2
      STOPTIMER
      
   END IF
  
END TIMER



ON TIMER 1
  
   FOR x = 4 to 14     //this seems to be broken
      IF SPRITEVALID(x) = true THEN
      PUSHSPRITE x, -8, 0
      END IF

      IF SPRITESTOUCHING(2,x) = TRUE THEN
         LET fail = true
      END IF
      
   NEXT
  
END TIMER

ON TIMER 1
  
   IF fail = false THEN
      PUSHSPRITE 1, -8,0
      
      IF spritex(1) < -2210 THEN
         LET spritex (1) = 0
      END IF
      
      FOR i = numy to numy+shots         //pushes shots
        
         IF spritevalid(i) = true THEN
            PUSHSPRITE i, 10, 0
         END IF
      NEXT
   END IF
END TIMER

(i will improve the code to create/push shots once I want them to actually do something, and they are created in the key down section)

EDIT: why must this be so hard? I thought I would be nearly done by now.
Title: Re: Various Questions
Post by: Gan on March 03, 2010, 05:52:34 AM
Game making takes quite a bit of time and work. Though the more you do it, the faster and better you will become. Besides that, Sc has a few feature barriers that you have to work around to get what you want done. Mainly why I find Obj-C easier to make mockups and games in.


-Gan
Title: Re: Various Questions
Post by: EqwanoX on March 03, 2010, 08:12:56 AM
Quote
EDIT: why must this be so hard? I thought I would be nearly done by now.
lol, oh boy, been there, you gotta get used to that part.

you can only have one timer but you can emulate multiple timers useing variables

on timer 1
let timer1=timer1+1
let timer2=timer2+1

if timer1=5 then
let timer1=0

end if