X

تعلم تصميم لعبة ذكاء بشكل بسيط

AutoPlay Media Studio and Generate All In One Tutorials

 
  • Filter
  • Time
  • Show
Clear All
new posts
  • عبد الهادي بهاب
    Thread Author
    Free Membership
    • Nov 2018 
    • 181 
    • 81 
    • 43 

    السلام عليكم

    اليوم سنقوم لتعلم تصميم لعبة ذكاء بسيطة جدا تعتمد على تدوير مجموعة اشكال للوصول الى تطابق افقي او عمودي

    الفكرة مستقامة من لعبى تسمى hisimantiki



    رابط اللعبة
    http://www.b30b.com/up//view.php?file=bb52549e0d

    الان مع البرمحة بالاوتوبلاي :
    سنركز على شيئين تدوير الاشكال و ايضا كيف نعلن ان اللاعب نجح في الللعب

    - افتح مشروع جديد
    - في الصفحة ضع 2 من paragraph و ضع لهما لون واحدا لكليهما او ممكن تخد صورة كخلفية ما
    - حمل صور لاشكال بسيطة مختلفة اللون مثلا الاشكال التالية



















    - الان نضع الصور بشكل موزع على حواف الخلفيتين بهذا الشكل :


    الان سنفترض ان المشكل في الصورتين المتقابلتين يجب ان يكونا من نفس النوع
    لذلك سنجعل كود التصحيح هو ان يعرف مصدر الصورتين لمتقابلتين
    فان وجد انهما من نفس النوع يعلنك لاعيا ناجحا
    اذن اولا سنحفظ مكان الصورتين المتقابلتين و في مشروعنا هما الصورة رقم 3 من المربع الاول
    و الصورة 5 من المربع 2
    و لنتفرض متغيرين هما sol 1 ; sol2 وهما موقع الصورتين باستخدام الكود التالي :

    PHP Code:
    sol1 Image.GetPos("Image3");
    sol2 Image.GetPos("Image5"); 
    ثم نضع متغيرين اين نحفظ فيهما مصدر الصورتين الموجدتين في الموقع 3 و 5 و نسميهما obj1: obj2
    بداية نعطيهما مصدر الصورتين في الشكل الاول بواسطة الكود

    PHP Code:
    obj1 Image.GetFilename("Image3");
    obj2 Image.GetFilename("Image5"); 
    الان كيف نجعل المربع يدور ؟
    نحن لن نجعله يدور بل سنجعل الصور التي في وسطه تدور ...و بالاحرى تغيير مواقعها تباعا من اليمين الى اليسار او العكس بوضع موقع الصور بالشكل التالي :



    تضع في الخلفية للمربع الاول مهما كان صورة او paragraph نضغ في الحدث On click الكود التالي :
    نحفظ موقع الصور من 1 الى 4 في مصفوفة ... ثم نجعل الصورة الاولى تاخد موقع الصورة 2 و الصورة 2 تنتقل الى موقع الصورة 3 و هكذا

    PHP Code:
    pos1={}; for i=1,do  pos1[i] = Image.GetPos("Image"..iend

    for i=1,do
      if 
    i== 4 then p=1; else p=i+1 end
      Image
    .SetPos("Image"..pos1[p].Xpos1[p].Y);
    end 
    نفس الشي في المربع الثاني فقط نضيف i+4 لياخد موقع الصور 5-6-7-8

    PHP Code:
    pos1={}; for i=1,do  pos1[i] = Image.GetPos("Image"..i+4end

    for i=1,do
      if 
    i== 4 then p=1; else p=i+1 end
      Image
    .SetPos("Image"..i+pos1[p].Xpos1[p].Y);
    end 
    جميل فلما تضغط على الصور تتنقل كالتالي :



    الان ناتي الى كود التصحيح :
    بعد كل ضغطة سيحفظ الكود ماهو مصدر الصورة التي تحتل الموقع 3 في obj1
    نفس الشيء في المربع الثاني يحفظ مصدر الصورة التي تحتل الموقع 5 و يحفظها في obj2

    الان سيقارن القيمتين obj1 و obj2 فان كانا متساويتيم فان الشكلين كتطابقين و بالتالي نجح اللاعب
    اذن في المربع الاول يصبح الكود كالاتي

    PHP Code:
    pos1={}; for i=1,do  pos1[i] = Image.GetPos("Image"..iend

    for i=1,do
      if 
    i== 4 then p=1; else p=i+1 end
      Image
    .SetPos("Image"..pos1[p].Xpos1[p].Y);
    end

    for i=1,do
      if 
    Image.GetPos("Image"..i).== sol1.and Image.GetPos("Image"..i).== sol1.Y then
      ala 
    ;
      
    end
    end

    obj1 
    Image.GetFilename("Image"..ala);

    if 
    obj1 ~= "" and obj2 ~= "" and obj1 == obj2 then
    Dialog
    .Message("bahab elhadi","gooooooooooooooooood");
    end 
    و في المربع الثاني:

    PHP Code:
    pos1={}; for i1,do  pos1[i] = Image.GetPos("Image"..i+4end

    for i=1,do
      if 
    i== 4 then p=1; else p=i+1 end
    Image
    .SetPos("Image"..i+pos1[p].Xpos1[p].Y);
    end

    for i=1,do
      if 
    Image.GetPos("Image"..i+4).== sol2.and Image.GetPos("Image"..i+4).== sol2.Y then
      ali 
    i+;
      
    end
    end

    obj2 
    Image.GetFilename("Image"..ali);

    if 
    obj1 ~= "" and obj2 ~= "" and obj1 == obj2 then
    Dialog
    .Message("bahab elhadi","gooooooooooooooooood");
    end 
    و في الصفحة في on show

    PHP Code:
    sol1 Image.GetPos("Image3");
    sol2 Image.GetPos("Image5");
    obj1 Image.GetFilename("Image3");
    obj2 Image.GetFilename("Image5"); 
    احفظ العمل ثم معاينة

    بالتوفيق
  • Saadedin
    Administrator
    • Sep 2018 
    • 35703 
    • 18,350 
    • 2,790 

    #2
    يتبع:
    Originally posted by عبد الهادي بهاب
    السلام عليكم
    في الصفحة الثانية
    سنضع الان اربع مربعات و في كل مريع اربع اشكال
    بعذا الشكل



    يجب ان تركز على الصور المتقابلة و نسجل ارقامها و هي التي ستلزمنا في كود التصحبح
    في مشروعنا الارقام المتقابلة هي الكاتي


    سيكون نفس الكود لتدوير اشكال المربع الواحد و يسجل مصدر الصور التي نريدها في كل مربع
    و بالتالي يصبح المشروع كالالتي

    في الصفحة on show
    PHP Code:
    sol1 Image.GetPos("Image3");
    sol2 Image.GetPos("Image4");
    obj1 Image.GetFilename("Image3");
    obj2 Image.GetFilename("Image4");

    sol3 Image.GetPos("Image5");
    sol4 Image.GetPos("Image8");
    obj3 Image.GetFilename("Image5");
    obj4 Image.GetFilename("Image8");

    sol5 Image.GetPos("Image10");
    sol6 Image.GetPos("Image11");
    obj5 Image.GetFilename("Image10");
    obj6 Image.GetFilename("Image11");

    sol7 Image.GetPos("Image14");
    sol8 Image.GetPos("Image13");
    obj7 Image.GetFilename("Image14");
    obj8 Image.GetFilename("Image13"); 
    الان في المربع الاول اعلى بسار
    PHP Code:
    pos1={}; for i=1,do  pos1[i] = Image.GetPos("Image"..iend

    for i=1,do
      if 
    i== 4 then p=1; else p=i+1 end
      Image
    .SetPos("Image"..pos1[p].Xpos1[p].Y);
    end

    for i=1,do
      if 
    Image.GetPos("Image"..i).== sol1.X
      
    and Image.GetPos("Image"..i).== sol1.Y then
      ala 
    ;
      elseif 
    Image.GetPos("Image"..i).== sol2.X
      
    and Image.GetPos("Image"..i).== sol2.Y then
      ali 
    ;
      
    end
    end

    obj1 
    Image.GetFilename("Image"..ala);
    obj2 Image.GetFilename("Image"..ali);


    if 
    obj1 == obj3 and obj2 == obj5
    and obj6 == obj8 and obj4 == obj7  then
    Dialog
    .Message("","gooooooooooooooooood");
    end 
    في المربع الثاني اعلى على اليمسن
    PHP Code:
    pos1={}; for i=1,do  pos1[i] = Image.GetPos("Image"..i+4end

    for i=1,do
      if 
    i== 4 then p=1; else p=i+1 end
      Image
    .SetPos("Image"..i+pos1[p].Xpos1[p].Y);
    end

    for i=1,do
      if 
    Image.GetPos("Image"..i+4).== sol3.X
      
    and Image.GetPos("Image"..i+4).== sol3.Y then
      ala 
    i+;
      elseif 
    Image.GetPos("Image"..i+4).== sol4.X
      
    and Image.GetPos("Image"..i+4).== sol4.Y then
      ali 
    i+;
      
    end
      end

    obj3 
    Image.GetFilename("Image"..ala);
    obj4 Image.GetFilename("Image"..ali);


    if 
    obj1 == obj3 and obj2 == obj5
    and obj6 == obj8 and obj4 == obj7  then
    Dialog
    .Message("","gooooooooooooooooood");
    end 
    في المربع الثالث اسفل بسار
    PHP Code:
    pos1={}; for i=1,do  pos1[i] = Image.GetPos("Image"..i+8end

    for i=1,do
      if 
    i== 4 then p=1; else p=i+1 end
      Image
    .SetPos("Image"..i+pos1[p].Xpos1[p].Y);
    end

    for i=1,do
      if 
    Image.GetPos("Image"..i+8).== sol5.X
      
    and Image.GetPos("Image"..i+8).== sol5.Y then
      ala 
    i+;
      elseif 
    Image.GetPos("Image"..i+8).== sol6.X
      
    and Image.GetPos("Image"..i+8).== sol6.Y then
      ali 
    i+;
      
    end
    end



    obj5 
    Image.GetFilename("Image"..ala);
    obj6 Image.GetFilename("Image"..ali);


    if 
    obj1 == obj3 and obj2 == obj5
    and obj6 == obj8 and obj4 == obj7  then
    Dialog
    .Message("","gooooooooooooooooood");
    end 
    في المربع الرابع اسفل يمين
    PHP Code:
    pos1={}; for i=1,do  pos1[i] = Image.GetPos("Image"..i+12end

    for i=1,do
      if 
    i== 4 then p=1; else p=i+1 end
      Image
    .SetPos("Image"..i+12 pos1[p].Xpos1[p].Y);
    end

    for i=1,do
      if 
    Image.GetPos("Image"..i+12).== sol7.X
      
    and Image.GetPos("Image"..i+12).== sol7.Y then
      ala 
    i+12 ;
      elseif 
    Image.GetPos("Image"..i+12).== sol8.X
      
    and Image.GetPos("Image"..i+12).== sol8.Y then
      ali 
    i+12 ;
      
    end
    end


    obj7 
    Image.GetFilename("Image"..ala);
    obj8 Image.GetFilename("Image"..ali);


    if 
    obj1 == obj3 and obj2 == obj5
    and obj6 == obj8 and obj4 == obj7  then
    Dialog
    .Message("","gooooooooooooooooood");
    end 
    لما تحفظ العمل يصبح لك العمل بهذا الشكل :


    قم بالمعاينة و ارفعوا لنا تطبيقاتكم
    Comment
    • ميدو حسن
      Free Membership
      • Sep 2018 
      • 353 
      • 32 
      • 20 

      #3

      بـارك الله فيك
      Comment
      Working...
      X