Castle Paradox Forum Index Castle Paradox

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Gamelist   Review List   Song List   All Journals   Site Stats   Search Gamelist   IRC Chat Room

Init Mouse
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
J_Taylor
The Self-Proclaimed King of Ketchup




Joined: 02 Dec 2009
Posts: 188
Location: Western NY

PostPosted: Wed Jun 09, 2010 3:29 am    Post subject: Reply with quote

Code:
include, plotscr.hsd
include, scancode.hsi
include, The Mansion.hsi

#-----------------------

global variable(
1, mouse cursor
2, move-left
)

define constant (15, timer:mouse)

plotscript, new-game, begin

  move-left := create rect (40, 160)

  put slice (move-left, 0, 40)

  if (slice contains (move-left, mouse cursor)) then (mouse cursor := load walkabout sprite (2))

  init mouse
  mouse region (-1, -1, -1, -1)
  mouse cursor := load walkabout sprite (1)
  mouse update loop

  setup camera

end

script, mouse update loop, begin
  set slice x (mouse cursor, mouse pixel x)
  set slice y (mouse cursor, mouse pixel y)
  set timer (timer:mouse, 0, 1, @mouse update loop)
end

script, setup camera, begin
  put camera (0,0)
end


(Said I wasn't very far...)

I'm also now getting a error I'm don't remember being there before:
Quote:
slice contains: invalid slice handle 0

call chain (current script last): new-game

_________________
Elemental: .75%
Heart of Darkness: 0% (crash)
The Mansion: .05%
Shattered Alliance: .05%

See a pattern forming? I do, dammit.
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
Rimudora
Psychopath yandere
Halloween 2006 Creativity Winner
Halloween 2006 Creativity Winner



Joined: 26 May 2005
Posts: 335

PostPosted: Wed Jun 09, 2010 5:58 am    Post subject: Reply with quote

Quote:

if (slice contains (move-left, mouse cursor)) then (mouse cursor := load walkabout sprite (2))

init mouse
mouse region (-1, -1, -1, -1)
mouse cursor := load walkabout sprite (1)


You're trying to use the handle 'mouse cursor' before you've given it a value. It seems like that first bolded line should be in the mouse update loop instead.
Back to top
View user's profile Send private message Send e-mail
J_Taylor
The Self-Proclaimed King of Ketchup




Joined: 02 Dec 2009
Posts: 188
Location: Western NY

PostPosted: Wed Jun 09, 2010 7:10 am    Post subject: Reply with quote

Maybe I should've explained that better.

The second bolded line is supposed to set walkabout sprite (1) as the pic. The first bolded line is supposed to check to see if the mouse is inside the other slice, and if so, change the pic to walkabout sprite (2).

How would this get rewritten to achieve this? Should I put the second bolded line in setup script? Like, one to assign values to the variables?
_________________
Elemental: .75%
Heart of Darkness: 0% (crash)
The Mansion: .05%
Shattered Alliance: .05%

See a pattern forming? I do, dammit.
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
Bob the Hamster
OHRRPGCE Developer




Joined: 22 Feb 2003
Posts: 2526
Location: Hamster Republic (Southern California Enclave)

PostPosted: Wed Jun 09, 2010 7:56 am    Post subject: Reply with quote

Your "if(slice contains)" belongs in the mouse update loop, not in the new-game script.

An "if" command is only evaluated once. It is like:

if (condition) is true RIGHT NOW then(do stuff)

what the "if" command cannot do is:

if (condition) is true now or at any point in the future then(do stuff)

Also, when your mouse is in the move-left area, you should change the cursor with "replace walkabout sprite". if you use "load walkabout sprite" you will load a new copy of the mouse cursor without removing the old one.

Code:
include, plotscr.hsd
include, scancode.hsi
include, The Mansion.hsi

#-----------------------

global variable(
1, mouse cursor
2, move-left
)

define constant (15, timer:mouse)

plotscript, new-game, begin

  move-left := create rect (40, 160)

  put slice (move-left, 0, 40)

  init mouse
  mouse region (-1, -1, -1, -1)
  mouse cursor := load walkabout sprite (1)
  mouse update loop

  setup camera

end

script, mouse update loop, begin
  set slice x (mouse cursor, mouse pixel x)
  set slice y (mouse cursor, mouse pixel y)
  if (slice contains (move-left, mouse cursor)) then (
    replace walkabout sprite (mouse cursor, 2)
  )else(
    replace walkabout sprite (mouse cursor, 1)
  )
  set timer (timer:mouse, 0, 1, @mouse update loop)
end

script, setup camera, begin
  put camera (0,0)
end
Back to top
View user's profile Send private message Send e-mail Visit poster's website
J_Taylor
The Self-Proclaimed King of Ketchup




Joined: 02 Dec 2009
Posts: 188
Location: Western NY

PostPosted: Wed Jun 09, 2010 9:19 am    Post subject: Reply with quote

In other words, I really need to hanker down and force myself to understand loops.

I'm trying to figure this out right now, and I'll let you guys know if I do, but as of yet I haven't had any luck: How do I now add a few more slices to be checked as well?
_________________
Elemental: .75%
Heart of Darkness: 0% (crash)
The Mansion: .05%
Shattered Alliance: .05%

See a pattern forming? I do, dammit.
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
Bob the Hamster
OHRRPGCE Developer




Joined: 22 Feb 2003
Posts: 2526
Location: Hamster Republic (Southern California Enclave)

PostPosted: Wed Jun 09, 2010 9:41 am    Post subject: Reply with quote

you will want more checks in the mouse update loop.

Or better yet, move the checks into a separate script. I think I would organize it like this:

Code:

script, mouse update loop, begin
  set slice x (mouse cursor, mouse pixel x)
  set slice y (mouse cursor, mouse pixel y)
  replace walkabout sprite (mouse cursor, current cursor number)
  set timer (timer:mouse, 0, 1, @mouse update loop)
end

script, current cursor number, begin
  if (cursor should change) then (
    exit returning(2)
  )
  exit returning(1)
end

script, cursor should change, begin
  if(slice contains (move-left, mouse cursor)) then(exit returning(true))
  # add more checks here!
  exit returning(false)
end

Back to top
View user's profile Send private message Send e-mail Visit poster's website
J_Taylor
The Self-Proclaimed King of Ketchup




Joined: 02 Dec 2009
Posts: 188
Location: Western NY

PostPosted: Thu Jun 10, 2010 3:12 pm    Post subject: Reply with quote

I'm feeling really stupid right now.

I understand the 'moving from one script to the next' part well, but that's about it. For instance...

What does the 'exit returning' do? And how does this new script change the mouse visual, exactly?

Sorry if I'm being a bother. I just REALLY want to have mouse compatability in this game, and want a total grasp on it, just in case I decide to make more games with a mouse in them.
_________________
Elemental: .75%
Heart of Darkness: 0% (crash)
The Mansion: .05%
Shattered Alliance: .05%

See a pattern forming? I do, dammit.
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
Bob the Hamster
OHRRPGCE Developer




Joined: 22 Feb 2003
Posts: 2526
Location: Hamster Republic (Southern California Enclave)

PostPosted: Thu Jun 10, 2010 3:22 pm    Post subject: Reply with quote

J_Taylor wrote:
I'm feeling really stupid right now.


Don't worry. you aren't :) This stuff just takes some time to learn.

J_Taylor wrote:
I understand the 'moving from one script to the next' part well, but that's about it. For instance...

What does the 'exit returning' do? And how does this new script change the mouse visual, exactly?


exit returning causes the script to quit and return a value. For example:

Code:

plotscript, my script, begin
  show value(lucky number)
end

script, lucky number, begin
  exit returning(random(1, 100))
end


Okay, that is a dumb example, but hopefully it makes sense. the "lucky number" script returns the random number, and the "show value" displays that number

In the mouse example, the "cursor should change" script returns true if the mouse cursor sprite is colliding with any of the areas that should cause it to change, otherwise it returns false.

the mouse visual is changed by the "replace walkabout sprite" command. That command changes which walkabout sprite the mouse cursor slice is using, but it does not create a new slice.

J_Taylor wrote:
Sorry if I'm being a bother. I just REALLY want to have mouse compatibility in this game, and want a total grasp on it, just in case I decide to make more games with a mouse in them.


Not a bother. Mouse support is important.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
J_Taylor
The Self-Proclaimed King of Ketchup




Joined: 02 Dec 2009
Posts: 188
Location: Western NY

PostPosted: Tue Jun 15, 2010 3:20 am    Post subject: Reply with quote

Okay. Makes a lot more sense now. I actually figured out the piece of 'clicking on the slice = do this' on my own.
_________________
Elemental: .75%
Heart of Darkness: 0% (crash)
The Mansion: .05%
Shattered Alliance: .05%

See a pattern forming? I do, dammit.
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP! All times are GMT - 8 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group