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

ugh, slices...

 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
Blue Pixel
SPY SAPPIN MAH FISH SANDWICH




Joined: 22 Apr 2005
Posts: 621

PostPosted: Sat Dec 05, 2009 12:49 am    Post subject: ugh, slices... Reply with quote

So I'm in the 48 hour contest and i need help fast.

trying to get a large enemy slice (pic1 pal1) to move acoss the screen diagonally. I dont even know how to get it on the screen in the first place.

PLEASE HELP ASAP!!

thanks!

EDIT 8:46PM: current script

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

global variable, begin
 1,  friction
 2,  gravity
 3,  hero-x
 4,  hero-y
 5,  hero-vx
 6,  hero-vy
 7,  hero-speed
 8,  hero-max-vx
 9,  hero-max-vy
 10, hero-jump-speed
 11, hero-animation
 12, hero-direction

 13, enemy anim
 14, hero-hp
 15, hero-max-hp
 16, score
 17, lives left
 18, hero-portrait
 19, lifebar
 20, hero-invincibility
 21, used door
 #main loop variables
 22, playing
 23, hero can jump
 #player control suspension variables
 24, jumping suspended
 25, walking suspended


 3000, rain parent
 3001, old camera x
 3002, old camera y
end

define constant, begin
  14, main loop timer

  #the timer ID used by the rain script
  15, rain timer

  20, first location trigger
  29, last location trigger
  30, first action trigger
  49, last action trigger
end

plotscript, new game, begin
  initialize
  #start the do game script
  set timer(main loop timer, 0, 1, @do game)
  custom main loop
  game over
end

script, initialize, begin
  suspend player
  gravity := 25
  friction := 15
  hero-x := hero pixel x(me) * 10
  hero-y := hero pixel y(me) * 10
  hero-vx := 0
  hero-vy := 0
  hero-speed := 25
  hero-jump-speed := -145
  hero-max-vx := 100
  hero-max-vy := 100
  hero-direction := right
  playing := true

end

define constant, begin
  5, wiggle room
end


#========================================

script, do game, begin

  # Let's do The Loop!
  if (playing == false) then (exit script)


  variable (want left, want right, want jump)

  if (walking suspended == false) then (
    if (key is pressed(key:right)) then (want right := true)
    if (key is pressed(key:left)) then (want left := true)
  )
  if (jumping suspended == false) then (
    if (key is pressed(key:alt)) then (want jump := true,)
  )

  # Accept player input
  if (key is pressed(key:esc)) then (playing := false)
  if (want right) then (
    hero-direction := right
    hero-vx += hero-speed
  )
  if (want left) then (
    hero-direction := left
    hero-vx -= hero-speed
  )
  if (want jump && hero can jump) then (hero-vy := hero-jump-speed, play sound (2))

  # Reduce speed if our hero's going too fast
  if (hero-vy >> hero-max-vy) then (hero-vy := hero-max-vy)
  if (hero-vx >> hero-max-vx) then (hero-vx := hero-max-vx)
  if (hero-vx << hero-max-vx * -1) then (hero-vx := hero-max-vx * -1)

  hero-x += hero-vx
  hero-y += hero-vy


  # TODO: Other game-playing stuff goes here.

  #========================================

  check npcs
   
  if (used door) then (
    # Player changed maps. Update location variables.
    hero-x := hero pixel x * 10
    hero-y := hero pixel y * 10
    hero-vx := 0
    hero-vy := 0
    used door := false
  )

If (key is pressed (57)) then (
set tag (3, off)
  create npc (10, hero-x, hero-y)
  walk npc (10, hero-direction, 3)
  wait for npc (10)
 destroy npc (10)
set tag(3, on)
)

  #================HUD====================


$0=""
$1=""
$2=""
$3=""

$10="HP :"

  variable(g)
  variable(sl)
g:=hero-hp

while (g>>0) do, begin
if (g>>0) then  (append ascii(186, 255),g:=(g--1))
end

 show string at(10, 0, 0)

sl:=load weapon sprite (0,1)
place sprite (sl, 0, 8)
  #========================================

  hero can jump := false
  if (can fall) then (hero-vy += gravity)
  else (
    if (want jump == false) then (hero can jump := true)
    # Apply friction
    if (hero-vx << friction && hero-vx >> friction * -1
        && want left == false && want right == false)
        then (hero-vx := 0)
    if (hero-vx >= friction && want right == false)
        then (hero-vx -= friction)
    if (hero-vx <= friction * -1 && want left == false)
        then (hero-vx += friction)
  )

  if (hero-vx <= 0) then (can left)
  if (hero-vx >= 0) then (can right)
  if (hero-vy <= 0) then (can rise)
  put hero(me, hero-x/10, hero-y/10)
  animate hero

  #loop
  set timer (main loop timer, 0, 1, @do game)

end

script, can fall, begin
  variable (hy) # hero's y-position in maptiles
  hy := hero-y / 200 + 1
  if(
    (read pass block((hero-x / 10 + wiggle room) / 20, hy), and, north wall)
    ||
    (read pass block((hero-x / 10 + 20 -- wiggle room) / 20, hy), and, north wall)
    ||
    (hy >= map height)
  )
  then (
    if (hero-vy>=0)
    then (
      hero-y := hero-y -- (hero-y, mod, 200)
      hero-vy := 0
    )
    return(false)
  )
  else (return(true))
end


#========================================

script, can rise, begin
  variable (hy)
  hy := (hero-y) / 200
  if(
    (read pass block((hero-x / 10 + wiggle room) / 20, hy), and, south wall)
    ||
    (read pass block((hero-x / 10 + 20 -- wiggle room) / 20, hy), and, south wall)
    ||
    (hy<<0)
  )
  then (
    hero-y := hero-y -- hero-y,mod,200 + 200
    if (hero-vy<<0) then (hero-vy:=0)
    return(false)
  )
  else (return(true))
end

#========================================

script, can left, begin
  variable (hx)
  hx := (hero-x--10) / 200
  if(
    (readpassblock(hx,(hero-y) / 200), and, east wall)
    ||
    (readpassblock(hx,(hero-y + 199) / 200), and, east wall)
    ||
    (hx<<0)
  )
  then (
    variable(new x)
    new x := 0
    if (hero-x,mod,200 >> 100) then (newx := 200)
    if (hero-vx << 100, and, (hero-x,mod,200 >> 50)) then (newx := 200)
    hero-x := hero-x -- (hero-x,mod,200) + new x

    if (hero-vx << 0) then (hero-vx := 0)
    return(false)
  )
  else (return(true))
)

#========================================

script, can right, begin
  variable (hx)
  hx:= hero-x / 200 + 1
  if (
    (read pass block(hx, hero-y / 200), and, west wall)
    ||
    (read pass block(hx, (hero-y + 199) / 200), and, westwall)
    ||
    (hx >= map width)
  )
  then (
    hero-x := hero-x -- (hero-x,mod,200)

    if (hero-vx >> 0) then (hero-vx := 0)
    return(false)
  )
  else (return(true))
end

#========================================

script, animate hero, begin
   if (hero-direction == right) then (
      set hero frame(me, 1)
   ) else (
      set hero frame(me, 0)
   )
   
   if (hero-vy << 0) then (
      # Jumping
      set hero direction(me, 2)
   ) else (
      if (hero-vy >> 0) then (
         # Falling
         set hero direction(me, 3)
      ) else (
         if (hero-vx <> 0) then (
            # Cycle between walking and standing
            if (hero-vx << 0) then (hero-animation -= hero-vx)           
            if (hero-vx >> 0) then (hero-animation += hero-vx)
            if (hero-animation >= hero-max-vx * 2) then (hero-animation -= hero-max-vx * 2)
            if (hero-animation >> hero-max-vx) then
            (
               set hero direction(me, 0)
            ) else (
               set hero direction(me, 1)
            )
         ) else (
            # Standing
            set hero direction(me, 0)
         )
      )
   )
end

#========================================

plotscript, start rain, begin
  variable (x, y, sl)
  # initialise
  rain parent := create container
  for (x, 0, 320, 80) do (
    for (y, 0, 240, 80) do (
      sl := load large enemy sprite(0, 1) #change this
      place sprite (sl, x, y)
      set parent (sl, rain parent)
    )
  )
  old camera x := camera pixel x
  old camera y := camera pixel y
  set timer (rain timer, 1, 1, @update rain)
end

script, update rain, begin
  variable (x, y, sl)
  # rain effect
  # loop through all slices
  sl := first child (rain parent)
  while (sl) do (
    x := slice x (sl) + 2 -- camera pixel x + old camera x
    if (x >> 320) then (x -= 320 + 80)
    if (x <= -80) then (x += 320 + 80)
    y := slice y (sl) + 2 -- camera pixel y + old camera y
    if (y >> 240) then (y -= 240 + 80)
    if (x <= -80) then (y += 240 + 80)
    place sprite (sl, x, y)
    sl := next sibling (sl)
  )
  old camera x := camera pixel x
  old camera y := camera pixel y
  set timer (rain timer, 0, 1, @update rain)
end

plotscript, stop rain, begin
  stop timer (rain timer)
  # delete rain slices
  free slice (rain parent)
end


#========================================

script, custom main loop, begin
while (playing) do (
#FIXME: you need to make sure this script is triggered only once!
if (hero x(me)>>15 && check tag(2)<<1)
then (intro)
wait (1)
)
end

Script, intro, begin
#suspend player
walking suspended := true
jumping suspended := true
variable (sl, box)
Box := create container (50, 50)
set slice x (box, 400)
set slice y (box, 100)
set parent (box, lookup slice(sl: map layer 1))
sl := load medium enemy sprite (0,1)
set parent(sl, box)
play sound (1)
Wait (20)
Show text box (1)
wait for text box
wait (10)
wait (1)
free slice (box)
walking suspended := false
jumping suspended := false
set tag (2, on)
end

#========================================

plotscript, npc door, which, begin
  use door(which)
  used door := true
end

script, npc near hero, ref, begin
  variable(nx, ny)
  nx := npc pixel x(ref) * 10
  ny := npc pixel y(ref) * 10
  return ((nx -- hero-x << 200 && hero-x -- nx << 200) &&
          (ny -- hero-y << 200 && hero-y -- ny << 200))
end


script, check npcs, begin
  variable(i, j, ref)
  # Location triggers
  for(i, first location trigger, last location trigger) do (
    for (j, 0, npc copy count(i) -- 1) do (
      ref := npc reference(i, j)
      if (npc near hero(ref)) then (
        use npc(ref)
        wait for text box
      )
    )
  )
end


#========================================

script, snakeboss, begin

end


#========================================


_________________


Last edited by Blue Pixel on Sat Dec 05, 2009 5:46 pm; edited 3 times in total
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Rimudora
Psychopath yandere
Halloween 2006 Creativity Winner
Halloween 2006 Creativity Winner



Joined: 26 May 2005
Posts: 335

PostPosted: Sat Dec 05, 2009 2:31 am    Post subject: Reply with quote

Code:
variable(handle)
handle:=load large enemy sprite(1,1)
place sprite (handle, x, y)


Where x and y are where you want the sprite to start. I believe this will be enough to make your enemy sprite appear on-screen. Once you do that, you can use the handle with other slice functions. There's stuff here that tells you how to move slices, I believe.
http://gilgamesh.hamsterrepublic.com/wiki/ohrrpgce/index.php/Plotslices_Tutorial
Back to top
View user's profile Send private message Send e-mail
Blue Pixel
SPY SAPPIN MAH FISH SANDWICH




Joined: 22 Apr 2005
Posts: 621

PostPosted: Sat Dec 05, 2009 2:36 am    Post subject: Reply with quote

Nvm, Tmc helped me with this Happy

but now i need to know how to trigger scripts using the sidescroller tutorial, since im pretty sure you cant access npcs the normal way using it.
_________________
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Moogle1
Scourge of the Seas
Halloween 2006 Creativity Winner
Halloween 2006 Creativity Winner



Joined: 15 Jul 2004
Posts: 3377
Location: Seattle, WA

PostPosted: Sat Dec 05, 2009 11:17 am    Post subject: Reply with quote

In the script you're using, NPCs 20-29 will be used when you are touching them.

You have two copies of "check npcs."
_________________
Back to top
View user's profile Send private message Visit poster's website AIM Address
Blue Pixel
SPY SAPPIN MAH FISH SANDWICH




Joined: 22 Apr 2005
Posts: 621

PostPosted: Sat Dec 05, 2009 5:47 pm    Post subject: Reply with quote

Now I need help setting up bullets.

I havn't got the slightest clue on how to do that.
_________________
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP! All times are GMT - 8 Hours
Page 1 of 1

 
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