You must be logged in to rate this game
This is a tiny tech demo, showing how to use the clamp slice plotscripting command.

Code:


global variable(1, sprite)
global variable(2, box)
global variable(3, button)

plotscript, clampslice example, begin
  suspend player
  init mouse
  unhide mouse cursor

  load slice collection(0)
  sprite := lookup slice(sli:dinosaur)
  box := lookup slice(sli:box)
  button := lookup slice(sli:button)

  while(true) do(
    if(keyval(key:esc) > 1) then(game over)
    update button()
    set slice edge x(sprite, edge:center, mouse pixel x -- slice x(box))
    set slice edge y(sprite, edge:center, mouse pixel y -- slice y(box))
    clamp slice(sprite, box)
    wait(1)
  )
end

script, update button, begin
  if(slice collide point(button, mouse pixel x, mouse pixel y)) then(
    set rect bg col(button, random(0, 255))
    if(mouse click(left button)) then(
      randomize the box()
    )
  )else(
    set rect bg col(button, 96)
  )
end

script, randomize the box, begin
  variable(width)
  width := slice width(sprite layer)
  variable(height)
  height := slice height(sprite layer)
  set slice x(box, random(0, width / 4))
  set slice y(box, random(0, height / 4))
  set slice width(box, random(width / 2, width * 3/4))
  set slice height(box, random(height / 2, height * 3/4))
end
PostPosted: Tue May 02, 2017 3:10 pm
Download
clampslice.zip clampslice.zip (50.37 KB; downloaded 44 times)
clamp slice example rpg (with script)
Reviews
clampslice0001.gif
Tags:


Powered by phpBB © 2001, 2005 phpBB Group