Campo Minato Nel Form1 sono presenti i seguenti componenti:

Similar documents
CALCULATOR APPLICATION

You can call the project anything you like I will be calling this one project slide show.

if (say==0) { k.commandtext = "Insert into kullanici(k_adi,sifre) values('" + textbox3.text + "','" + textbox4.text + "')"; k.

CSIS 1624 CLASS TEST 6

IBSDK Quick Start Tutorial for C# 2010

Click on the empty form and apply the following options to the properties Windows.

Object oriented lab /second year / review/lecturer: yasmin maki

Start Visual Studio, start a new Windows Form project under the C# language, name the project BalloonPop MooICT and click OK.

Now find the button component in the tool box. [if toolbox isn't present click VIEW on the top and click toolbox]

Main Game Code. //ok honestly im not sure, if i guess its a class ment for this page called methodtimer that //either uses the timer or set to timer..

Form Properties Window

We are going to use some graphics and found a nice little batman running GIF, off course you can use any image you want for the project.

Start Visual Studio, create a new project called Helicopter Game and press OK

Start Visual Studio and create a new windows form application under C# programming language. Call this project YouTube Alarm Clock.

C:\homeworks\PenAttention_v13_src\PenAttention_v13_src\PenAttention4\PenAttention\PenAttention.cs 1 using System; 2 using System.Diagnostics; 3 using

The Open Core Interface SDK has to be installed on your development computer. The SDK can be downloaded at:

Create your own Meme Maker in C#

// Specify SEF file to load. edischema oschema = oedidoc.loadschema(spath + sseffilename, SchemaTypeIDConstants. Schema_Standard_Exchange_Format);

Visual Basic/C# Programming (330)

// Specify SEF file to load. oschema = (edischema) oedidoc.loadschema(spath + sseffilename, SchemaTypeIDConstants. Schema_Standard_Exchange_Format);

APARAT DE MASURA. Descrierea programului

Chapter 6 Dialogs. Creating a Dialog Style Form

This is the empty form we will be working with in this game. Look under the properties window and find the following and change them.

} } public void getir() { DataTable dt = vt.dtgetir("select* from stok order by stokadi");

Mainly three tables namely Teacher, Student and Class for small database of a school. are used. The snapshots of all three tables are shown below.

Programmi di utilità

To start we will be using visual studio Start a new C# windows form application project and name it motivational quotes viewer

เว บแอพล เคช น. private void Back_Click(object sender, EventArgs e) { this.webbrowser2.goback(); }

First start a new Windows Form Application from C# and name it Interest Calculator. We need 3 text boxes. 4 labels. 1 button

Projects A.A. 2012/2013. Main topics for projects and

Huw Talliss Data Structures and Variables. Variables

Visual Basic/C# Programming (330)

Fondamenti di Informatica C. Lezione 24: Dentro le applet

FARI LAMPS. Copyright 2017 EUROCAR TOGLIANI s.r.l.

Class Test 4. Question 1. Use notepad to create a console application that displays a stick figure. See figure 1. Question 2

C# winforms gridview

Using Template Bookmarks for Automating Microsoft Word Reports

Chapter 3 Transport Layer

string spath; string sedifile = "277_005010X228.X12"; string sseffile = "277_005010X228.SemRef.EVAL0.SEF";

XNA 4.0 RPG Tutorials. Part 24. Level Editor Continued

Developing for Mobile Devices Lab (Part 1 of 2)

create database ABCD use ABCD create table bolumler ( bolumkodu int primary key, bolumadi varchar(20) )

LIGHT_P_TOGGLE, LIGHT_N_TOGGLE, BATTERY_TOGGLE, ALTERNATOR_TOGGLE, AVIONICS_TOGGLE, FLOAT_RETRACT, FLOAT_EXTEND }

Experiment 5 : Creating a Windows application to interface with 7-Segment LED display

// Precondition: None // Postcondition: The address' name has been set to the // specified value set;

II. Programming Technologies

Il vero osso duro è rappresentato dall'inattività degli studenti, sia in aula che a casa: seguono poco e non fanno esercizi.

namespace Gen837X222A1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

Eyes of the Dragon - XNA Part 37 Map Editor Revisited

namespace spojneice { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

Class Test 5. Create a simple paint program that conforms to the following requirements.

namespace csharp_gen277x214 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

Representing Recursive Relationships Using REP++ TreeView

APÉNDICE J. CÓDIGO DEL ARCHIVO FORM1.CS EN LENGUAJE C# Comprende:

namespace csharp_gen837x223a2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

The Gracefulness of the Merging Graph N ** C 4 with Dotnet Framework

بسم هللا الرحمن الرحيم المحاضرة السابعة مستوى ثالث علوم حاسوب برمجة مرئية 2 )عملي ) جامعة الجزيرة محافظة اب الجمهورية اليمنية النافذة الرئيسية

Chapter 12. Tool Strips, Status Strips, and Splitters

Sass: Syntactically Awesome Stylesheet. Laura Farinetti Dipartimento di Automatica e Informatica Politecnico di Torino

Your Company Name. Tel: Fax: Microsoft Visual Studio C# Project Source Code Output

Implementazione Java di Alberi Binari. A.A. 16/17 DA1 - Andrea Pietracaprina 1

Examples. Products. W informs Controls > Products > Navigation Bar > Examples. This topic provides how -to examples, grouped by features.

Conventions in this tutorial

Esempi di programmi client/server in Python 2

Writing Your First Autodesk Revit Model Review Plug-In

Istruzioni passo passo per creare qualsiasi CUSTOM AWARD con BBLogger How to create step by step any CUSTOM AWARD by BBLogger

XNA 4.0 RPG Tutorials. Part 11b. Game Editors

GESTIONE DEL BACKGROUND. Programmazione Web 1

Answer on Question# Programming, C#

Computer Networks II

namespace Tst_Form { private: /// <summary> /// Required designer variable. /// </summary> System::ComponentModel::Container ^components;

MW MOC SUPPORTING AND TROUBLESHOOTING WINDOWS 10

عنوان مقاله : خواندن و نوشتن محتوای فایل های Excel بدون استفاده ازAutomation Excel تهیه وتنظیم کننده : مرجع تخصصی برنامه نویسان

Basic Concepts. Based on original slides by Silberschatz, Galvin, Gagne, and Anastasi. PerLab

Визуал програмчлал. Багш: Ж. Шинэбаяр /Маг/

2.3 Add GDS Google Map to Visual Studio Toolbox and create a simple map project

Overview. Building a Web-Enabled Decision Support System. Integrating DSS in Business Curriculum. Introduction to DatabaseSupport Systems

Model JI-4040 USB Multifunction Digital I/O Module - Isolated. Programmer s Interface Document

UNIT-3. Prepared by R.VINODINI 1

Concurrency in JavaFX. Tecniche di Programmazione A.A. 2014/2015

Classes in C# namespace classtest { public class myclass { public myclass() { } } }

Chapter 13 Working with Threads

MOC20741 Networking with Windows Server 2016

FDSc in ICT. Building a Program in C#

Lists. Problem. Store a set of unique words (duplicates shall be ignored) Class interface 4/23/2013. Arrays reloaded

Tutorial 6 Enhancing the Inventory Application Introducing Variables, Memory Concepts and Arithmetic

ANALISI DELLE CORRISPONDENZE IN R

pojedinačnom elementu niza se pristupa imeniza[indeks] indeks od 0 do n-1

Tutorial 5 Completing the Inventory Application Introducing Programming

Appendix A Programkod

private string sconnection = ConfigurationManager.ConnectionStrings["Development"].ConnectionString

Hands-On Lab. Lab: Client Object Model. Lab version: Last updated: 2/23/2011

Lists. Problem. Store a set of unique words (duplicates shall be ignored) Class interface 3/1/2016. Arrays reloaded

Step 1: Start a GUI Project. Start->New Project->Visual C# ->Windows Forms Application. Name: Wack-A-Gopher. Step 2: Add Content

Lecture 8 Building an MDI Application

XNA 4.0 RPG Tutorials. Part 3. Even More Core Game Components

Introduction to Visual Studio and C#

Chapter 8 Advanced GUI Features

Inheriting Windows Forms with Visual C#.NET

FIT 2R. design Serge & Robert Cornelissen TRIMLESS FRAME

Transcription:

Campo Minato Nel Form1 sono presenti i seguenti componenti: menustrip1 panel1 picturebox1 label_livello panel2 menustrip1 button_unknown button_free button_fall button_quest button_expl button_bomb Il codice è il seguente: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; /********************************************************************************* * PROGETTO: CAMPO MINATO ******************************************************** * SCUOLA: ITI G.M. ANGIOY SASSARI ********************************************** * CLASSE: IV A INFORMATICA - A.S. 2013/14 *************************************** * DOCENTI: Prof. M. Cherchi, Prof. A. Zoccheddu ********************************* * STUDENTI: Gnocchi Domenica, Piano Guido, Carta Bianca ************************* * ******************************************************************************/ namespace CampoMinato 1

public partial class Form1 : Form static Random estrai = new Random(); static int max_ri = 8; static int max_co = 8; static int num_mine = 16; static Campo campo; static Button bt_unknown, bt_free, bt_fall, bt_quest, bt_bomb, bt_expl; public class MyCell : Button const int dim = 25; public bool bomb; public int stato; //0==scoprire, 1==libero, 2==bloccato, public bool controllato; public MyCell(int top, int left) : base() this.bomb = false; this.stato = 0; //libero this.controllato = false; this.top = dim*top + 5; this.left = dim * left + 5; this.height = dim; this.width = dim; this.image = bt_unknown.image; this.forecolor = Color.White; this.font = new Font("Consolas", 12, FontStyle.Bold); //il costruttore imposta il delegato gestore di evento clic sinistro this.click += delegate(object sender, EventArgs e) if (this.stato == 0) //da scoprire if (this.mytag() == "1") //c'è una bomba //sconfitta campo.sconfitta(top, left); else 2

//gioca this.image = bt_free.image; this.stato = 1; //libero campo.mosse--; campo.verificavittoria(); campo.scopri(top, left); ; //il costruttore imposta il delegato gestore di evento clic destro this.mousedown += delegate(object sender, MouseEventArgs e) if (e.button == System.Windows.Forms.MouseButtons.Right) switch (this.stato) case 0: //era libero this.stato = 2; //bloccato this.image = bt_quest.image; return; case 2: this.stato = 0; //libero this.image = bt_unknown.image; return; //switch ; //costruttore public string MyTag() if (this.bomb) return "1"; else return "0"; //class MyCell ************************************************* 3

public class Campo public MyCell[,] griglia; public int mosse; public Campo() griglia = new MyCell[max_ri, max_co]; for (int ri = 0; ri < max_ri; ri++) for (int co = 0; co < max_co; co++) griglia[ri, co] = new MyCell(ri, co); this.minare(); //constructor private void Minare() int minecount = num_mine; //numero mine da posizionare while (minecount > 0) int ri = estrai.next(0,max_ri); int co = estrai.next(0, max_co); if (griglia[ri, co].bomb == false) griglia[ri, co].bomb = true; //mette bomba minecount--; mosse = (max_co*max_ri) - num_mine; //mosse disponibili //method Minare() 4

public void Sconfitta(int r, int c) //Close(); for (int ri = 0; ri < max_ri; ri++) for (int co = 0; co < max_co; co++) griglia[ri, co].stato = 2; if (griglia[ri, co].mytag() == "1") griglia[ri, co].backcolor = Color.Black; griglia[ri, co].image = bt_bomb.image; else griglia[ri, co].backcolor = Color.Green; griglia[ri, co].image = bt_free.image; griglia[r, c].backcolor = Color.Maroon; //griglia[r, c].image = bt_expl.image; MessageBox.Show("Hai perso!"); public void VerificaVittoria() if (mosse == 0) this.vittoria(); public void Vittoria() MessageBox.Show("Hai vinto!"); 5

public void Scopri(int ri, int co) griglia[ri, co].image = bt_free.image; griglia[ri, co].stato = 1; //libero griglia[ri, co].text = "" + this.calcola(ri, co); if (griglia[ri, co].text == "0") for (int r = ri - 1; r <= ri + 1; r++) for (int c = co - 1; c <= co + 1; c++) if ((r >= 0) && (r < max_ri) && (c >= 0) && (c < max_co) && ((r!= ri) (c!= co))) if ( (griglia[r, c].stato == 0)//libero && (griglia[r, c].controllato == false)) Scopri(r, c); //chiamata ricorsiva!!! public int Calcola(int ri, int co) int cont = 0; for (int r = ri - 1; r <= ri + 1; r++) for (int c = co - 1; c <= co + 1; c++) if ((r >= 0) && (r < max_ri) && (c >= 0) && (c < max_co) && ((r!= ri) (c!= co))) if (griglia[r, c].mytag() == "1") cont++; return cont; 6

//************************************************metodi public void Inizio() Width = max_co * 25 + 17; Height = max_ri * 25 + 87; panel1.backcolor = Color.PaleGreen; panel2.backcolor = Color.Green; StartPosition = FormStartPosition.CenterScreen; panel2.controls.clear(); label_livello.text = "Bombe nascoste: " + num_mine; public void Crea_Griglia() campo = new Campo(); panel2.controls.clear(); for (int ri = 0; ri < max_ri; ri++) for (int co = 0; co < max_co; co++) panel2.controls.add(campo.griglia[ri,co]); public void Livello(int liv) max_ri = liv; max_co = liv; switch (liv) case 8: num_mine = liv * 2; break; case 12: num_mine = liv * 2; break; case 16: num_mine = liv * 3; break; case 20: num_mine = liv * 4; break; Inizio(); //Livello() 7

//************************************************gestori eventi public Form1() InitializeComponent(); private void Form1_Load(object sender, EventArgs e) //impostazioni base finestra FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; //creazione campo di gioco Inizio(); // static Button bt_unknown, bt_free, bt_fall, bt_quest, bt_bomb; bt_unknown = button_unknown; bt_free = button_free; bt_fall = button_fall; bt_quest = button_quest; bt_bomb = button_bomb; bt_expl = button_expl; 8

private void iniziotoolstripmenuitem_click(object sender, EventArgs e) Crea_Griglia(); private void grazietoolstripmenuitem_click(object sender, EventArgs e) Grazie ringraziamenti = new Grazie(); ringraziamenti.showdialog(); private void escitoolstripmenuitem_click(object sender, EventArgs e) Close(); private void picturebox1_click(object sender, EventArgs e) Crea_Griglia(); //Form1 //namespace private void intermediotoolstripmenuitem_click(object sender, EventArgs e) Livello(12); private void veteranotoolstripmenuitem_click(object sender, EventArgs e) Livello(16); private void espertotoolstripmenuitem_click(object sender, EventArgs e) Livello(20); 9

Al progetto è stato aggiunto un secondo form informativo per i ringraziamenti: In un progetto si dovrebbe sempre: 1) Citare le fonti da cui si è tratto parte del codice software, anche se parziale e che deve essere senza copyright restrittivi 2) Citare le fonti delle risorse come immagini, suoni, video, pagine web, ecc 3) Citare la scuola e i docenti che hanno assistito gli studenti, anche se solo parzialmente o moralmente 4) Indicare i nomi degli autori e i link per i contatti 10