Forum Le CBNA

Le Forum du CBNA a pour but de vous aider dans l'utilisation de GameMaker. Premier forum Francophone sous GameMaker, vous trouverez des .gmd, .gm6, .gmk, scripts, logiciels et d'autres ressources sur Le CBNA.
 
AccueilAccueil  ­FAQFAQ  ­RechercherRechercher  ­S'enregistrerS'enregistrer  ­MembresMembres  ­ConnexionConnexion  
Poster un nouveau sujet   Répondre au sujetPartager | 
 

 Dessiner un spirographe

Voir le sujet précédent Voir le sujet suivant Aller en bas 
AuteurMessage
onilink_
Utilisateur moyen


Nombre de messages: 63
Localisation: Le vigan (Pres de Ganges)
Projet Actuel: Convertisseur : Projet .gm6 >> Projet C++ SDL + FMOD
Avancement:
10 / 10010 / 100


MessageSujet: Dessiner un spirographe   Mer 30 Sep - 20:10

Code a mettre dans le DRAW event
Code:

if !variable_local_exists('create')
{
rad = pi/180
add = 0.1

rc1 = 200
rc2 = 90
pl  = 80
v1 = 1-add
v2 = 2
create = 1
}

xc1 = room_width/2
yc1 = room_height/2

am = 3600

s = 1

draw_set_color(c_white)
for(a1=0 ; a1<=am ; a1+=s)
{
        a2 = a1*v2
       
        xc2 = xc1 + cos(a1*v1*rad)*(rc1-rc2)
        yc2 = yc1 + sin(a1*v1*rad)*(rc1-rc2)
        x = xc2 + cos(a2*rad)*pl
        y = yc2 + sin(a2*rad)*pl
       
        xc2_= xc1 + cos((a1+s)*v1*rad)*(rc1-rc2)
        yc2_= yc1 + sin((a1+s)*v1*rad)*(rc1-rc2)
        x_= xc2_+ cos((a2+s*v2)*rad)*pl
        y_= yc2_+ sin((a2+s*v2)*rad)*pl
       
        draw_line(x,y,x_,y_)
}

if keyboard_check(vk_left)
{
if keyboard_check(ord('A'))
rc1 += 1

if keyboard_check(ord('Z'))
rc2 += 1

if keyboard_check(ord('E'))
pl -= 1
}

if keyboard_check(vk_right)
{
if keyboard_check(ord('A'))
rc1 -= 1

if keyboard_check(ord('Z'))
rc2 -= 1

if keyboard_check(ord('E'))
pl += 1
}

if keyboard_check_pressed(vk_up)
{
if keyboard_check(ord('A'))
v1 += add

if keyboard_check(ord('Z'))
v2 += add
}

if keyboard_check_pressed(vk_down)
{
if keyboard_check(ord('A'))
v1 -= add

if keyboard_check(ord('Z'))
v2 -= add
}


pour changer le spirographe
on utilise les touches directionnelles + A,Z et E[code]
Revenir en haut Aller en bas
shm31
*Excellent utilisateur*


Nombre de messages: 12381
Projet Actuel: Cotoniser (générateur de nuages)
Avancement:
90 / 10090 / 100


MessageSujet: Re: Dessiner un spirographe   Mer 30 Sep - 23:35

le framerate est plutôt médiocre je dirais, ça bouffe pas mal de perf

_________________
Citation:
Mario never had any adventure...he is a delusional old Plumber (Or had something to do with him eating Shrooms/Drugs)

The Giant Turtles and Goombas are what he sees everyday while working on the sewers, Dry bones being the corpses of dead turtles kid flushes through the toilets...
And Bowser is the constant fear to those "Alligator in the sewers" urban legends
Peach is just a Pin up girl turned Princess in his own twisted mind....
Revenir en haut Aller en bas
http://host-a.net/shm31
daminetreg
- Administrateur -


Nombre de messages: 16626
Localisation: Siege du CBNA!
Projet Actuel: Site Web du CBNA, version beta :
Avancement:
99 / 10099 / 100


MessageSujet: Re: Dessiner un spirographe   Jeu 1 Oct - 10:53

shm31 a écrit:
le framerate est plutôt médiocre je dirais, ça bouffe pas mal de perf


Faudrait juste optimiser tout ça, mais en soi le système fonctionne. ^^

_________________

Mon CV
Le CBNA Tous Ensemble! Réalisons!
Revenir en haut Aller en bas
http://lecbna.org/
onilink_
Utilisateur moyen


Nombre de messages: 63
Localisation: Le vigan (Pres de Ganges)
Projet Actuel: Convertisseur : Projet .gm6 >> Projet C++ SDL + FMOD
Avancement:
10 / 10010 / 100


MessageSujet: Re: Dessiner un spirographe   Jeu 1 Oct - 16:54

pour plus d'optimisation faut changer la valeur de la variable
s.
Pour de bonnes performances la mettre a 5 ou 10.
Par contre la qualité diminue.
Sinon on peut pas vraiment optimiser plus sauf en creant un tableau
cos et un autre sin pour ne pas a avoir a utiliser les fonctions de trigo
qui bouffent pas mal de vitesse.
Revenir en haut Aller en bas
onilink_
Utilisateur moyen


Nombre de messages: 63
Localisation: Le vigan (Pres de Ganges)
Projet Actuel: Convertisseur : Projet .gm6 >> Projet C++ SDL + FMOD
Avancement:
10 / 10010 / 100


MessageSujet: Re: Dessiner un spirographe   Jeu 5 Nov - 20:04

En fait je retire ce que j'ai dit pour les fonctions de trigo elles sont trés performantes ange (pardonnez-moi^^)

Sinon voila un léger remake pour les faignants qui ne vont que tester le code happy1 .

Code:

if !variable_local_exists('create')
{
    rad = pi/180
    add = 0.1

    rc1 = 200
    rc2 = 90
    pl  = 80
    v1 = 1-add
    v2 = 2
    create = 1
}

xc1 = room_width/2
yc1 = room_height/2
am = 3600
//A augmenter si sa rame ^^
s = 5

for(a1=0 ; a1<=am ; a1+=s)
{
        a2 = a1*v2
     
        xc2 = xc1 + cos(a1*v1*rad)*(rc1-rc2)
        yc2 = yc1 + sin(a1*v1*rad)*(rc1-rc2)
        x = xc2 + cos(a2*rad)*pl
        y = yc2 + sin(a2*rad)*pl
     
        xc2_= xc1 + cos((a1+s)*v1*rad)*(rc1-rc2)
        yc2_= yc1 + sin((a1+s)*v1*rad)*(rc1-rc2)
        x_= xc2_+ cos((a2+s*v2)*rad)*pl
        y_= yc2_+ sin((a2+s*v2)*rad)*pl
       
        draw_set_color(v1*v2*256)
        draw_line(x,y,x_,y_)
}

if keyboard_check(vk_left)          {
if keyboard_check(ord('A'))rc1 += 1
if keyboard_check(ord('Z'))rc2 += 1
if keyboard_check(ord('E'))pl -= 1
}

if keyboard_check(vk_right)        {
if keyboard_check(ord('A'))rc1 -= 1
if keyboard_check(ord('Z'))rc2 -= 1
if keyboard_check(ord('E'))pl += 1
}

if keyboard_check_pressed(vk_up)    {
if keyboard_check(ord('A')) v1 += add
if keyboard_check(ord('Z')) v2 += add
}

if keyboard_check_pressed(vk_down)  {
if keyboard_check(ord('A')) v1 -= add
if keyboard_check(ord('Z')) v2 -= add
}


Voila ça devrait être beaucoup moins mou p_bye
Revenir en haut Aller en bas
 

Dessiner un spirographe

Voir le sujet précédent Voir le sujet suivant Revenir en haut 
Page 1 sur 1

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
Forum Le CBNA :: Programmation :: Scripts GML-
Poster un nouveau sujet   Répondre au sujet