Jump to content

News Reporters - Discuții / Discussions


Alexander
 Share

Recommended Posts

Ce trebuie sa faci?

 

 

Pariezi bani, daca nimeresti 4/4 aceasi manelist castigi dublul sumei pariate..

 

 

Cu + - modifici suma pariata

Cu butonu de jos dai drumu la pacanele

 

O sa refac algoritmul pentru castig..aia e partea usoara a jocului de editat

Link to comment
Share on other sites

Pariezi bani, daca nimeresti 4/4 aceasi manelist castigi dublul sumei pariate..

 

 

Cu + - modifici suma pariata

Cu butonu de jos dai drumu la pacanele

 

O sa refac algoritmul pentru castig..aia e partea usoara a jocului de editat

OOO. In ce e scris?

Link to comment
Share on other sites

OOO. In ce e scris?

 

Java.

 

 

L-ai incercat?

Daca vrei sa vezi cum arata codul jocului

 

package com.example.testa;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Rect;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Toast;

public class DesenMinge extends View {

   Bitmap btn,plus,minus,fundal,pacanele_spate,paca1,paca2,paca3,paca4,modelp1,modelp2,modelp3;
   float x,y,plus_x,plus_y,minus_x,minus_y;
   int bani_actuali=100,bani_adaugati=0;
   int[] pac=new int[6];

   boolean spin=false;
   public String text="";
   boolean egale(int a, int b, int c,int d,int e){
       if(a==e && b==e &&c==e && d==e)
           return true;
       else return false;
   }
   public void Mesaj(String txt)
   {
       Toast.makeText(getContext(), txt, Toast.LENGTH_SHORT).show();
   }
   public DesenMinge(Context context) {
       super(context);
       // TODO Auto-generated constructor stub
       btn=BitmapFactory.decodeResource(getResources(), R.drawable.buton_normal);
       plus=BitmapFactory.decodeResource(getResources(), R.drawable.plus);
       minus=BitmapFactory.decodeResource(getResources(), R.drawable.minus);
       fundal=BitmapFactory.decodeResource(getResources(), R.drawable.background);
       pacanele_spate=BitmapFactory.decodeResource(getResources(), R.drawable.pacanele_spate);
       paca1=BitmapFactory.decodeResource(getResources(), R.drawable.paca1);
       paca2=BitmapFactory.decodeResource(getResources(), R.drawable.paca1);
       paca3=BitmapFactory.decodeResource(getResources(), R.drawable.paca1);
       paca4=BitmapFactory.decodeResource(getResources(), R.drawable.paca1);
       modelp1=BitmapFactory.decodeResource(getResources(), R.drawable.paca1);
       modelp2=BitmapFactory.decodeResource(getResources(), R.drawable.paca2);
       modelp3=BitmapFactory.decodeResource(getResources(), R.drawable.paca3);
   plus_x=0;
   plus_y=0;
   minus_y=0;
   minus_x=0;
       x=10;y=10;

   }
   public static int randomInt(int bound1, int bound2) {
  	 int min = Math.min(bound1, bound2);
  	 int max = Math.max(bound1, bound2);
  	 return min + (int)(Math.random() * (max - min + 1));
   }
   public void invarte(){
       pac[1]=randomInt(1,3);
       pac[2]=randomInt(1,3);
       pac[3]=randomInt(1,3);
       pac[4]=randomInt(1,3);

       switch (pac[1]){
       case 1: paca1=modelp1; break;
       case 2: paca1=modelp2; break;
       case 3: paca1=modelp3; break;
       }
       switch (pac[2]){
       case 1: paca2=modelp1; break;
       case 2: paca2=modelp2; break;
       case 3: paca2=modelp3; break;
       }
       switch (pac[3]){
       case 1: paca3=modelp1; break;
       case 2: paca3=modelp2; break;
       case 3: paca3=modelp3; break;
       }
       switch (pac[4]){
       case 1: paca4=modelp1; break;
       case 2: paca4=modelp2; break;
       case 3: paca4=modelp3; break;
       }

   }
   public boolean coliziune(MotionEvent event,Bitmap btn,float x, float y){
         if (event.getX() >= x && event.getX() < (x + btn.getWidth())
  				 && event.getY() >= y && event.getY() < (y + btn.getHeight()))
             return true;
         else return false;
   }
   public boolean onTouchEvent(MotionEvent event){
  	 int action = event.getAction();
  	 float xx = event.getX();  // or getRawX();
  	 float yy = event.getY();



  	 switch(action){

  	 case MotionEvent.ACTION_DOWN:

           if(coliziune(event,minus,minus_x,minus_y)){
               if(bani_adaugati>=1)
                   {
                   bani_adaugati--;
                   bani_actuali++;
                   }
           }
           if(coliziune(event,plus,plus_x,plus_y)){
                   if(bani_actuali>=1)
                       {
                       bani_adaugati++;
                       bani_actuali--;
                       }

           }


           if(coliziune(event,btn,x,y)) {

               if(btn!=BitmapFactory.decodeResource(getResources(), R.drawable.buton_apasat))
               {
                   btn=BitmapFactory.decodeResource(getResources(), R.drawable.buton_apasat);
               }
               if(bani_adaugati>0)
  	         invarte();
               else
                   Mesaj("Nu ai pus niciun pariu, nu poti da drumul la pacanele.");
  		 }
  		 break;
  	 case MotionEvent.ACTION_MOVE:

           if(coliziune(event,minus,minus_x,minus_y)){
               if(bani_adaugati>=1)
                   {
                   bani_adaugati--;
                   bani_actuali++;
                   }
           }
           if(coliziune(event,plus,plus_x,plus_y)){
                   if(bani_actuali>=1)
                       {
                       bani_adaugati++;
                       bani_actuali--;
                       }
           }
  	 if(coliziune(event,btn,x,y)){
  		   if(bani_adaugati>0)  
           invarte();

  		 }
  		 break;

  	 case MotionEvent.ACTION_UP:
             if(coliziune(event,btn,x,y)){
           if(bani_adaugati>0){

               if(egale(pac[1],pac[2],pac[3],pac[4],1) || egale(pac[1],pac[2],pac[3],pac[4],2) || egale(pac[1],pac[2],pac[3],pac[4],3) ){
                   Mesaj("Felicitari! Ai castigat dublu cat ai pariat! ("+bani_adaugati*2+").");
                   bani_actuali+=bani_adaugati*2;
                   bani_adaugati=0;
               }
               else{
                   Mesaj("Ai pierdut banii pariati.");
                   bani_adaugati=0;
               }
           }
             }
           if(btn!=BitmapFactory.decodeResource(getResources(), R.drawable.buton_normal))
           {
               btn=BitmapFactory.decodeResource(getResources(), R.drawable.buton_normal);
           }
           break;
  	 }
  	 return true;
   }






   @Override
   protected void onDraw(Canvas canvas) {
       // TODO Auto-generated method stub
       super.onDraw(canvas);
       plus_x=canvas.getWidth()-plus.getWidth();
       minus_x=plus_x-plus.getWidth()-20;
       x=canvas.getWidth()-btn.getWidth();
       y=canvas.getHeight()-btn.getHeight()*1.8f;

       // text

Paint paint=new Paint();
       paint.setColor(Color.parseColor("#FFFFFF"));
       paint.setStyle(Style.FILL_AND_STROKE);
       paint.setStrokeWidth(0.5f);
       paint.setTextSize(18);

       text="Bani actuali: "+bani_actuali+" Bani adaugati: "+bani_adaugati;
       Bitmap bg=Bitmap.createScaledBitmap(fundal, canvas.getWidth(), canvas.getHeight(), false);
       canvas.drawBitmap(bg, 0, 0, new Paint());
       canvas.drawText(text, 1, 20, paint);
       String rezultat_pacanele=pac[1]+" "+pac[2]+" "+pac[3]+" "+pac[4];

        // imagine

        canvas.drawBitmap(btn, x, y, new Paint());
        canvas.drawBitmap(plus,plus_x,plus_y,new Paint());
        canvas.drawBitmap(minus,minus_x,minus_y,new Paint());
        float pcx=canvas.getWidth()/9.5f;
        float pcy=canvas.getHeight()/5.5f;
        canvas.drawBitmap(pacanele_spate, pcx,pcy, new Paint());
        canvas.drawBitmap(paca1, pcx+20, pcy+20, paint);
        canvas.drawBitmap(paca2, pcx+20+paca1.getWidth(),pcy+20,new Paint());
        canvas.drawBitmap(paca3, pcx+20+paca1.getWidth()+paca2.getWidth(),pcy+20,new Paint());
        canvas.drawBitmap(paca4, pcx+20+paca1.getWidth()+paca2.getWidth()+paca3.getWidth(),pcy+20,new Paint());
       // canvas.drawText(rezultat_pacanele,canvas.getWidth()/2,canvas.getHeight()/2,paint);

       invalidate();
   }


}

 

Edited by ZIUA VERDE UNOFFICIAL
Link to comment
Share on other sites

Pariezi bani, daca nimeresti 4/4 aceasi manelist castigi dublul sumei pariate..

 

 

Cu + - modifici suma pariata

Cu butonu de jos dai drumu la pacanele

 

O sa refac algoritmul pentru castig..aia e partea usoara a jocului de editat

 

Tocmai pe Salam l-ai nimerit? :))

Link to comment
Share on other sites

  • psoN changed the title to Discuții / Discussions
  • E l e g a n t locked this topic
  • .Aku unlocked and locked this topic
  • .Aku unlocked this topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.