Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> [Scripting]Cursor Basics, simple Logic
Rukiri
post Aug 9 2010, 10:10 AM
Post #1


emerge -avt awesome! Wait... it brings me.... HERE?!
Group Icon

Group: Revolutionary
Posts: 1,729
Type: Scripter
RM Skill: Advanced




This is a simple tutorial of moving the cursor around, be it basic or complex.

In any game you're most likely to have a cursor in your game, what it does is up to you. But this will be more about Game Menu Cursors/Tiles than anything else.


What you need
- 3 Variables(only 2 if it's a single row)
- Cursor Graphic

Variables
- Cursor_Cur_Location = 1 (This will be our first choice)
- Cursor_Max_Location = 3 (3 is the number of max choices, you would add your own number and if a choice is added don't forget to add '1' to the variable)
- Cursor_X = 0 (This is our Cursor X position)
- Cursor_Y = 0 (This is our Cursor Y Position)

Basic Coding

Remember that third variable we would use for rows, it's the same type of coding for left and right but it uses 2 extra variables, example. Cursor_Row_Cur_Location = 0 (This is our first row location), and you'd just add "MAX" to the second variable.

Key Up

CODE
if (Cursor_Cur_Location < 1) {
  Cursor_Cur_Location +=1; // add 1 choice;
  Cursor_Y +=16; // Move 1 16X16 tile.
}
else {
  Cursor_Cur_Location = 1;
  //  If you want to  add an animation for the cursor to move back
  Cursor_Y = 0 // Third Choice
}


Key Up

CODE
if (Cursor_Cur_Location < 1) {
  Cursor_Cur_Location -=1; // minus 1 choice;
  Cursor_Y -=16; // Move 1 16X16 tile.
}
else {
  Cursor_Cur_Location = 3;
  //  If you want to  add an animation for the cursor to move back
  Cursor_Y = 32 // Third Choice
}


Basic Menu Code

CODE
if (Cursor_Cur_Location = 1) {
  // First Choice
}
if (Cursor_Cur_Location = 2) {
  // Second Choice
}
if (Cursor_Cur_Location = 3) {
  // Third Choice
}


Conclusion

While simple this is really how Menus work and Cursors move, you can change how the cursor moves if you want rows, say 4 choices but 2 choices max per row.
I hope you learned something, and expect something new each week!


__________________________
Xeilsoft
- Follow your dreams to the very end..

Kits that I'm working on.
[Unity3D 4.0] LTTP/Minish Cap - I don't have time for custom gfx like what the pze folks are doing but I will try and work on some enhanced LTTP graphics.

Main PC
Core i7 3820 overclocked @ 4.8GHZ
Galaxy: Nvidia Geforce GTX 680 GDDR5 2GB
Asrock X79 Extreme9 w' creative sound
64GB corsair platinum @ 1600MHZ
Muchkin 128GB SSD(boot), OZKIN 2TB SSD, Western Digital GREEN 1TB HDD.
Rosewill Lightning 1000W PSU
OS: Funtoo Linux, Windows 8 (Virtual Machine)

iMac (March 2013)
3.4GHz Quad-core Intel Core i7, Turbo Boost up to 3.9GHz
16GB 1600MHz DDR3 SDRAM - 2X8GB
1TB Serial ATA Drive @ 7200 rpm
NVIDIA GeForce GTX 680MX 2GB GDDR5
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 17th June 2013 - 09:38 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker