Discussion forum about PANORAMIC language
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Discussion forum about PANORAMIC language

Mac, Windows & Android application development with PANORAMIC language
 
HomeHome  SearchSearch  Latest imagesLatest images  RegisterRegister  Log in  
Latest topics
» What happened with the panoramic language ?
by Wed Jan 03, 2024 4:09 pm

» Hello world.
by Wed May 09, 2018 11:53 pm

» Biomorphes de PICKOVER
by Sun Jun 18, 2017 2:33 am

» In less than 10 lines of code
by Fri Jun 16, 2017 5:03 am

» Effect Dopler
by Fri Jun 16, 2017 3:29 am

» SuperEllipse
by Wed Jun 14, 2017 4:01 am

» Plants
by Wed Jun 14, 2017 3:38 am

» Mira's attractor
by Wed Jun 14, 2017 3:30 am

» Triangle of Sierpinski
by Wed Jun 14, 2017 3:22 am

» Esthétique polaire
by Wed Jun 14, 2017 3:16 am

» Butterfly effect : Lorenz equations
by Wed Jun 14, 2017 3:08 am

» Collision detection
by Tue Jun 13, 2017 5:09 am

» The Bees Laline Paull Epub Books
by Mon Oct 10, 2016 8:58 pm

» PANORAMIC for Mac OSX 10 is available
by Tue Aug 09, 2016 6:08 pm

» ide
by Sat Jul 16, 2016 12:27 am

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

 

 Clic to select on sprite and move it !! (Thanks Klaus)

Go down 
3 posters
AuthorMessage
jicehel




Number of posts : 15
Registration date : 2013-03-12

Clic to select on sprite and move it !! (Thanks Klaus) Empty
PostSubject: Clic to select on sprite and move it !! (Thanks Klaus)   Clic to select on sprite and move it !! (Thanks Klaus) EmptySat Mar 23, 2013 1:48 pm

A cool source from Klaus until he can connect:
The source create 2 sprites:
- A blue rectangle
- A red ring
The ring is on the rectangle at the begin.
You can clic on one of the sprites to select it and then you can or clic somether to move the sprote or click on other sprites to deselect the current and select the one you clicked on

This source can be adapted for many use of sprites ...
English users show us you can do cool things too with Panoramic !!
PS: Germans users are alot too (Klaus, Stephan, Severin). I'm sure you make cool things too...

Code:
' ON_SPRITE_CLICK.bas
label click, tim
dim i%, x%, y%, ns%, spr%, x1%, y1%, delta%
dim number_sprite_click%, save_sprite_click%

delta% = 1

scene2d 1 : on_click 1,click : full_space 1 : color 1,200,200,200
image 2
timer 3 : timer_interval 3,100 : on_timer 3,tim : timer_off 3

ns% = 0 : ' initialement pas de sprites
dim sprites%(10,2)  : ' pérvoir pour 10 sprites

' premier sprite: rectangle bleu
sprite 17 : sprite_position 17,300,10
picture 17 : hide 17 : width 17,200 : height 17,10
2d_target_is 17 : 2d_pen_color 0,0,255 : 2d_fill_color 0,0,255
2d_rectangle 0,0,199,9
2d_image_copy 2,0,0,199,9
sprite_image_load 17,2
memoriser_sprite(17,200,10)
sprite_position 17,200,200

' deuxième sprite: anneau rouge
sprite 12 : sprite_position 12,10,50
picture 12 : hide 12 : width 12,120 : height 12,120
color 12,0,0,0 : ' fond transparent
2d_target_is 12 : 2d_pen_color 255,0,0 : 2d_fill_color 255,0,0
2d_circle 60,60,50
2d_fill_color 0,0,0
2d_circle 60,60,25
2d_image_copy 2,0,0,119,119
sprite_image_load 12,2
memoriser_sprite(12,120,120)
sprite_position 12,250,150

end

sub memoriser_sprite(n%,w%,h%)
  ns% = ns% + 1        : ' compter le nouveau sprite
  sprites%(ns%,0) = n% : ' numéro du sprite
  sprites%(ns%,1) = w% : ' largeur du sprite
  sprites%(ns%,2) = h% : ' hauteur du sprite
end_sub

tim:
  sprite_position number_sprite_click%,sprite_x_position(number_sprite_click%)+delta%,sprite_y_position(number_sprite_click%)+delta%
  delta% = 0 - delta%
  return

click:
  timer_off 3
  save_sprite_click% = number_sprite_click%
  number_sprite_click% = 0  : ' supposer "aucun sprite n'est cliqué"
  x% = mouse_x_left_down(1)
  y% = mouse_y_left_down(1)
  for i%=ns% to 1 step -1  : ' boucle sur les sprites existants
    spr% = sprites%(i%,0)
    x1% = x% - sprite_x_position(spr%)
    y1% = y% - sprite_y_position(spr%)
    ' test si l'abscisse du clic correspond à ce sprite
    if x%>=sprite_x_position(spr%)
      if x%<(sprite_x_position(spr%)+sprites%(i%,1))
        ' test si l'ordonnée du clic correspond à ce sprite
        if y%>=sprite_y_position(spr%)
          if y%<(sprite_y_position(spr%)+sprites%(i%,2))
            ' test si ce n'est pas la couleur transparente
            if (color_pixel_red(spr%,x1%,y1%)+color_pixel_green(spr%,x1%,y1%)+color_pixel_blue(spr%,x1%,y1%))>0
              ' alors on a identifié le sprite
              number_sprite_click% = spr%
              : ' .. lancer ici la routine on_sprite_click
              caption 0,"NUMBER_SPRITE_CLICK = "+str$(number_sprite_click%)
              timer_on 3
              return
            end_if
          end_if
        end_if
      end_if
    end_if
  next i%
  if save_sprite_click%>0 then sprite_position save_sprite_click%,x%,y%
  caption 0,"NUMBER_SPRITE_CLICK = 0"
  return
Back to top Go down
Klaus

Klaus


Number of posts : 18
Age : 74
Localisation : France
Registration date : 2013-03-23

Clic to select on sprite and move it !! (Thanks Klaus) Empty
PostSubject: Re: Clic to select on sprite and move it !! (Thanks Klaus)   Clic to select on sprite and move it !! (Thanks Klaus) EmptySat Mar 23, 2013 9:19 pm

Hello, here I am ! I use KGF as pseudo on the english form because Klaus is simply refused here, but it's me anyway ! Thanks to you, Papydall, for estimating my little sample worth to be published here !
Back to top Go down
http://klaus.panoramic.voila.net/
jicehel




Number of posts : 15
Registration date : 2013-03-12

Clic to select on sprite and move it !! (Thanks Klaus) Empty
PostSubject: Re: Clic to select on sprite and move it !! (Thanks Klaus)   Clic to select on sprite and move it !! (Thanks Klaus) EmptySun Mar 24, 2013 1:35 am

Klaus Jicehel is the same Jicehel as on the french Forum... Not papydall Very Happy
Back to top Go down
papydall

papydall


Number of posts : 39
Age : 73
Localisation : TUNISIA
Registration date : 2013-03-16

Clic to select on sprite and move it !! (Thanks Klaus) Empty
PostSubject: Re: Clic to select on sprite and move it !! (Thanks Klaus)   Clic to select on sprite and move it !! (Thanks Klaus) EmptySun Mar 24, 2013 1:40 am

Klaus wrote:
Hello, here I am ! I use KGF as pseudo on the english form because Klaus is simply refused here, but it's me anyway ! Thanks to you, Papydall, for estimating my little sample worth to be published here !

Let us return to Caesar what belongs to Caesar: it is rather Jicehel whom you have to thank.
Back to top Go down
Klaus

Klaus


Number of posts : 18
Age : 74
Localisation : France
Registration date : 2013-03-23

Clic to select on sprite and move it !! (Thanks Klaus) Empty
PostSubject: Re: Clic to select on sprite and move it !! (Thanks Klaus)   Clic to select on sprite and move it !! (Thanks Klaus) EmptySun Mar 24, 2013 10:51 am

Oh yes, sorry Jicehel ! And thank you !
Back to top Go down
http://klaus.panoramic.voila.net/
Sponsored content





Clic to select on sprite and move it !! (Thanks Klaus) Empty
PostSubject: Re: Clic to select on sprite and move it !! (Thanks Klaus)   Clic to select on sprite and move it !! (Thanks Klaus) Empty

Back to top Go down
 
Clic to select on sprite and move it !! (Thanks Klaus)
Back to top 
Page 1 of 1
 Similar topics
-
» KGF.dll from klaus
» how to move in a scene in 3D

Permissions in this forum:You cannot reply to topics in this forum
Discussion forum about PANORAMIC language :: Panoramic for Windows :: Source code (snippets)-
Jump to: