Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Placing images at the current mousex/mousey and keeping them there.

Author
Message
Deego
16
Years of Service
User Offline
Joined: 21st May 2008
Location:
Posted: 28th Jun 2008 02:40
I'm trying to create a game where you shoot targets with a paintball gun. Each time you pull the trigger, the desired effect is an image, selected at random, pasted at the current mousex and mousey, that will remain there.

I tried setting up an array so that on every click, the current mousex and mousey are saved. At the same time, I tried pasting a randomly selected sprite.



Problem is, I don't think arrays work inside an "if" command, rendering my attempt at saving the mousex/mousey of old clicks futile.

If anyone has played Goldeneye on N64 with the paintball cheat, I'm trying to do exactly the same thing, but with 2D instead of 3D.

Attachments

Login to view attachments
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 28th Jun 2008 04:15 Edited at: 28th Jun 2008 04:19
Maybe this will help. When getting something like a mouse position, make sure you put it in the loop so it will be continuously updating when the player moves the mouse.

Click and hold to make circles appear where you click. Keep in mind that there are better ways of organizing this (such as the use of a User Defined Type) but I tried to keep it sort of simple...



And, if you would like, a tutorial on arrays can be found here:
http://forum.thegamecreators.com/?m=forum_view&t=84908&b=7

Deego
16
Years of Service
User Offline
Joined: 21st May 2008
Location:
Posted: 28th Jun 2008 04:41
Oops, forgot to set up my arrays (dim PSx(integer), not dim PSx()). Thanks! That's a great snippet.
Deego
16
Years of Service
User Offline
Joined: 21st May 2008
Location:
Posted: 28th Jun 2008 05:34
Here's the working code, for future reference.



The SpriteNumber reset has to be before illegal numbers will be used in the code.
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 28th Jun 2008 15:09
Glad to be of help

Login to post a reply

Server time is: 2024-09-27 16:24:27
Your offset time is: 2024-09-27 16:24:27