tag:blogger.com,1999:blog-55758858105630186882024-03-12T16:10:08.230-07:00chia sẻ kinh nghiệm - học hỏinguyendangtuan95@gmail.comhttp://www.blogger.com/profile/11769458566723493488noreply@blogger.comBlogger15125tag:blogger.com,1999:blog-5575885810563018688.post-40254101589835012862013-08-14T09:21:00.003-07:002013-08-14T09:21:31.388-07:00Chúng ta không chỉ có một mình<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">Hôm trước đã nói tới chuyện thông qua command mà điểu khiển một biến robot rồi, hôm nay cũng với command và robot này nhưng chúng ta không chỉ điều khiển một mà là nhiều. tức là khi viết lệnh chúng ta viết cho nhiều robot và với phân cách là dấu chấm (.) có bao nhiêu lệnh thì có bấy nhiêu biến robot được vẽ trên màn hình. Hãy xét một lệnh tổng hợp ví dụ như sau: 1 robot: string,x,y Nhiều robot: string1,x1,y1.srting,x2,y2.string3,x3,y3.(string_n,x_n,y_n) Giả sử ta có lệnh tổng hợp sau: Abc,10,50.bcd,30,100.def,120,5 vậy là ta có 3 biến robot được tạo ra và màn hình sẽ thực hiện việc vẽ 3 biến này lên màn hình. Để làm như vậy, bây giờ ta sẽ sử dụng biến rb là một Vector của lớp robot Ta đặt: Vector rb; Chưa vội gán giá trị cho nó bao nhiêu đối tượng mà ta sẽ phân tích từ lệnh. Lớp canvas.java sẽ như thế này:</span><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;"></span><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;"></span><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;"></span><br />
<table style="background-color: #e9e8e2; color: black; font-family: Monospaced; font-size: 14px; line-height: 20px; width: 100%px;"><tbody>
<tr><td align="center">C:\Users\WIN7\Documents\NetBeansProjects\mog\src\mog.java</td></tr>
</tbody></table>
<pre style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;"><span class="keyword-directive" style="color: #0000e6;">import</span> javax.microedition.midlet.*;
<span class="keyword-directive" style="color: #0000e6;">import</span> javax.microedition.lcdui.*;
<span class="keyword-directive" style="color: #0000e6;">import</span> java.util.*;
<span class="keyword-directive" style="color: #0000e6;">public</span> <span class="keyword-directive" style="color: #0000e6;">class</span> <span class="ST0" style="font-weight: bold;">mog</span> <span class="keyword-directive" style="color: #0000e6;">extends</span> MIDlet {
<span class="keyword-directive" style="color: #0000e6;">public</span> <span class="keyword-directive" style="color: #0000e6;">void</span> <span class="ST0" style="font-weight: bold;">startApp</span>(){
Display.<span class="ST1" style="color: #009900; font-style: italic;">getDisplay</span>(<span class="keyword-directive" style="color: #0000e6;">this</span>).setCurrent(<span class="keyword-directive" style="color: #0000e6;">new</span> canvas());}
<span class="keyword-directive" style="color: #0000e6;">public</span> <span class="keyword-directive" style="color: #0000e6;">void</span> <span class="ST0" style="font-weight: bold;">destroyApp</span>(<span class="keyword-directive" style="color: #0000e6;">boolean</span> t){}
<span class="keyword-directive" style="color: #0000e6;">public</span> <span class="keyword-directive" style="color: #0000e6;">void</span> <span class="ST0" style="font-weight: bold;">pauseApp</span>(){}}
<span class="keyword-directive" style="color: #0000e6;">class</span> <span class="ST0" style="font-weight: bold;">canvas</span> <span class="keyword-directive" style="color: #0000e6;">extends</span> Canvas{
textfield <span class="ST2" style="color: #009900; font-style: italic;">tf</span>;
Vector <span class="ST2" style="color: #009900; font-style: italic;">rb</span>=<span class="keyword-directive" style="color: #0000e6;">new</span> Vector();
Font <span class="ST2" style="color: #009900; font-style: italic;">f</span>=Font.<span class="ST1" style="color: #009900; font-style: italic;">getFont</span>(0,0,8);
<span class="keyword-directive" style="color: #0000e6;">int</span> <span class="ST2" style="color: #009900; font-style: italic;">w</span>,<span class="ST2" style="color: #009900; font-style: italic;">h</span>,<span class="ST2" style="color: #009900; font-style: italic;">k</span>=0,<span class="ST2" style="color: #009900; font-style: italic;">fh</span>;
String <span class="ST2" style="color: #009900; font-style: italic;">command</span>=<span class="character" style="color: #ce7b00;">""</span>;
<span class="keyword-directive" style="color: #0000e6;">public</span> <span class="ST0" style="font-weight: bold;">canvas</span>(){
setFullScreenMode(<span class="keyword-directive" style="color: #0000e6;">true</span>);
<span class="ST2" style="color: #009900; font-style: italic;">w</span>=getWidth();
<span class="ST2" style="color: #009900; font-style: italic;">h</span>=getHeight();
<span class="ST2" style="color: #009900; font-style: italic;">fh</span>=<span class="ST2" style="color: #009900; font-style: italic;">f</span>.getHeight();
<span class="ST2" style="color: #009900; font-style: italic;">tf</span>=<span class="keyword-directive" style="color: #0000e6;">new</span> textfield(<span class="character" style="color: #ce7b00;">"</span><span class="character" style="color: #ce7b00;">command</span><span class="character" style="color: #ce7b00;">"</span>,0,0,<span class="ST2" style="color: #009900; font-style: italic;">w</span>);
}
<span class="keyword-directive" style="color: #0000e6;">public</span> <span class="keyword-directive" style="color: #0000e6;">void</span> <span class="ST0" style="font-weight: bold;">paint</span>(Graphics g){
g.setFont(<span class="ST2" style="color: #009900; font-style: italic;">f</span>);
g.setColor(0);
g.fillRect(0,0,<span class="ST2" style="color: #009900; font-style: italic;">w</span>,<span class="ST2" style="color: #009900; font-style: italic;">h</span>);
<span class="ST2" style="color: #009900; font-style: italic;">tf</span>.paint(g,<span class="ST2" style="color: #009900; font-style: italic;">k</span>,<span class="keyword-directive" style="color: #0000e6;">true</span>);
g.setColor(0xf0f0);
g.setClip(0,0,<span class="ST2" style="color: #009900; font-style: italic;">w</span>,<span class="ST2" style="color: #009900; font-style: italic;">h</span>);
g.drawString(<span class="ST2" style="color: #009900; font-style: italic;">command</span>,0,<span class="ST2" style="color: #009900; font-style: italic;">fh</span>*2,Graphics.<span class="ST3" style="color: #009900; font-style: italic;">TOP</span>|Graphics.<span class="ST3" style="color: #009900; font-style: italic;">LEFT</span>);
<span class="keyword-directive" style="color: #0000e6;">if</span>(<span class="ST2" style="color: #009900; font-style: italic;">rb</span>!=<span class="keyword-directive" style="color: #0000e6;">null</span>)
<span class="keyword-directive" style="color: #0000e6;">for</span>(<span class="keyword-directive" style="color: #0000e6;">int</span> i=0;i<<span class="ST2" style="color: #009900; font-style: italic;">rb</span>.size();i++)
((robot)<span class="ST2" style="color: #009900; font-style: italic;">rb</span>.elementAt(i)).paint(g);
<span class="ST2" style="color: #009900; font-style: italic;">k</span>=0;
repaint();
}
<span class="keyword-directive" style="color: #0000e6;">public</span> <span class="keyword-directive" style="color: #0000e6;">void</span> <span class="ST0" style="font-weight: bold;">keyPressed</span>(<span class="keyword-directive" style="color: #0000e6;">int</span> k){
<span class="keyword-directive" style="color: #0000e6;">this</span>.<span class="ST2" style="color: #009900; font-style: italic;">k</span>=k;
<span class="keyword-directive" style="color: #0000e6;">if</span>(k==-5){
<span class="ST2" style="color: #009900; font-style: italic;">command</span>=<span class="ST2" style="color: #009900; font-style: italic;">tf</span>.getString();
String[] acommand=tach(<span class="ST2" style="color: #009900; font-style: italic;">command</span>,<span class="character" style="color: #ce7b00;">"</span><span class="character" style="color: #ce7b00;">.</span><span class="character" style="color: #ce7b00;">"</span>);
<span class="keyword-directive" style="color: #0000e6;">for</span>(<span class="keyword-directive" style="color: #0000e6;">int</span> i=0;i<acommand.<span class="ST2" style="color: #009900; font-style: italic;">length</span>;i++){
robot nrb=<span class="keyword-directive" style="color: #0000e6;">new</span> robot(<span class="ST2" style="color: #009900; font-style: italic;">w</span>/2,<span class="ST2" style="color: #009900; font-style: italic;">h</span>/2);
nrb.getcommand(tach(acommand[i],<span class="character" style="color: #ce7b00;">"</span><span class="character" style="color: #ce7b00;">,</span><span class="character" style="color: #ce7b00;">"</span>));
<span class="ST2" style="color: #009900; font-style: italic;">rb</span>.addElement((robot)nrb);}}}
<span class="keyword-directive" style="color: #0000e6;">public</span> <span class="keyword-directive" style="color: #0000e6;">void</span> <span class="ST0" style="font-weight: bold;">keyReleased</span>(<span class="keyword-directive" style="color: #0000e6;">int</span> k){<span class="keyword-directive" style="color: #0000e6;">this</span>.<span class="ST2" style="color: #009900; font-style: italic;">k</span>=0;}
<span class="keyword-directive" style="color: #0000e6;">public</span> String[] <span class="ST0" style="font-weight: bold;">tach</span>(String s,String c){
Vector v=<span class="keyword-directive" style="color: #0000e6;">new</span> Vector();
<span class="keyword-directive" style="color: #0000e6;">if</span>(!s.endsWith(c)){s+=c;}
<span class="keyword-directive" style="color: #0000e6;">int</span> st=0,np=s.indexOf(c,st);
<span class="keyword-directive" style="color: #0000e6;">while</span>(np!=-1){
v.addElement((String)s.substring(st,np));
st=np+c.length();
np=s.indexOf(c,st);}
String[] rt=<span class="keyword-directive" style="color: #0000e6;">new</span> String[v.size()];
v.copyInto((String[])rt);
<span class="keyword-directive" style="color: #0000e6;">for</span>(<span class="keyword-directive" style="color: #0000e6;">int</span> i=0;i<rt.<span class="ST2" style="color: #009900; font-style: italic;">length</span>;i++){System.<span class="ST3" style="color: #009900; font-style: italic;">out</span>.println(rt[i]+rt[i].length());}
<span class="keyword-directive" style="color: #0000e6;">return</span> rt;}
}
<span class="keyword-directive" style="color: #0000e6;">class</span> <span class="ST0" style="font-weight: bold;">robot</span>{
<span class="keyword-directive" style="color: #0000e6;">int</span> <span class="ST2" style="color: #009900; font-style: italic;">x</span>,<span class="ST2" style="color: #009900; font-style: italic;">y</span>,<span class="ST2" style="color: #009900; font-style: italic;">nx</span>,<span class="ST2" style="color: #009900; font-style: italic;">ny</span>;
String <span class="ST2" style="color: #009900; font-style: italic;">say</span>;
<span class="keyword-directive" style="color: #0000e6;">long</span> <span class="ST2" style="color: #009900; font-style: italic;">lm</span>=0;
<span class="keyword-directive" style="color: #0000e6;">public</span> <span class="ST0" style="font-weight: bold;">robot</span>(<span class="keyword-directive" style="color: #0000e6;">int</span> x,<span class="keyword-directive" style="color: #0000e6;">int</span> y){
<span class="keyword-directive" style="color: #0000e6;">this</span>.<span class="ST2" style="color: #009900; font-style: italic;">x</span>=x;
<span class="keyword-directive" style="color: #0000e6;">this</span>.<span class="ST2" style="color: #009900; font-style: italic;">y</span>=y;
<span class="keyword-directive" style="color: #0000e6;">this</span>.<span class="ST2" style="color: #009900; font-style: italic;">nx</span>=x;
<span class="keyword-directive" style="color: #0000e6;">this</span>.<span class="ST2" style="color: #009900; font-style: italic;">ny</span>=y;
}
<span class="keyword-directive" style="color: #0000e6;">public</span> <span class="keyword-directive" style="color: #0000e6;">void</span> <span class="ST0" style="font-weight: bold;">getcommand</span>(String[] s){
<span class="ST2" style="color: #009900; font-style: italic;">say</span>=s[0];
<span class="ST2" style="color: #009900; font-style: italic;">nx</span>=Integer.<span class="ST1" style="color: #009900; font-style: italic;">parseInt</span>(s[1]);
<span class="ST2" style="color: #009900; font-style: italic;">ny</span>=Integer.<span class="ST1" style="color: #009900; font-style: italic;">parseInt</span>(s[2]);
}
<span class="keyword-directive" style="color: #0000e6;">public</span> <span class="keyword-directive" style="color: #0000e6;">void</span> <span class="ST0" style="font-weight: bold;">paint</span>(Graphics g){
<span class="keyword-directive" style="color: #0000e6;">if</span>(System.<span class="ST1" style="color: #009900; font-style: italic;">currentTimeMillis</span>()-<span class="ST2" style="color: #009900; font-style: italic;">lm</span>>200)
move();
g.setColor(0xf000f0);
g.fillRect(<span class="ST2" style="color: #009900; font-style: italic;">x</span>,<span class="ST2" style="color: #009900; font-style: italic;">y</span>,16,16);
}
<span class="keyword-directive" style="color: #0000e6;">void</span> <span class="ST0" style="font-weight: bold;">move</span>(){
<span class="ST2" style="color: #009900; font-style: italic;">x</span>+=<span class="ST2" style="color: #009900; font-style: italic;">x</span>><span class="ST2" style="color: #009900; font-style: italic;">nx</span>?-1:(<span class="ST2" style="color: #009900; font-style: italic;">x</span>==<span class="ST2" style="color: #009900; font-style: italic;">nx</span>?0:1);
<span class="ST2" style="color: #009900; font-style: italic;">y</span>+=<span class="ST2" style="color: #009900; font-style: italic;">y</span>><span class="ST2" style="color: #009900; font-style: italic;">ny</span>?-1:(<span class="ST2" style="color: #009900; font-style: italic;">y</span>==<span class="ST2" style="color: #009900; font-style: italic;">ny</span>?0:1);}
}
</pre>
<span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">• Như chúng ta thấy đó, sau khi ta nhấn phím 5, lệnh sẽ được lấy ra từ textfield (tf) và phân tích thành mảng của các lệnh con qua String[] acommand=tach(command,"."); • Và sau đó lại được phân tích và gán vào biến robot bình thường. for(int i=0;i</span><acommand .length="" 2="" 4.01="" a.="" a="" acmmand="" acommand="" ang="" b="" bi="" c.="" c="" canvas.java="" ch="" cho="" chu="" chuy="" d="" di="" doctype="" dtd="" en="" gi="" h="" html4="" html="" http:="" i="" keypressed="" kh="" khi="" l="" m="" n="" ng="" nh="" nhi="" nrb.getcommand="" nrb="" o="" p="" public="" rb.addelement="" rb="" robot="" s="" sau="" strict.dtd="" style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" t="" ta="" tach="" th="" theo="" ti="" tr="" u="" v="" vector="" w3c="" w="" www.w3.org="" y:="" y=""></acommand><br />
<table style="background-color: #e9e8e2; color: black; font-family: Monospaced; width: 100%px;"><tbody>
<tr><td align="center">C:\Users\WIN7\Documents\NetBeansProjects\mog\src\mog.java</td></tr>
</tbody></table>
<pre style="background-color: white; font-family: Monospaced;"><span class="keyword-directive" style="color: #0000e6;">public</span> <span class="keyword-directive" style="color: #0000e6;">void</span> <span class="ST0" style="font-weight: bold;">keyPressed</span>(<span class="keyword-directive" style="color: #0000e6;">int</span> k){
<span class="keyword-directive" style="color: #0000e6;">this</span>.<span class="ST2" style="color: #009900; font-style: italic;">k</span>=k;
<span class="keyword-directive" style="color: #0000e6;">if</span>(k==-5){
<span class="ST2" style="color: #009900; font-style: italic;">command</span>=<span class="ST2" style="color: #009900; font-style: italic;">tf</span>.getString();
String[] acommand=tach(<span class="ST2" style="color: #009900; font-style: italic;">command</span>,<span class="character" style="color: #ce7b00;">"</span><span class="character" style="color: #ce7b00;">.</span><span class="character" style="color: #ce7b00;">"</span>);
Vector trb=<span class="keyword-directive" style="color: #0000e6;">new</span> Vector();
<span class="keyword-directive" style="color: #0000e6;">for</span>(<span class="keyword-directive" style="color: #0000e6;">int</span> i=0;i<acommand.<span class="ST2" style="color: #009900; font-style: italic;">length</span>;i++){
String[] info=tach(acommand[i],<span class="character" style="color: #ce7b00;">"</span><span class="character" style="color: #ce7b00;">,</span><span class="character" style="color: #ce7b00;">"</span>);
robot nrb=<span class="keyword-directive" style="color: #0000e6;">new</span> robot(<span class="ST2" style="color: #009900; font-style: italic;">w</span>/2,<span class="ST2" style="color: #009900; font-style: italic;">h</span>/2);
<span class="keyword-directive" style="color: #0000e6;">for</span>(<span class="keyword-directive" style="color: #0000e6;">int</span> j=0;j<<span class="ST2" style="color: #009900; font-style: italic;">rb</span>.size();j++){
<span class="keyword-directive" style="color: #0000e6;">if</span>(info[0].equals(((robot)<span class="ST2" style="color: #009900; font-style: italic;">rb</span>.elementAt(j)).<span class="ST2" style="color: #009900; font-style: italic;">say</span>)){nrb=(robot)<span class="ST2" style="color: #009900; font-style: italic;">rb</span>.elementAt(j);
System.<span class="ST3" style="color: #009900; font-style: italic;">out</span>.println(<span class="character" style="color: #ce7b00;">"</span><span class="character" style="color: #ce7b00;">dectect</span><span class="character" style="color: #ce7b00;">"</span>);}}
nrb.getcommand(info);
trb.addElement((robot)nrb);}
<span class="ST2" style="color: #009900; font-style: italic;">rb</span>=trb;}}
}
</pre>
<acommand .length="" 2="" 4.01="" a.="" a="" acmmand="" acommand="" ang="" b="" bi="" c.="" c="" canvas.java="" ch="" cho="" chu="" chuy="" d="" di="" doctype="" dtd="" en="" gi="" h="" html4="" html="" http:="" i="" keypressed="" kh="" khi="" l="" m="" n="" ng="" nh="" nhi="" nrb.getcommand="" nrb="" o="" p="" public="" rb.addelement="" rb="" robot="" s="" sau="" strict.dtd="" style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" t="" ta="" tach="" th="" theo="" ti="" tr="" u="" v="" vector="" w3c="" w="" www.w3.org="" y:="" y="">• Lúc này ta cần tạo thêm một biến trb dùng để tạo một vùng thêm các biến robot vào và so sánh với biến rb cũ, nếu không làm như vậy mà thêm trực tiếp vào biến cũ ta sẽ không thể nào kiểm soát được các đối tượng mà ta đã ra lệnh trước đó. • Bài này vậy là xong, nếu đến đây các bạn vẫn chưa hiểu được là ta đang làm cái gì thì bài sau các bạn sẽ rõ. Đây không phải chỉ là chuyện rèn kỹ năng giải thuật mà nó phải có sử dụng thực tế. <a href="http://holyeyed.99k.org/function/up/mog-72176.zip" style="color: #993322; text-decoration: none;">Tải zip</a></acommand></div>
nguyendangtuan95@gmail.comhttp://www.blogger.com/profile/11769458566723493488noreply@blogger.com0tag:blogger.com,1999:blog-5575885810563018688.post-57405384334571951842013-08-14T09:19:00.001-07:002013-08-14T09:19:50.963-07:00Đi lệch quỹ đạo<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">một lập trình viên thường không thể nào kiểm soát hết mọi trường hợp có thể xảy ra trong thực tế, dù rằng đó là ứng dụng do chính họ tạo ra. một thế giới nhỏ bé cũng có những sự cố của chính nó, tôi cũng gặp nhiều những sự cố như vậy, tôi cố gắng sửa chữa chúng nhưng dường như cứ để như vậy thì lại hay hơn. mình có thề sửa cái này vì nó ngay trước mặt mình nhưng còn những thứ không bao giờ hiện ra ngay trước mắt. tôi không biết mình có đi lệch quỹ đạo hay không và thật sự đâu là quĩ đạo của chính tôi. dù sao thì tôi cũng sống cho chính bản thân mình và không chịu sự điều khiển của ai cả, nếu như tôi không còn là tôi của những ngày ban đầu thì tôi vẫn đi trong chính con đường của mình chứ không ai khác. trong những gì mà ta đầu tư cũng có thể bỏ đi hết, nếu tự nhiên có thứ gì đó thu hút ta hơn. tôi thường xem việc lập trình hoặc là viết bài hướng dẫn như là một sự giải thoát khỏi sự chán nản của cuộc sống nhưng thỉnh thoảng cái cô độc vẫn ám ảnh tôi nhiều hơn. và bây giờ tôi muốn nói gì đó cho nó khuây khỏa, muốn quên đi những thứ mà tôi chưa kịp hoàn thành. bế tắc trong bất cứ chuyện gì cũng không có nghĩa lí gì hết nếu như có một cái gì đó cho ta nhìn ra ngoài. hãy thử tưởng tượng khi bạn đang cố gắng suy nghĩ về cuộc đời mình rồi sẽ ra sao và có một người đến nói với bạn rằng hãy đi chơi với họ thì bạn sẽ nghĩ sao. tự nhiên ta sẽ quên hết mọi thứ đang dang dở và hào hứng đến với họ hơn là việc ta đang làm. tôi không biết, thường thì tôi sẽ làm vậy, và ngay cả trong việc viết hướng dẫn như thế này tôi cũng không muốn bó buộc vào điều gì hết, đừng phiền lòng nếu như bài biết này làm phí thời gian của bạn, vì nó là những gì mà tôi thấy là có ý nghĩa với một vài người và ít nhất là đối với tôi. nhiều khi nằm trên giường và nhìn ra ngoài cửa sổ tôi lại thấy nó như hấp dẫn tôi rất nhiều, tôi thích nhìn chỉ một góc như vậy và suy nghĩ xem những phần còn lại của thế giới đang diễn ra như thế nào. hay chuyện vào một thời gian nào đó bạn nghĩ về một người bạn của mình hiện giờ đang làm gì và như thế nào, có những chuyện gì làm cho họ buồn hay vui và họ có nhớ tới bạn không. thật sự là ta có thể nghĩ đến hàng vô số những chuyện xảy ra trên thế giới này và mọi thứ điều tuyệt diệu.</span><br />
<div class="separator" style="background-color: white; clear: both; font-family: Monospaced; font-size: 14px; line-height: 20px; text-align: center;">
<a href="http://www.questpcs.com/exteriors/httpdocs/images/WindowTypes/picture_window.jpg" imageanchor="1" style="color: #993322; margin-left: 1em; margin-right: 1em; text-decoration: none;"><img border="0" height="309" src="http://www.questpcs.com/exteriors/httpdocs/images/WindowTypes/picture_window.jpg" style="-webkit-box-shadow: rgba(0, 0, 0, 0.498039) 1px 1px 5px; border: none; box-shadow: rgba(0, 0, 0, 0.498039) 1px 1px 5px; padding: 8px; position: relative;" width="400" /></a></div>
<span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">"hãy thử nhìn xung quanh và nghĩ xem điều gì đang diễn ra ở đó"</span></div>
nguyendangtuan95@gmail.comhttp://www.blogger.com/profile/11769458566723493488noreply@blogger.com0tag:blogger.com,1999:blog-5575885810563018688.post-55748108306977897042013-08-14T09:18:00.002-07:002013-08-14T09:18:49.266-07:00điều khiển nhân vật thông qua lệnh<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">Bài trước đã hướng dẫn cách viết một class textfield hiển thị và nhập trên Canvas, bài này sẽ sử dụng đến textfield đó để làm vài thứ: Đầu tiên chúng ta sẽ tạo một class nhận giá trị là một chuổi và sau đó là phân tích chuỗi đó để thực hiện những lệnh mà ta muốn, lệnh ở đây bao gồm (chuỗi,tọa độ x, tọa độ y) và sau khi nhận chuỗi này nó sẽ tự cập nhật thông tin vào trong các biến của nó, ta viết như sau:</span><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;"></span><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;"></span><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;"></span><br />
<table style="background-color: #e9e8e2; color: black; font-family: Monospaced; font-size: 14px; line-height: 20px; width: 100%px;"><tbody>
<tr><td align="center">C:\Users\WIN7\Documents\NetBeansProjects\textfield\src\NewClass.java</td></tr>
</tbody></table>
<pre style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;"><span class="keyword-directive" style="color: #0000e6;">import</span> javax.microedition.lcdui.*;
<span class="keyword-directive" style="color: #0000e6;">import</span> java.util.*;
<span class="keyword-directive" style="color: #0000e6;">class</span> <span class="ST0" style="font-weight: bold;">canvas</span> <span class="keyword-directive" style="color: #0000e6;">extends</span> Canvas{
textfield <span class="ST1" style="color: #009900;">tf</span>;
<span class="comment" style="color: #969696;">//robot là một đối tượng nhận lệnh và điều khiển bởi lệnh</span>
<span class="ST2" style="color: #009900; font-style: italic;">robot</span> <span class="ST1" style="color: #009900;">rb</span>;
Font <span class="ST1" style="color: #009900;">f</span>=Font.<span class="ST2" style="color: #009900; font-style: italic;">getFont</span>(0,0,8);
<span class="keyword-directive" style="color: #0000e6;">int</span> <span class="ST1" style="color: #009900;">w</span>,<span class="ST1" style="color: #009900;">h</span>,<span class="ST1" style="color: #009900;">k</span>=0,<span class="ST1" style="color: #009900;">fh</span>;
String <span class="ST1" style="color: #009900;">command</span>=<span class="character" style="color: #ce7b00;">""</span>;
<span class="keyword-directive" style="color: #0000e6;">public</span> <span class="ST0" style="font-weight: bold;">canvas</span>(){
<span class="ST2" style="color: #009900; font-style: italic;">setFullScreenMode</span>(<span class="keyword-directive" style="color: #0000e6;">true</span>);
<span class="ST1" style="color: #009900;">w</span>=<span class="ST2" style="color: #009900; font-style: italic;">getWidth</span>();
<span class="ST1" style="color: #009900;">h</span>=<span class="ST2" style="color: #009900; font-style: italic;">getHeight</span>();
<span class="ST1" style="color: #009900;">fh</span>=<span class="ST1" style="color: #009900;">f</span>.getHeight();
<span class="ST1" style="color: #009900;">tf</span>=<span class="keyword-directive" style="color: #0000e6;">new</span> textfield(<span class="character" style="color: #ce7b00;">"</span><span class="character" style="color: #ce7b00;">command</span><span class="character" style="color: #ce7b00;">"</span>,0,0,<span class="ST1" style="color: #009900;">w</span>);
<span class="ST1" style="color: #009900;">rb</span>=<span class="keyword-directive" style="color: #0000e6;">new</span> <span class="ST2" style="color: #009900; font-style: italic;">robot</span>(<span class="ST1" style="color: #009900;">w</span>/2,<span class="ST1" style="color: #009900;">h</span>/2);
}
<span class="keyword-directive" style="color: #0000e6;">public</span> <span class="keyword-directive" style="color: #0000e6;">void</span> <span class="ST0" style="font-weight: bold;">paint</span>(Graphics g){
g.setFont(<span class="ST1" style="color: #009900;">f</span>);
g.setColor(0);
g.fillRect(0,0,<span class="ST1" style="color: #009900;">w</span>,<span class="ST1" style="color: #009900;">h</span>);
<span class="comment" style="color: #969696;">//vẽ hộp nhập văn bản lên canvas</span>
<span class="ST1" style="color: #009900;">tf</span>.paint(g,<span class="ST1" style="color: #009900;">k</span>,<span class="keyword-directive" style="color: #0000e6;">true</span>);
g.setColor(0xf0f0);
g.setClip(0,0,<span class="ST1" style="color: #009900;">w</span>,<span class="ST1" style="color: #009900;">h</span>);
<span class="comment" style="color: #969696;">//vẽ chuỗi lệnh ra màn hình</span>
g.drawString(<span class="ST1" style="color: #009900;">command</span>,0,<span class="ST1" style="color: #009900;">fh</span>*2,Graphics.<span class="ST3" style="color: #009900; font-style: italic;">TOP</span>|Graphics.<span class="ST3" style="color: #009900; font-style: italic;">LEFT</span>);
<span class="comment" style="color: #969696;">//vẽ đối tượng nhận lệnh ra màn hình</span>
<span class="ST1" style="color: #009900;">rb</span>.<span class="ST2" style="color: #009900; font-style: italic;">paint</span>(g);
<span class="ST1" style="color: #009900;">k</span>=0;
<span class="ST2" style="color: #009900; font-style: italic;">repaint</span>();
}
<span class="keyword-directive" style="color: #0000e6;">public</span> <span class="keyword-directive" style="color: #0000e6;">void</span> <span class="ST0" style="font-weight: bold;">keyPressed</span>(<span class="keyword-directive" style="color: #0000e6;">int</span> k){
<span class="keyword-directive" style="color: #0000e6;">this</span>.<span class="ST2" style="color: #009900; font-style: italic;">k</span>=k;
<span class="comment" style="color: #969696;">//nếu nhấn mã -5 (phím ok) thì cho command nhận giá trị của textfield (tf), </span>
<span class="keyword-directive" style="color: #0000e6;">if</span>(k==-5){
<span class="ST1" style="color: #009900;">command</span>=<span class="ST1" style="color: #009900;">tf</span>.getString();
<span class="comment" style="color: #969696;">//sau đó truyền tham số vào trong đối tượng hoạt động robot(rb), trước đó ta cho nó tách thành từng phần qua method tach trước, cách nhau bởi dấu phẩy (có dạng: say,x,y)</span>
<span class="ST1" style="color: #009900;">rb</span>.<span class="ST2" style="color: #009900; font-style: italic;">getcommand</span>(<span class="ST2" style="color: #009900; font-style: italic;">tach</span>(<span class="ST1" style="color: #009900;">command</span>,<span class="character" style="color: #ce7b00;">"</span><span class="character" style="color: #ce7b00;">,</span><span class="character" style="color: #ce7b00;">"</span>));}}
<span class="keyword-directive" style="color: #0000e6;">public</span> <span class="keyword-directive" style="color: #0000e6;">void</span> <span class="ST0" style="font-weight: bold;">keyReleased</span>(<span class="keyword-directive" style="color: #0000e6;">int</span> k){<span class="keyword-directive" style="color: #0000e6;">this</span>.<span class="ST2" style="color: #009900; font-style: italic;">k</span>=0;}
<span class="comment" style="color: #969696;">//chức năng tách chuỗi ra thành từng phần</span>
<span class="keyword-directive" style="color: #0000e6;">public</span> String[] <span class="ST0" style="font-weight: bold;">tach</span>(String s,String c){
Vector v=<span class="keyword-directive" style="color: #0000e6;">new</span> Vector();
<span class="keyword-directive" style="color: #0000e6;">if</span>(!s.endsWith(c)){s+=c;}
<span class="keyword-directive" style="color: #0000e6;">int</span> st=0,np=s.indexOf(c,st);
<span class="keyword-directive" style="color: #0000e6;">while</span>(np!=-1){
v.addElement((String)s.substring(st,np));
st=np+c.length();
np=s.indexOf(c,st);}
String[] rt=<span class="keyword-directive" style="color: #0000e6;">new</span> String[v.size()];
v.copyInto((String[])rt);
<span class="keyword-directive" style="color: #0000e6;">for</span>(<span class="keyword-directive" style="color: #0000e6;">int</span> i=0;i<rt.<span class="ST1" style="color: #009900;">length</span>;i++){System.<span class="ST3" style="color: #009900; font-style: italic;">out</span>.println(rt[i]+rt[i].length());}
<span class="keyword-directive" style="color: #0000e6;">return</span> rt;}
}
</pre>
<span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">Lớp robot là một dạng như sau, nó sẽ nhận các giá trị lệnh và xử lí để hoạt động theo lệnh đó:</span><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;"></span><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;"></span><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;"></span><br />
<table style="background-color: #e9e8e2; color: black; font-family: Monospaced; font-size: 14px; line-height: 20px; width: 100%px;"><tbody>
<tr><td align="center">C:\Users\WIN7\Documents\NetBeansProjects\textfield\src\NewClass.java</td></tr>
</tbody></table>
<pre style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;"><span class="keyword-directive" style="color: #0000e6;">class</span> <span class="ST0" style="font-weight: bold;">robot</span>{
<span class="keyword-directive" style="color: #0000e6;">int</span> <span class="ST1" style="color: #009900;">x</span>,<span class="ST1" style="color: #009900;">y</span>,<span class="ST1" style="color: #009900;">nx</span>,<span class="ST1" style="color: #009900;">ny</span>;
String <span class="ST1" style="color: #009900;">say</span>;
<span class="keyword-directive" style="color: #0000e6;">long</span> <span class="ST1" style="color: #009900;">lm</span>=0;
<span class="comment" style="color: #969696;">//hàm khởi tạo robot nhận 2 giá trị x, y là tọa độ đầu tiên của nó</span>
<span class="keyword-directive" style="color: #0000e6;">public</span> <span class="ST0" style="font-weight: bold;">robot</span>(<span class="keyword-directive" style="color: #0000e6;">int</span> x,<span class="keyword-directive" style="color: #0000e6;">int</span> y){
<span class="keyword-directive" style="color: #0000e6;">this</span>.<span class="ST1" style="color: #009900;">x</span>=x;
<span class="keyword-directive" style="color: #0000e6;">this</span>.<span class="ST1" style="color: #009900;">y</span>=y;
<span class="keyword-directive" style="color: #0000e6;">this</span>.<span class="ST1" style="color: #009900;">nx</span>=x;
<span class="keyword-directive" style="color: #0000e6;">this</span>.<span class="ST1" style="color: #009900;">ny</span>=y;
}
<span class="comment" style="color: #969696;">//hàm getcommand này nhận một mảng chuỗi bao gồm các giá trị truyền vào say, nx, ny </span>
<span class="keyword-directive" style="color: #0000e6;">public</span> <span class="keyword-directive" style="color: #0000e6;">void</span> <span class="ST0" style="font-weight: bold;">getcommand</span>(String[] s){
<span class="ST1" style="color: #009900;">say</span>=s[0];
<span class="ST1" style="color: #009900;">nx</span>=Integer.<span class="ST2" style="color: #009900; font-style: italic;">parseInt</span>(s[1]);
<span class="ST1" style="color: #009900;">ny</span>=Integer.<span class="ST2" style="color: #009900; font-style: italic;">parseInt</span>(s[2]);
}
<span class="comment" style="color: #969696;">//hàm paint sẽ vẽ đối tượng này lên Graphics của canvas, đồng thời cũng di chuyển nó thông qua hàm move</span>
<span class="keyword-directive" style="color: #0000e6;">public</span> <span class="keyword-directive" style="color: #0000e6;">void</span> <span class="ST0" style="font-weight: bold;">paint</span>(<span class="ST2" style="color: #009900; font-style: italic;">Graphics</span> g){
<span class="comment" style="color: #969696;">//cũng cần phải cho nghỉ một khoảng thời gian để nó không di chuyển quá nhanh mà ta không kịp theo dõi</span>
<span class="keyword-directive" style="color: #0000e6;">if</span>(System.<span class="ST2" style="color: #009900; font-style: italic;">currentTimeMillis</span>()-<span class="ST1" style="color: #009900;">lm</span>>200)
move();
g.<span class="ST2" style="color: #009900; font-style: italic;">setColor</span>(0xf000f0);
g.<span class="ST2" style="color: #009900; font-style: italic;">fillRect</span>(<span class="ST1" style="color: #009900;">x</span>,<span class="ST1" style="color: #009900;">y</span>,16,16);
}
<span class="comment" style="color: #969696;">//hàm move này so sánh giá trị tọa độ x,y với nx,ny để từ đó tính toán và thay đổi giá trị của x,y cho đến khi bằng nx,ny</span>
<span class="keyword-directive" style="color: #0000e6;">void</span> <span class="ST0" style="font-weight: bold;">move</span>(){
<span class="comment" style="color: #969696;">//so sánh x và nx nếu như x lớn hơn nx thì cho x trừ đi 1, nếu x bằng nx thì không thay đổi x, ngược lại thì cho x tăng lên 1 khi x nhỏ hơn nx</span>
<span class="ST1" style="color: #009900;">x</span>+=<span class="ST1" style="color: #009900;">x</span>><span class="ST1" style="color: #009900;">nx</span>?-1:(<span class="ST1" style="color: #009900;">x</span>==<span class="ST1" style="color: #009900;">nx</span>?0:1);
<span class="comment" style="color: #969696;">//tương tự với y và ny</span>
<span class="ST1" style="color: #009900;">y</span>+=<span class="ST1" style="color: #009900;">y</span>><span class="ST1" style="color: #009900;">ny</span>?-1:(<span class="ST1" style="color: #009900;">y</span>==<span class="ST1" style="color: #009900;">ny</span>?0:1);}
}
</pre>
<span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">Xong như vậy là chúng ta đã hoàn thành rồi, chỉ cần ghép nó vào MIDlet nữa là thấy:</span><a href="http://holyeyed.99k.org/function/up/mog-25113.zip" style="background-color: white; color: #993322; font-family: Monospaced; font-size: 14px; line-height: 20px; text-decoration: none;">http://holyeyed.99k.org/function/up/mog-25113.zip</a><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;"> </span><a href="http://holyeyed.99k.org/function/up/mog-97485.jar" style="background-color: white; color: #993322; font-family: Monospaced; font-size: 14px; line-height: 20px; text-decoration: none;">http://holyeyed.99k.org/function/up/mog-97485.jar</a><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;"></span><br />
<div class="separator" style="background-color: white; clear: both; font-family: Monospaced; font-size: 14px; line-height: 20px; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdQWljZwpVn5BSnciNNBXoRekXU8hgL_X6zNMGcrmywxVlhjOm8fGNkTGrsr0gd9usw4FhX5b5Be2WeJR1mkCvZ-xCb1EdEqT9Imge70WwBX-fCHYTTKE4ws1m2-llHmWdtytDIYooo7d8/s1600/Capture.PNG" imageanchor="1" style="color: #993322; margin-left: 1em; margin-right: 1em; text-decoration: none;"><img border="0" height="325" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdQWljZwpVn5BSnciNNBXoRekXU8hgL_X6zNMGcrmywxVlhjOm8fGNkTGrsr0gd9usw4FhX5b5Be2WeJR1mkCvZ-xCb1EdEqT9Imge70WwBX-fCHYTTKE4ws1m2-llHmWdtytDIYooo7d8/s400/Capture.PNG" style="-webkit-box-shadow: rgba(0, 0, 0, 0.498039) 1px 1px 5px; border: none; box-shadow: rgba(0, 0, 0, 0.498039) 1px 1px 5px; padding: 8px; position: relative;" width="243" /></a></div>
</div>
nguyendangtuan95@gmail.comhttp://www.blogger.com/profile/11769458566723493488noreply@blogger.com0tag:blogger.com,1999:blog-5575885810563018688.post-13988285477827952902013-08-14T09:15:00.003-07:002013-08-14T09:15:36.106-07:00nhập văn bản trực tiếp từ Canvas<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">thường thì muốn nhập chuỗi thì ta thiết kế sử dụng TextBox hoặc là TextField trên Form, nhưng trong game nên hạn chế cho người dùng sử dụng giao diện bậc cao như vậy. Ta sẽ cho nhập văn bản trực tiếp từ bàn phím trên Canvas dựa vào hàm keyPressed(int i) :</span><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;"></span><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;"></span><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;"></span><br />
<table style="background-color: #e9e8e2; color: black; font-family: Monospaced; font-size: 14px; line-height: 20px; width: 100%px;"><tbody>
<tr><td align="center">C:\Users\WIN7\Documents\NetBeansProjects\textfield\src\textfield.java</td></tr>
</tbody></table>
<pre style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;"> 1 <span class="comment" style="color: #969696;">//textfield.java</span>
2 <span class="keyword-directive" style="color: #0000e6;">import</span> javax.microedition.lcdui.*;
3
4 <span class="keyword-directive" style="color: #0000e6;">public</span> <span class="keyword-directive" style="color: #0000e6;">class</span> <span class="ST0" style="font-weight: bold;">textfield</span> {
5
6 <span class="keyword-directive" style="color: #0000e6;">int</span> <span class="ST1" style="color: #009900;">x</span>, <span class="ST1" style="color: #009900;">y</span>, <span class="ST1" style="color: #009900;">w</span>, <span class="ST1" style="color: #009900;">lk</span> = 0, <span class="ST1" style="color: #009900;">np</span> = 0, <span class="ST1" style="color: #009900;">fh</span>, <span class="ST1" style="color: #009900;">tcolor</span> = 0, <span class="ST1" style="color: #009900;">bgcolor</span> = 0xf0f0f0;
7 String <span class="ST1" style="color: #009900;">s</span> = <span class="character" style="color: #ce7b00;">""</span>, <span class="ST1" style="color: #009900;">title</span>;
8 <span class="comment" style="color: #969696;">//mảng ac chứa các kí tự cần thiết tương ứng với các phím bấm từ 0 đến 9</span>
9 String[] <span class="ST1" style="color: #009900;">ac</span> = {<span class="character" style="color: #ce7b00;">"</span><span class="character" style="color: #ce7b00;"> 0</span><span class="character" style="color: #ce7b00;">"</span>, <span class="character" style="color: #ce7b00;">"</span><span class="character" style="color: #ce7b00;">.,1</span><span class="character" style="color: #ce7b00;">"</span>, <span class="character" style="color: #ce7b00;">"</span><span class="character" style="color: #ce7b00;">abc2</span><span class="character" style="color: #ce7b00;">"</span>, <span class="character" style="color: #ce7b00;">"</span><span class="character" style="color: #ce7b00;">def3</span><span class="character" style="color: #ce7b00;">"</span>, <span class="character" style="color: #ce7b00;">"</span><span class="character" style="color: #ce7b00;">ghi4</span><span class="character" style="color: #ce7b00;">"</span>, <span class="character" style="color: #ce7b00;">"</span><span class="character" style="color: #ce7b00;">jkl5</span><span class="character" style="color: #ce7b00;">"</span>, <span class="character" style="color: #ce7b00;">"</span><span class="character" style="color: #ce7b00;">mno6</span><span class="character" style="color: #ce7b00;">"</span>, <span class="character" style="color: #ce7b00;">"</span><span class="character" style="color: #ce7b00;">pqrs7</span><span class="character" style="color: #ce7b00;">"</span>, <span class="character" style="color: #ce7b00;">"</span><span class="character" style="color: #ce7b00;">tuv8</span><span class="character" style="color: #ce7b00;">"</span>, <span class="character" style="color: #ce7b00;">"</span><span class="character" style="color: #ce7b00;">wxyz9</span><span class="character" style="color: #ce7b00;">"</span>};
10 <span class="keyword-directive" style="color: #0000e6;">long</span> <span class="ST1" style="color: #009900;">lp</span> = 0, <span class="ST1" style="color: #009900;">rr</span> = 0;
11 <span class="keyword-directive" style="color: #0000e6;">boolean</span> <span class="ST1" style="color: #009900;">focus</span> = <span class="keyword-directive" style="color: #0000e6;">false</span>;
12 Font <span class="ST1" style="color: #009900;">f</span> = Font.<span class="ST2" style="color: #009900; font-style: italic;">getFont</span>(0, 0, 8);
13 <span class="comment" style="color: #969696;">//hàm khởi tạo textfield nhận các giá trị tiêu đề (title), vị trí đặt hộp text(x, y), và chiều rộng hộp (w)</span>
14 <span class="keyword-directive" style="color: #0000e6;">public</span> <span class="ST0" style="font-weight: bold;">textfield</span>(String title, <span class="keyword-directive" style="color: #0000e6;">int</span> x, <span class="keyword-directive" style="color: #0000e6;">int</span> y, <span class="keyword-directive" style="color: #0000e6;">int</span> w) {
15 <span class="keyword-directive" style="color: #0000e6;">this</span>.<span class="ST1" style="color: #009900;">title</span> = title;
16 <span class="keyword-directive" style="color: #0000e6;">this</span>.<span class="ST1" style="color: #009900;">x</span> = x;
17 <span class="keyword-directive" style="color: #0000e6;">this</span>.<span class="ST1" style="color: #009900;">y</span> = y;
18 <span class="keyword-directive" style="color: #0000e6;">this</span>.<span class="ST1" style="color: #009900;">w</span> = w;
19 <span class="ST1" style="color: #009900;">fh</span> = <span class="ST1" style="color: #009900;">f</span>.getHeight();
20 }
21
22 String <span class="ST0" style="font-weight: bold;">getString</span>() {
23 <span class="keyword-directive" style="color: #0000e6;">return</span> <span class="ST1" style="color: #009900;">s</span>;
24 }
25 <span class="comment" style="color: #969696;">//hàm paint này dùng vẽ textfield lên Graphic (g) và được dùng trên Canvas, nó nhận các biến tham số: Graphics g, biến mã phím int k, và biến boolean focus chỉ định là có thực hiện thao tác với textfield này không</span>
26 <span class="keyword-directive" style="color: #0000e6;">public</span> <span class="keyword-directive" style="color: #0000e6;">void</span> <span class="ST0" style="font-weight: bold;">paint</span>(Graphics g, <span class="keyword-directive" style="color: #0000e6;">int</span> k, <span class="keyword-directive" style="color: #0000e6;">boolean</span> focus) {
27 g.setFont(<span class="ST1" style="color: #009900;">f</span>);
28 <span class="keyword-directive" style="color: #0000e6;">this</span>.<span class="ST1" style="color: #009900;">focus</span> = focus;
29 <span class="comment" style="color: #969696;">//nếu có tác động focus==true thì cho thực hiện vẽ chuỗi theo mã phím</span>
30 <span class="keyword-directive" style="color: #0000e6;">if</span> (focus && cr() - <span class="ST1" style="color: #009900;">lp</span> > <span class="ST1" style="color: #009900;">rr</span>) {
31 add(k);
32 }
33 <span class="comment" style="color: #969696;">//các hàm vẽ liên quan đến việc vẽ chuỗi s ra màn hình</span>
34 <span class="keyword-directive" style="color: #0000e6;">int</span> slen = <span class="ST1" style="color: #009900;">f</span>.stringWidth(<span class="ST1" style="color: #009900;">s</span>);
35 <span class="keyword-directive" style="color: #0000e6;">int</span> kh = slen - <span class="ST1" style="color: #009900;">w</span>;
36 g.setColor(<span class="ST1" style="color: #009900;">bgcolor</span>);
37 g.fillRect(<span class="ST1" style="color: #009900;">x</span>, <span class="ST1" style="color: #009900;">y</span> + <span class="ST1" style="color: #009900;">fh</span>, <span class="ST1" style="color: #009900;">w</span>, <span class="ST1" style="color: #009900;">fh</span>);
38 g.drawString(<span class="ST1" style="color: #009900;">title</span> + <span class="character" style="color: #ce7b00;">"</span><span class="character" style="color: #ce7b00;">:</span><span class="character" style="color: #ce7b00;">"</span>, <span class="ST1" style="color: #009900;">x</span>, <span class="ST1" style="color: #009900;">y</span>, Graphics.<span class="ST3" style="color: #009900; font-style: italic;">TOP</span> | Graphics.<span class="ST3" style="color: #009900; font-style: italic;">LEFT</span>);
39 g.setColor(<span class="ST1" style="color: #009900;">tcolor</span>);
40 g.setClip(<span class="ST1" style="color: #009900;">x</span>, <span class="ST1" style="color: #009900;">y</span> + <span class="ST1" style="color: #009900;">fh</span>, <span class="ST1" style="color: #009900;">w</span>, <span class="ST1" style="color: #009900;">fh</span>);
41 g.drawString(<span class="ST1" style="color: #009900;">s</span> + (focus ? <span class="character" style="color: #ce7b00;">"</span><span class="character" style="color: #ce7b00;">|</span><span class="character" style="color: #ce7b00;">"</span> : <span class="character" style="color: #ce7b00;">""</span>), <span class="ST1" style="color: #009900;">x</span> - (kh > 0 ? kh : 0), <span class="ST1" style="color: #009900;">y</span> + <span class="ST1" style="color: #009900;">fh</span>, Graphics.<span class="ST3" style="color: #009900; font-style: italic;">TOP</span> | Graphics.<span class="ST3" style="color: #009900; font-style: italic;">LEFT</span>);
42
43
44 }
45
46 <span class="keyword-directive" style="color: #0000e6;">void</span> <span class="ST0" style="font-weight: bold;">add</span>(<span class="keyword-directive" style="color: #0000e6;">int</span> k) {
47 <span class="comment" style="color: #969696;">//nếu key là -3(phím qua trái) thì cho xóa kí tự</span>
48 <span class="keyword-directive" style="color: #0000e6;">if</span> (k == -3 && <span class="ST1" style="color: #009900;">s</span>.length() > 0) {
49 <span class="ST1" style="color: #009900;">s</span> = <span class="ST1" style="color: #009900;">s</span>.substring(0, <span class="ST1" style="color: #009900;">s</span>.length() - 1);
50 <span class="ST1" style="color: #009900;">lk</span> = k;
51 <span class="ST1" style="color: #009900;">lp</span> = cr();
52 } <span class="keyword-directive" style="color: #0000e6;">else</span> <span class="keyword-directive" style="color: #0000e6;">if</span> (k == -6) {<span class="comment" style="color: #969696;">//nếu key là -6 thì thôi không tác động đến textfield này nữa</span>
53 <span class="ST1" style="color: #009900;">focus</span> = <span class="keyword-directive" style="color: #0000e6;">false</span>;
54 } <span class="keyword-directive" style="color: #0000e6;">else</span> {
55 <span class="comment" style="color: #969696;">//tìm vị trí của phím bấm từ 0 đến 9, do phím 0 có mã phím là 48 nên ta lần lượt trừ cho 48 sẽ tương ứng với vị trí của bảng kí tự trong mảng chuổi ac</span>
56 <span class="keyword-directive" style="color: #0000e6;">int</span> sk = k - 48;
57 <span class="comment" style="color: #969696;">//nếu như sk lớn hơn 0 thì cho thực hiện tiếp, tương đương là bấm các phím từ 0->9</span>
58 <span class="keyword-directive" style="color: #0000e6;">if</span> (sk >= 0) {
59 <span class="comment" style="color: #969696;">//nếu thời gian hiện tại trừ lp(lần nhấn sau cùng) <800 và phím nhấn lần này giống với phím bấm lần sau cùng thì cho tăng np (index cần lấy của kí tự trong chuỗi).</span>
60 <span class="keyword-directive" style="color: #0000e6;">if</span> (cr() - 800 < <span class="ST1" style="color: #009900;">lp</span> && <span class="ST1" style="color: #009900;">lk</span> == sk) {
61 <span class="ST1" style="color: #009900;">np</span>++;
62 <span class="keyword-directive" style="color: #0000e6;">if</span> (<span class="ST1" style="color: #009900;">np</span> == <span class="ST1" style="color: #009900;">ac</span>[sk].length()) {
63 <span class="ST1" style="color: #009900;">np</span> = 0;
64 }
65 <span class="ST1" style="color: #009900;">s</span> = <span class="ST1" style="color: #009900;">s</span>.substring(0, <span class="ST1" style="color: #009900;">s</span>.length() - 1);
66 <span class="ST1" style="color: #009900;">s</span> += <span class="ST1" style="color: #009900;">ac</span>[sk].charAt(<span class="ST1" style="color: #009900;">np</span>);
67 } <span class="keyword-directive" style="color: #0000e6;">else</span> {<span class="comment" style="color: #969696;">//ngược lại thì cho thêm vào kí tự thích hợp với phím bấm(kí tự đầu tiên tương ứng các mảng giá trị)</span>
68 <span class="ST1" style="color: #009900;">np</span> = 0;
69 <span class="ST1" style="color: #009900;">s</span> += <span class="ST1" style="color: #009900;">ac</span>[sk].charAt(<span class="ST1" style="color: #009900;">np</span>);
70 }
71 <span class="comment" style="color: #969696;">//đặt mả phím sau cùng và lk (phím bấm sau cùng) và thời gian bấm sau cùng lp (lần nhấn sau cùng)</span>
72 <span class="ST1" style="color: #009900;">lk</span> = sk;
73 <span class="ST1" style="color: #009900;">lp</span> = cr();
74 }
75
76 }
77 }
78 <span class="comment" style="color: #969696;">//hàm cr() trả lại thời gian hiện thời</span>
79 <span class="keyword-directive" style="color: #0000e6;">long</span> <span class="ST0" style="font-weight: bold;">cr</span>() {
80 <span class="keyword-directive" style="color: #0000e6;">return</span> System.<span class="ST2" style="color: #009900; font-style: italic;">currentTimeMillis</span>();
81 }
82 }
83
84 <span class="keyword-directive" style="color: #0000e6;">class</span> <span class="ST0" style="font-weight: bold;">canvas</span> <span class="keyword-directive" style="color: #0000e6;">extends</span> Canvas {
85 <span class="comment" style="color: #969696;">//tạo một biến textfield mới, với tiêu đề là "nhập văn bản", ở tọa độ (0,120) và chiều rông màn hình</span>
86 textfield <span class="ST1" style="color: #009900;">tf</span> = <span class="keyword-directive" style="color: #0000e6;">new</span> textfield(<span class="character" style="color: #ce7b00;">"</span><span class="character" style="color: #ce7b00;">nhập văn bản</span><span class="character" style="color: #ce7b00;">"</span>, 0, 120, 40);
87 <span class="keyword-directive" style="color: #0000e6;">int</span> <span class="ST1" style="color: #009900;">w</span> = getWidth(), <span class="ST1" style="color: #009900;">h</span> = getHeight(), <span class="ST1" style="color: #009900;">k</span> = 0;
88
89 <span class="keyword-directive" style="color: #0000e6;">public</span> <span class="ST0" style="font-weight: bold;">canvas</span>() {
90 }
91
92 <span class="keyword-directive" style="color: #0000e6;">public</span> <span class="keyword-directive" style="color: #0000e6;">void</span> <span class="ST0" style="font-weight: bold;">paint</span>(Graphics g) {
93 g.setColor(0);
94 g.fillRect(0, 0, <span class="ST1" style="color: #009900;">w</span>, <span class="ST1" style="color: #009900;">h</span>);
95 <span class="comment" style="color: #969696;">//thực hiện lệnnh vẽ textfield ra màn hình lên Graphics g và với mã phím k</span>
96 <span class="ST1" style="color: #009900;">tf</span>.paint(g, <span class="ST1" style="color: #009900;">k</span>, <span class="keyword-directive" style="color: #0000e6;">true</span>);
97 <span class="ST1" style="color: #009900;">k</span>=0;
98 repaint();
99 }
100
101 <span class="keyword-directive" style="color: #0000e6;">public</span> <span class="keyword-directive" style="color: #0000e6;">void</span> <span class="ST0" style="font-weight: bold;">keyPressed</span>(<span class="keyword-directive" style="color: #0000e6;">int</span> k) {
102 <span class="keyword-directive" style="color: #0000e6;">this</span>.<span class="ST1" style="color: #009900;">k</span> = k;
103 }
104
105 <span class="keyword-directive" style="color: #0000e6;">public</span> <span class="keyword-directive" style="color: #0000e6;">void</span> <span class="ST0" style="font-weight: bold;">keyReleased</span>(<span class="keyword-directive" style="color: #0000e6;">int</span> k) {
106 <span class="keyword-directive" style="color: #0000e6;">this</span>.<span class="ST1" style="color: #009900;">k</span> = 0;
107 }
108 }
</pre>
<span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">• ở đây chúng ta chỉ cần lưu ý là trong textfield.java có các biến đảm nhận thời gian như là lp, để xác định lần nhấn phím sau cùng mà người dùng nhấn. sau đó so sánh với giá trị thời gian hiện tại lấy từ hàm cr(), nếu như mà hai giá trị này chênh nhau quá 800ms thì cho cộng vào chuỗi một kí tự mới tương ứng với index 0 trong giá trị của phím trong mảng chuỗi ac. Còn nếu như mà thấy thời gian chênh nhau giữa lp và cr() trong 800ms trở lại và mã phím cũng là mã phím nhấn sau cùng thì cho tăng index lấy kí tự trong mã phím hiện tại và kết quả là thay đổi kí tự vừa mới ghi lúc nãy chứ không thêm kí tự mới nào. • </span><a href="http://holyeyed.99k.org/function/up/textfield-62592.jar" style="background-color: white; color: #993322; font-family: Monospaced; font-size: 14px; line-height: 20px; text-decoration: none;">Tải jar</a><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;"> •</span><a href="http://holyeyed.99k.org/function/up/src-30856.zip" style="background-color: white; color: #993322; font-family: Monospaced; font-size: 14px; line-height: 20px; text-decoration: none;">Tải zip</a></div>
nguyendangtuan95@gmail.comhttp://www.blogger.com/profile/11769458566723493488noreply@blogger.com0tag:blogger.com,1999:blog-5575885810563018688.post-19345760108438193572013-08-14T09:05:00.001-07:002013-08-14T09:05:40.304-07:00một đội quân địch, cấp độ khó<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">trong trò chơi mà chơi với những AI thì lúc nào chúng cũng thua mình thôi, do đó cần tạo ra độ khó bằng cách tăng số lượng của chúng. tôi sẽ tạo ra một đạo quân địch từ những gì mà ta đã có và thêm vào đó một vài thứ khác.</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">ta sẽ tạo ra một class E, bao gồm một biến xe T và những giá trị như mã key, biến đúng sai die , như sau:</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">//E.java</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">import javax.microedition.lcdui.*;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">public class E {</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">T x;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">boolean die;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">int k;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">public E(int x, int y, int color, int w,int h){</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">die=false;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">this.x=new T(x,y,color,w,h);}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">void paint(Graphics g,int k){</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">x.paint(g,k);}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">. Sau đó trong game.java ta sửa lại như sau:</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">//game.java</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">import javax.microedition.lcdui.*;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">import java.util.*;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">public class game extends Canvas {</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">String[] smenu={"play game","help","about"};</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">int w,h,fh,mindex=0,mode=0,k,ak,cx=3;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">Midlet m;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">Font f=Font.getDefaultFont();</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">T t,x;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">E[] e;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">long lai=0;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">Random rd=new Random();</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">public game(Midlet m){</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">this.m=m;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">setFullScreenMode(true);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">w=getWidth();</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">h=getHeight();</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">fh=f.getHeight();</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">t=new T(0,0,0xf0f0f0,w,h);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">x=new T(w-16*3,h-16*3,0x6060f0,w,h);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">//khởi tạo e</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">e=new E[cx];</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">for(int i=0;i<e.length;i++){</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">e[i]=new E(w-16*3,h-16*3,0x6060f0,w,h);}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">public void paint(Graphics g){</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">g.setColor(0);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">g.fillRect(0, 0, w, h);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">g.setColor(0xf0f0f0);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">switch(mode){</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">case 0: //vẽ menu</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">//vẽ thanh index</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">g.fillRect(0, (h-fh*3)/2+mindex*fh, w, fh);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">//vẽ các menu</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">for(int i=0;i<smenu.length;i++){</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(i==mindex){g.setColor(0);}else{g.setColor(0xf0f0f0);}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">g.drawString(smenu[i],w/2 ,( h-fh*3)/2+i*fh, Graphics.HCENTER|Graphics.TOP);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">break;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">case 1: //vẽ game play</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">g.drawString(smenu[0], w/2, h/2, Graphics.BASELINE|Graphics.HCENTER);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">t.paint(g, k);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">x.paint(g, (ak=ai(x,ak)));</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(check(t,x)){x.color-=0x000010;}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(check(x,t)){t.color-=0x100000;}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">//biến n đếm số xe đã được vẽ trong e</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">int n=0;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">for(int i=0;i<e.length;i++){</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">//chỉ vẽ ra tới 3 xe tăng, nếu nhiều hơn thì chờ đến lượt</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(n==2)continue; </span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">//nếu chưa trúng đạn thì vẽ ra</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(!e[i].die)</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">{n++;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">e[i].k=ai(e[i].x,e[i].k);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">e[i].paint(g,e[i].k);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">//check xem có trúng đạn của ta không, nếu có thì cho chết die=true</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(check(t,e[i].x))e[i].die=true;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(check(e[i].x,t)){</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">//xe ta bị trúng đạn</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">//game over, kết thúc trò chơi, hay mất mạng, mất máu gì đó</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">}}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">break;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">case 2: //vẽ help</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">g.drawString(smenu[1], w/2, h/2, Graphics.BASELINE|Graphics.HCENTER);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">break;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">case 3: //vẽ about</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">g.drawString(smenu[2], w/2, h/2, Graphics.BASELINE|Graphics.HCENTER);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">break;}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">//vẽ nút lệnh</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">g.setColor(0xf0f0f0);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">g.drawString("exit", 0, h, Graphics.LEFT|Graphics.BOTTOM);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">g.drawString("back", w, h, Graphics.RIGHT|Graphics.BOTTOM);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">repaint();}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">protected void keyReleased(int k){this.k=0;}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">public void keyPressed(int k){</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">this.k=k;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">//cho di chuyển vị trí thanh menu</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(mode==0){</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(k==-1)mindex--;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(k==-2)mindex++;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(mindex<0)mindex=smenu.length-1;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(mindex==smenu.length)mindex=0;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">//thay đổi mode khi lựa chọn menu</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(k==-5)mode=mindex+1;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">//các lệnh cho menu góc màn hình</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(k==-6)m.notifyDestroyed();}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(k==-7)mode=0;}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">boolean check(T a, T b){</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">int xc=(a.d.x-b.x)/16/3;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">int yc=(a.d.y-b.y)/16/3;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(xc==0&amp;&amp;yc==0&amp;&amp;a.d.f!=-1){</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">b.color-=0x100010;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">return true;}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">return false;}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">int ai(T a,int ak){</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(lai<System.currentTimeMillis()-2000){</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">lai=System.currentTimeMillis();</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">int k=Math.abs(rd.nextInt())%4;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">return -(k+1);}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(System.currentTimeMillis()%25==0)</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">return -(1+a.f);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(rd.nextInt()%3==0&amp;&amp;a.d.f==-1){return -5;}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">return 0;}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">. Kết quả đây, trò chơi gần như hoàn thiện, các bạn có thể thêm phần level cho trò chơi hoặc gì đó hay ho một chút...</span><br />
<div class="separator" style="background-color: white; clear: both; font-family: Monospaced; font-size: 14px; line-height: 20px; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPvuEICOp6__816eQ9otN2johVFL_pNUTzqC1a-L0zSVvmIVnLRofISO8KocbURDip5h-vG6P3X368HTXogZVuSnjPKO6yhyphenhyphenZ8rQd76_w9ZO4lS4ij8YzR8Ow-sdf7wpCfiK_DN9-PFCTM/s1600/8.PNG" imageanchor="1" style="color: #993322; margin-left: 1em; margin-right: 1em; text-decoration: none;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPvuEICOp6__816eQ9otN2johVFL_pNUTzqC1a-L0zSVvmIVnLRofISO8KocbURDip5h-vG6P3X368HTXogZVuSnjPKO6yhyphenhyphenZ8rQd76_w9ZO4lS4ij8YzR8Ow-sdf7wpCfiK_DN9-PFCTM/s320/8.PNG" style="-webkit-box-shadow: rgba(0, 0, 0, 0.498039) 1px 1px 5px; border: none; box-shadow: rgba(0, 0, 0, 0.498039) 1px 1px 5px; padding: 8px; position: relative;" width="242" /></a></div>
<br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><a href="http://holyeyed.99k.org/function/up/src-32444.zip" style="background-color: white; color: #993322; font-family: Monospaced; font-size: 14px; line-height: 20px; text-decoration: none;">source here</a></div>
nguyendangtuan95@gmail.comhttp://www.blogger.com/profile/11769458566723493488noreply@blogger.com0tag:blogger.com,1999:blog-5575885810563018688.post-33615707247507874122013-08-14T09:04:00.001-07:002013-08-14T09:04:06.503-07:00giới hạn màn hình<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">tức nhiên nếu cứ để cho những chiếc xe chạy ra khỏi giới hạn của màn hình thì chẳng biết nó sẽ đi tới đâu, thật sự thì nó không thể nào đi quá giới hạn của biến int nhưng mà ta cũng có thể coi là đó là một nơi vô tận. bây giờ ta sẽ giới hạn khả năng di chuyển của chúng, nhưng chiếc xe khi gặp khung màn hình thì không di chuyển thêm nữa. ta biến đổi T.java như sau:</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">//T.java</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">import javax.microedition.lcdui.*;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">public class T {</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">F d;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">int x,y,f,color,w,h;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">long lm=0;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">byte[][] shape={{0,1,0,1,1,1,1,0,1},{1,0,1,1,1,1,0,1,0},{0,1,1,1,1,0,0,1,1},{1,1,0,0,1,1,1,1,0}};</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">public T(int x,int y,int color,</span><span style="background-color: white; color: #38761d; font-family: Monospaced; font-size: 14px; line-height: 20px;">int w, int h</span><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">){</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">this.x=x;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">this.y=y;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">this.color=color;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">d=new F(x+16,y+16,0xf00000,50);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; color: #38761d; font-family: Monospaced; font-size: 14px; line-height: 20px;">this.w=w;<br />this.h=h;</span><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">boolean check(){return (lm<System.currentTimeMillis()-60);}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">public void paint(Graphics g,int k){</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">switch(k){</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">case -1: f=0; if(check()){y-=16;</span><span style="background-color: white; color: #38761d; font-family: Monospaced; font-size: 14px; line-height: 20px;"> if(y<0)y=0;</span><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;"> lm=System.currentTimeMillis();} break;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">case -2: f=1; if(check()){y+=16; </span><span style="background-color: white; color: #38761d; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(y>h-16*3)y=h-16*3;</span><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;"> lm=System.currentTimeMillis();} break;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">case -3: f=2; if(check()){x-=16; </span><span style="background-color: white; color: #38761d; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(x<0)x=0;</span><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;"> lm=System.currentTimeMillis();} break;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">case -4: f=3; if(check()){x+=16;</span><span style="background-color: white; color: #38761d; font-family: Monospaced; font-size: 14px; line-height: 20px;"> if(x>w-16*3) x=w-16*3;</span><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;"> lm=System.currentTimeMillis();}break;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">case -5: d.f=this.f; break;}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">g.setColor(color);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">for(int i=0;i<shape[f].length;i++){</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">int c=i%3,r=(i-c)/3;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">g.fillRect(x+c*16,y+r*16,16*shape[f][i],16*shape[f][i]);}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">d.fire(g,x+16,y+16);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">. Do hàm khởi tạo trong T.java đã thay đổi nên trong game.java ta cũng thay đổi khởi tạo cho biến</span><span style="background-color: white; color: red; font-family: Monospaced; font-size: 14px; line-height: 20px;"> t</span><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">và </span><span style="background-color: white; color: red; font-family: Monospaced; font-size: 14px; line-height: 20px;">x</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">public game(Midlet m){</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">this.m=m;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">setFullScreenMode(true);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">w=getWidth();</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">h=getHeight();</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">fh=f.getHeight();</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">t=new T(0,0,0xf0f0f0,</span><span style="background-color: white; color: #38761d; font-family: Monospaced; font-size: 14px; line-height: 20px;">w,h</span><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">x=new T(w-16*3,h-16*3,0x6060f0,</span><span style="background-color: white; color: #38761d; font-family: Monospaced; font-size: 14px; line-height: 20px;">w,h</span><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">);}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">* Kết quả rất mãn nguyện:</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><div class="separator" style="background-color: white; clear: both; font-family: Monospaced; font-size: 14px; line-height: 20px; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDxZ7G5AAGzi_pCkwFNrO_BRKWZivG5kVKZH9dGjQpuzTVF3t8Ax-Q4Fkht2F3apzBMuGcQ3fR34fLXXCQf9K1bKEX8hEQ-W0eqIwCaBvYHVF-eoiEhI_1wCTcCy1c0CnXivn_2jOjR9Ry/s1600/7.PNG" imageanchor="1" style="color: #993322; margin-left: 1em; margin-right: 1em; text-decoration: none;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDxZ7G5AAGzi_pCkwFNrO_BRKWZivG5kVKZH9dGjQpuzTVF3t8Ax-Q4Fkht2F3apzBMuGcQ3fR34fLXXCQf9K1bKEX8hEQ-W0eqIwCaBvYHVF-eoiEhI_1wCTcCy1c0CnXivn_2jOjR9Ry/s320/7.PNG" style="-webkit-box-shadow: rgba(0, 0, 0, 0.498039) 1px 1px 5px; border: none; box-shadow: rgba(0, 0, 0, 0.498039) 1px 1px 5px; padding: 8px; position: relative;" width="242" /></a></div>
<div>
<br /></div>
</div>
nguyendangtuan95@gmail.comhttp://www.blogger.com/profile/11769458566723493488noreply@blogger.com0tag:blogger.com,1999:blog-5575885810563018688.post-45010249496018588082013-08-14T09:03:00.002-07:002013-08-14T09:03:33.069-07:00AI tự động giải quyết vấn đề.<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="background-color: white;"><span style="font-family: Monospaced; font-size: 14px; line-height: 20px;">thật ra không có gì thông minh cho lắm, người lập trình nghĩ sao viết vậy thì các nhân vật tự động cũng làm theo như vậy. nhưng cũng có những Artificial inteligence thật sự làm người ta ngạc nhiên, điều đó phụ thuộc vào người lập trình như thế nào, có khi họ không phải là người truyền cách thức hoạt động vào code mà là một người khác có trí tuệ cao hơn họ, người này có thể không biết gì về lập trình cả.</span><br style="font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="font-family: Monospaced; font-size: 14px; line-height: 20px;">Ở đây tôi chỉ làm cho xe của địch có khả năng tự di chuyển và nả đạn khi cần thiết, như vậy thì mới thật sự là một trò chơi. trong game.java tôi thêm một hàm mới, hàm này tổng hợp một mã phím theo thời gian.</span></span><br />
<pre style="font-family: Monospaced; font-size: 14px; line-height: 20px;"><span style="background-color: white;">//game.java
import javax.microedition.lcdui.*;
import java.util.*;
public class game extends Canvas {
String[] smenu={"play game","help","about"};
int w,h,fh,mindex=0,mode=0,k,ak;
Midlet m;
Font f=Font.getDefaultFont();
T t,x;
long lai=0;
public game(Midlet m){
this.m=m;
setFullScreenMode(true);
w=getWidth();
h=getHeight();
fh=f.getHeight();
t=new T(0,0,0xf0f0f0);
x=new T(w-16*3,h-16*3,0x6060f0);}
public void paint(Graphics g){
g.setColor(0);
g.fillRect(0, 0, w, h);
g.setColor(0xf0f0f0);
switch(mode){
case 0: //vẽ menu
//vẽ thanh index
g.fillRect(0, (h-fh*3)/2+mindex*fh, w, fh);
//vẽ các menu
for(int i=0;i<smenu.length;i++){
if(i==mindex){g.setColor(0);}else{g.setColor(0xf0f0f0);}
g.drawString(smenu[i],w/2 ,( h-fh*3)/2+i*fh, Graphics.HCENTER|Graphics.TOP);
}
break;
case 1: //vẽ game play
g.drawString(smenu[0], w/2, h/2, Graphics.BASELINE|Graphics.HCENTER);
t.paint(g, k);
x.paint(g,<span style="color: #b45f06;"> (ak=ai(x,ak))</span>);
if(check(t,x)){x.color-=0x000010;}
if(check(x,t))t.color-=0x100000;
break;
case 2: //vẽ help
g.drawString(smenu[1], w/2, h/2, Graphics.BASELINE|Graphics.HCENTER);
break;
case 3: //vẽ about
g.drawString(smenu[2], w/2, h/2, Graphics.BASELINE|Graphics.HCENTER);
break;}
//vẽ nút lệnh
g.setColor(0xf0f0f0);
g.drawString("exit", 0, h, Graphics.LEFT|Graphics.BOTTOM);
g.drawString("back", w, h, Graphics.RIGHT|Graphics.BOTTOM);
repaint();}
protected void keyReleased(int k){this.k=0;}
public void keyPressed(int k){
this.k=k;
//cho di chuyển vị trí thanh menu
if(mode==0){
if(k==-1)mindex--;
if(k==-2)mindex++;
if(mindex<0)mindex=smenu.length-1;
if(mindex==smenu.length)mindex=0;
//thay đổi mode khi lựa chọn menu
if(k==-5)mode=mindex+1;
//các lệnh cho menu góc màn hình
if(k==-6)m.notifyDestroyed();}
if(k==-7)mode=0;}
boolean check(T a, T b){
int xc=(a.d.x-b.x)/16/3;
int yc=(a.d.y-b.y)/16/3;
if(xc==0&amp;&amp;yc==0&amp;&amp;a.d.f!=-1){return true;}
return false;}
//đây là hàm tổng hợp theo thời gian mã key cho xe tự động
<span style="color: #38761d;">int ai(T a,int ak){
Random rd=new Random();
// điều kiệm để đổi hướng xe là sau 2 giây (2000millis giây)
if(lai<System.currentTimeMillis()-2000){
lai=System.currentTimeMillis();
int k=Math.abs(rd.nextInt())%4;
return -(k+1);}
//nếu như không có gì thay đổi thì cứ sau 25 millis giây cho tiến về trước 1 bước
if(System.currentTimeMillis()%25==0)
return -(1+a.f);
//nếu không thì trả về key không, tức không di chuyển
return 0;}
}</span>
</span></pre>
<span style="background-color: white;"><span style="font-family: Monospaced; font-size: 14px; line-height: 20px;">. Kết quả của ta sẽ là xe tự động di chuyển</span></span><br />
<div class="separator" style="clear: both; font-family: Monospaced; font-size: 14px; line-height: 20px; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZ_fXa5Nu1_jNRU1KXl6QLeW09OU2bddF2xxrZUSzdcboAD-CQwsP8tza3PcqRVTasNpgpBi-C2eyW_B3cM23YB8lim8lXPC7c8HKjokocKDzYzJdm3Nq8xliUpQkFTLKIcDi06W6eQL6a/s1600/6.PNG" imageanchor="1" style="background-color: white; color: #993322; margin-left: 1em; margin-right: 1em; text-decoration: none;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZ_fXa5Nu1_jNRU1KXl6QLeW09OU2bddF2xxrZUSzdcboAD-CQwsP8tza3PcqRVTasNpgpBi-C2eyW_B3cM23YB8lim8lXPC7c8HKjokocKDzYzJdm3Nq8xliUpQkFTLKIcDi06W6eQL6a/s320/6.PNG" style="-webkit-box-shadow: rgba(0, 0, 0, 0.498039) 1px 1px 5px; border: none; box-shadow: rgba(0, 0, 0, 0.498039) 1px 1px 5px; padding: 8px; position: relative;" width="238" /></a></div>
<span style="background-color: white;"><span style="font-family: Monospaced; font-size: 14px; line-height: 20px;">Và sửa lại một chút cho khả năng tự nhả đạn:</span></span><br />
<pre style="font-family: Monospaced; font-size: 14px; line-height: 20px;"><span style="background-color: white;">int ai(T a,int ak){
Random rd=new Random();
if(lai<System.currentTimeMillis()-2000){
lai=System.currentTimeMillis();
int k=Math.abs(rd.nextInt())%4;
return -(k+1);}
if(System.currentTimeMillis()%25==0)
return -(1+a.f);
<span style="color: #b45f06;">if(rd.nextInt()%3==0&amp;&amp;a.d.f==-1){return -5;}</span>
return 0;}</span></pre>
</div>
nguyendangtuan95@gmail.comhttp://www.blogger.com/profile/11769458566723493488noreply@blogger.com0tag:blogger.com,1999:blog-5575885810563018688.post-9032568210008501672013-08-14T09:02:00.002-07:002013-08-14T09:02:21.320-07:00trúng đạn<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">bây giờ tôi sẽ thêm một hàm vào trong game.java để phát hiện xem khi nào thì xe ta bị trúng đạn hoặc là xe địch bị ta bắn trúng.</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">//game.java</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">import javax.microedition.lcdui.*;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">public class game extends Canvas {</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">String[] smenu={"play game","help","about"};</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">int w,h,fh,mindex=0,mode=0,k;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">Midlet m;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">Font f=Font.getDefaultFont();</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">T t,x;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">public game(Midlet m){</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">this.m=m;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">setFullScreenMode(true);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">w=getWidth();</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">h=getHeight();</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">fh=f.getHeight();</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">t=new T(0,0,0xf0f0f0);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">x=new T(w-16*3,h-16*3,0x6060f0);}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">public void paint(Graphics g){</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">g.setColor(0);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">g.fillRect(0, 0, w, h);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">g.setColor(0xf0f0f0);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">switch(mode){</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">case 0: //vẽ menu</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">//vẽ thanh index</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">g.fillRect(0, (h-fh*3)/2+mindex*fh, w, fh);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">//vẽ các menu</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">for(int i=0;i<smenu.length;i++){</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(i==mindex){g.setColor(0);}else{g.setColor(0xf0f0f0);}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">g.drawString(smenu[i],w/2 ,( h-fh*3)/2+i*fh, Graphics.HCENTER|Graphics.TOP);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">break;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">case 1: //vẽ game play</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">g.drawString(smenu[0], w/2, h/2, Graphics.BASELINE|Graphics.HCENTER);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">t.paint(g, k);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">x.paint(g, 0);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">//nếu như là kiểm tra thấy đạn của xe này chạm xe kia thì cho xe kia bị đổi màu, tức nhiên là trong thực tế bạn có thể cho nó biến mất</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(check(t,x)){x.color-=0x000010;}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(check(x,t)){t.color-=0x100000;}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">break;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">case 2: //vẽ help</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">g.drawString(smenu[1], w/2, h/2, Graphics.BASELINE|Graphics.HCENTER);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">break;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">case 3: //vẽ about</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">g.drawString(smenu[2], w/2, h/2, Graphics.BASELINE|Graphics.HCENTER);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">break;}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">//vẽ nút lệnh</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">g.setColor(0xf0f0f0);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">g.drawString("exit", 0, h, Graphics.LEFT|Graphics.BOTTOM);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">g.drawString("back", w, h, Graphics.RIGHT|Graphics.BOTTOM);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">repaint();}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">protected void keyReleased(int k){this.k=0;}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">public void keyPressed(int k){</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">this.k=k;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">//cho di chuyển vị trí thanh menu</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(mode==0){</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(k==-1)mindex--;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(k==-2)mindex++;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(mindex<0)mindex=smenu.length-1;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(mindex==smenu.length)mindex=0;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">//thay đổi mode khi lựa chọn menu</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(k==-5)mode=mindex+1;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">//các lệnh cho menu góc màn hình</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(k==-6)m.notifyDestroyed();}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(k==-7)mode=0;}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;"> //hàm check này nhận giá trị là 2 kiểu T và sau đó kiểm tra xem tọa độ đạn của xe đầu và tọa độ của xe sau nếu như mà chạm nhau thì trả lại giá trị true, tương đương với nghĩa là đã bắn trúng.</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; color: #b45f06; font-family: Monospaced; font-size: 14px; line-height: 20px;">boolean check(T a, T b){<br />int xc=(a.d.x-b.x)/16/3;<br />int yc=(a.d.y-b.y)/16/3;<br />if(xc==0&&yc==0&&a.d.f!=-1){return true;}<br />return false;}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">* kết quả như sau, sau khi trúng đạn xe địch thay đổi màu:</span><br />
<div class="separator" style="background-color: white; clear: both; font-family: Monospaced; font-size: 14px; line-height: 20px; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXpc1Fx1cSPff5H00rAGB_KgosXnXqKmyOQ-rszrBcrSEHBQHnKsy8vGcPpCGPbVo4BuEsLs5VTpi3w4vK0g58lj23eYy09wtX75kaJoJljKAq4bE-ak6Qwd3wqky8qbqKA9J3XezSKCFY/s1600/5.PNG" imageanchor="1" style="color: #993322; margin-left: 1em; margin-right: 1em; text-decoration: none;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiXpc1Fx1cSPff5H00rAGB_KgosXnXqKmyOQ-rszrBcrSEHBQHnKsy8vGcPpCGPbVo4BuEsLs5VTpi3w4vK0g58lj23eYy09wtX75kaJoJljKAq4bE-ak6Qwd3wqky8qbqKA9J3XezSKCFY/s320/5.PNG" style="-webkit-box-shadow: rgba(0, 0, 0, 0.498039) 1px 1px 5px; border: none; box-shadow: rgba(0, 0, 0, 0.498039) 1px 1px 5px; padding: 8px; position: relative;" width="237" /></a></div>
</div>
nguyendangtuan95@gmail.comhttp://www.blogger.com/profile/11769458566723493488noreply@blogger.com0tag:blogger.com,1999:blog-5575885810563018688.post-71258432946471157552013-08-14T09:00:00.001-07:002013-08-14T09:00:15.369-07:00chuẩn bị các nguyên liệu cho game<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">trong game có các thành phần như là nhân vật, chướng ngại vật, kẻ thù, và những vật dụng khác cũng như ngoại cảnh. tùy theo ý thích của mỗi người mà chúng ta có thể chuẩn bị đủ mọi thứ. cũng như việc lắp ráp một chiếc xe cần phải có những thứ tạo nên chiếc xe đó như khung xe, bánh xe, dây xích, bulong, ốc vít....</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">bây giờ tôi sẽ làm một game đơn giản thôi và sẽ sử dụng hoàn toàn bằng lệnh, tức là không dung thêm bất cứ file nào ngoài code java. game mà tôi sắp viết nên đây là một trò bắn tăng cổ điển, giống như trò chơi trên các máy bấm hộp nhỏ nhỏ xài pin mà ngoài chợ thường bán.</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">. Ta cần các hình sau:</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">- xe tăng của ta gọi là T</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">- xe tăng chướng vật gọi là X</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">- đạn bắn ra gọi là F</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">mỗi một hình như vậy chúng ta sẽ tạo trên một class riêng và chúng phải có những thuộc tính sau:</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">- tọa độ x</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">- tọa độ y</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">1. đầu tiên tôi viết class vẽ T, như sau:</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; color: #134f5c; font-family: Monospaced; font-size: 14px; line-height: 20px;">import javax.microedition.lcdui.*;<br /><br />public class T {<br /><br />//T này ngoài tọa độ x,y còn có thêm biến frame, và biến màu sắc<br />int x,y,f,color;<br /><br />//biến lm ghi lại lần di chuyển cuối cùng của T<br />long lm=0;<br /><br />//biến shape là các frame của T, gồm có 4 frame<br />byte[][] shape={{0,1,0,1,1,1,1,0,1},{1,0,1,1,1,1,0,1,0},{0,1,1,1,1,0,0,1,1},{1,1,0,0,1,1,1,1,0}};<br /><br />//hàm khởi tạo nhận giá trị tọa độ ban đầu và màu sắc của T<br />public T(int x,int y,int color){<br />this.x=x;<br />this.y=y;<br />this.color=color;}<br /><br />//hàm paint dùng để nhận biến Graphics và vẽ trên đó, cùng với biến k là phím nhấn trên bàn phím<br />public void paint(Graphics g,int k){<br /><br />//check xem lần cuối cùng di chuyển và khoảng thời gian hiện tại có cách nhau 60 millis giây<br />if(lm<System.currentTimeMillis()-60){<br />switch(k){<br />case -1: f=0; y-=16; break;<br />case -2: f=1; y+=16; break;<br />case -3: f=2; x-=16; break;<br />case -4: f=3; x+=16; break;}<br />lm=System.currentTimeMillis();}<br /><br />//đặt màu cho xe tăng này<br />g.setColor(color);<br /><br />//vẽ xe tăng theo frame, nếu là 0 thì không vẽ ra được gì, nếu 1 thì vẽ 1 ô vuông, tạo nên hình chiếc xe<br />for(int i=0;i<shape[f].length;i++){<br />int c=i%3,r=(i-c)/3;<br />g.fillRect(x+c*16,y+r*16,16*shape[f][i],16*shape[f][i]);}<br />}<br />}</span><span style="background-color: white; color: #134f5c; font-family: Monospaced; font-size: 14px; line-height: 20px;"><shape br="br" f="f" i="i" length="length"></shape></span><br />
<div class="separator" style="background-color: white; clear: both; font-family: Monospaced; font-size: 14px; line-height: 20px; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwk6fn3EOeOnd6WrquKzBXb376ZAphPJpDJXGKkfvFzDvLIskvzS_5rlyGCcdpGpCDCSGQB2LKyrwd83wlhEbkvFnvJ16rt41EeM8D2Sr8C1ja-XOsXoX7gzV0aIul7ItbefbohH-1Ctk8/s1600/2.PNG" imageanchor="1" style="color: #993322; margin-left: 1em; margin-right: 1em; text-decoration: none;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwk6fn3EOeOnd6WrquKzBXb376ZAphPJpDJXGKkfvFzDvLIskvzS_5rlyGCcdpGpCDCSGQB2LKyrwd83wlhEbkvFnvJ16rt41EeM8D2Sr8C1ja-XOsXoX7gzV0aIul7ItbefbohH-1Ctk8/s320/2.PNG" style="-webkit-box-shadow: rgba(0, 0, 0, 0.498039) 1px 1px 5px; border: none; box-shadow: rgba(0, 0, 0, 0.498039) 1px 1px 5px; padding: 8px; position: relative;" width="244" /></a></div>
<span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">kết quả của ta sẽ như thế này. ta không cần phải thiết kế thêm class X nữa mà chúng ta dùng class T để tạo luôn xe tăng chướng ngại, chỉ cần đổi màu một chút là được, và kết quả ta được như sau:</span><span style="background-color: white; color: #134f5c; font-family: Monospaced; font-size: 14px; line-height: 20px;"><br /></span><br />
<div class="separator" style="background-color: white; clear: both; font-family: Monospaced; font-size: 14px; line-height: 20px; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGX6j2Uskpu20ybL1PGHhqHMibUHrIs7_PS9T4hIDA9S7OTO5UdYKMgCZbpTuxUd9ZAqBJ1BIipd3VJs6o2mflSm2yd5IvQQAgtBmVZgJaJblChiHi9E28m8riht6lZo9Ldb9wPteyPPYa/s1600/3.PNG" imageanchor="1" style="color: #993322; margin-left: 1em; margin-right: 1em; text-decoration: none;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGX6j2Uskpu20ybL1PGHhqHMibUHrIs7_PS9T4hIDA9S7OTO5UdYKMgCZbpTuxUd9ZAqBJ1BIipd3VJs6o2mflSm2yd5IvQQAgtBmVZgJaJblChiHi9E28m8riht6lZo9Ldb9wPteyPPYa/s320/3.PNG" style="-webkit-box-shadow: rgba(0, 0, 0, 0.498039) 1px 1px 5px; border: none; box-shadow: rgba(0, 0, 0, 0.498039) 1px 1px 5px; padding: 8px; position: relative;" width="242" /></a></div>
<br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">Tất nhiên trong file game.java chúng ta cũng phải thay đổi một chút để đưa hai đối tượng T này vào:</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">import javax.microedition.lcdui.*;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">public class game extends Canvas {</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">String[] smenu={"play game","help","about"};</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">int w,h,fh,mindex=0,mode=0,k;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">Midlet m;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">Font f=Font.getDefaultFont();</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">T t,x;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">public game(Midlet m){</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">this.m=m;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">setFullScreenMode(true);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">w=getWidth();</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">h=getHeight();</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">fh=f.getHeight();</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">t=new T(0,0,0xf0f0f0);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">x=new T(w-16*3,h-16*3,0x6060f0);}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">public void paint(Graphics g){</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">g.setColor(0);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">g.fillRect(0, 0, w, h);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">g.setColor(0xf0f0f0);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">switch(mode){</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">case 0: //vẽ menu</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">//vẽ thanh index</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">g.fillRect(0, (h-fh*3)/2+mindex*fh, w, fh);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">//vẽ các menu</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">for(int i=0;i<smenu.length;i++){</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(i==mindex){g.setColor(0);}else{g.setColor(0xf0f0f0);}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">g.drawString(smenu[i],w/2 ,( h-fh*3)/2+i*fh, Graphics.HCENTER|Graphics.TOP);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">break;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">case 1: //vẽ game play</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">g.drawString(smenu[0], w/2, h/2, Graphics.BASELINE|Graphics.HCENTER);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">t.paint(g, k);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">x.paint(g, k);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">break;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">case 2: //vẽ help</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">g.drawString(smenu[1], w/2, h/2, Graphics.BASELINE|Graphics.HCENTER);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">break;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">case 3: //vẽ about</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">g.drawString(smenu[2], w/2, h/2, Graphics.BASELINE|Graphics.HCENTER);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">break;}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">//vẽ nút lệnh</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">g.setColor(0xf0f0f0);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">g.drawString("exit", 0, h, Graphics.LEFT|Graphics.BOTTOM);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">g.drawString("back", w, h, Graphics.RIGHT|Graphics.BOTTOM);</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">repaint();}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">protected void keyReleased(int k){this.k=0;}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">public void keyPressed(int k){</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">this.k=k;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">//cho di chuyển vị trí thanh menu</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(mode==0){</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(k==-1)mindex--;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(k==-2)mindex++;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(mindex<0 )mindex=smenu.length-1;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(mindex==smenu.length)mindex=0;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">//thay đổi mode khi lựa chọn menu</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(k==-5)mode=mindex+1;</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">//các lệnh cho menu góc màn hình</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(k==-6)m.notifyDestroyed();}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">if(k==-7)mode=0;}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">. Bây giờ thì viết thêm class F nữa, đây sẽ là đạn bắn ra từ các xe.</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; color: #38761d; font-family: Monospaced; font-size: 14px; line-height: 20px;">//F.java<br />import javax.microedition.lcdui.*;<br />public class F {<br />int x,y,color,f=-1,speed;<br />long lm=0;<br />public F(int x,int y,int color,int speed){<br />this.x=x;<br />this.y=y;<br />this.color=color;<br />this.speed=speed;}<br />public void fire(Graphics g,int x,int y){<br />if(f==-1){this.x=x; this.y=y;}<br />g.setColor(color);<br />if(System.currentTimeMillis()%500<250)<br />g.fillRect(this.x,this.y,16,16);<br /><br />if(f!=-1&amp;&amp;lm<System.currentTimeMillis()-speed){<br />switch(f){<br />case 0: this.y-=16; break;<br />case 1: this.y+=16; break;<br />case 2: this.x-=16; break;<br />case 3: this.x+=16; break;}<br />lm=System.currentTimeMillis();}<br />if(f!=-1&amp;&amp;(Math.abs(this.x-x)&gt;240||Math.abs(this.y-y)&gt;320)){f=-1;}<br />}<br />}</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">. cuối cùng thì mỗi xe đều có khả năng nhả đạn, nên trong T class ta chỉnh sửa lại một chút để tạo khả năng bắn đạn cho các xe này.</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; color: #38761d; font-family: Monospaced; font-size: 14px; line-height: 20px;">//T.java<br />import javax.microedition.lcdui.*;<br /><br />public class T {<br />F d;<br />int x,y,f,color;<br />long lm=0;<br />byte[][] shape={{0,1,0,1,1,1,1,0,1},{1,0,1,1,1,1,0,1,0},{0,1,1,1,1,0,0,1,1},{1,1,0,0,1,1,1,1,0}};<br />public T(int x,int y,int color){<br />this.x=x;<br />this.y=y;<br />this.color=color;<br />d=new F(x+16,y+16,0xf00000,500);}<br />boolean check(){return (lm<System.currentTimeMillis()-60);}<br /><br />public void paint(Graphics g,int k){<br />switch(k){<br />case -1: f=0; if(check()){y-=16; lm=System.currentTimeMillis();} break;<br />case -2: f=1; if(check()){y+=16; lm=System.currentTimeMillis();} break;<br />case -3: f=2; if(check()){x-=16; lm=System.currentTimeMillis();} break;<br />case -4: f=3; if(check()){x+=16; lm=System.currentTimeMillis();}break;<br />case -5: d.f=this.f; break;}<br />g.setColor(color);<br />for(int i=0;i<shape[f].length;i++){<br />int c=i%3,r=(i-c)/3;<br />g.fillRect(x+c*16,y+r*16,16*shape[f][i],16*shape[f][i]);}<br />d.fire(g,x+16,y+16);<br />}<br />}</span><span style="background-color: white; color: #38761d; font-family: Monospaced; font-size: 14px; line-height: 20px;"></span><br />
<div class="separator" style="background-color: white; clear: both; font-family: Monospaced; font-size: 14px; line-height: 20px; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhORLb8CprPaRg3Q3Tyrxx3wK0xTxDLS-FAcBkxS8ptIBgB0ulcgdC3AjpERgbVdiR-fgIYPGvbBf3lVnEDSUyvAFXHjHVj8Mx5g8egupYjP0BNaADxv2bfMu-GxCSp6-nb3G58oLWcNDKQ/s1600/4.PNG" imageanchor="1" style="color: #993322; margin-left: 1em; margin-right: 1em; text-decoration: none;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhORLb8CprPaRg3Q3Tyrxx3wK0xTxDLS-FAcBkxS8ptIBgB0ulcgdC3AjpERgbVdiR-fgIYPGvbBf3lVnEDSUyvAFXHjHVj8Mx5g8egupYjP0BNaADxv2bfMu-GxCSp6-nb3G58oLWcNDKQ/s320/4.PNG" style="-webkit-box-shadow: rgba(0, 0, 0, 0.498039) 1px 1px 5px; border: none; box-shadow: rgba(0, 0, 0, 0.498039) 1px 1px 5px; padding: 8px; position: relative;" width="240" /></a></div>
<span style="background-color: white; color: #38761d; font-family: Monospaced; font-size: 14px; line-height: 20px;">kết quả ta được như thế này.</span></div>
nguyendangtuan95@gmail.comhttp://www.blogger.com/profile/11769458566723493488noreply@blogger.com0tag:blogger.com,1999:blog-5575885810563018688.post-27445136103647807792013-08-14T08:58:00.002-07:002013-08-14T08:58:27.272-07:00chia các phần trong một trò chơi<div dir="ltr" style="text-align: left;" trbidi="on">
<h3 class="post-title entry-title" itemprop="name" style="background-color: white; font-family: Georgia, Utopia, 'Palatino Linotype', Palatino, serif; font-size: 30px; font-weight: normal; margin: 0px; position: relative;">
<br /></h3>
<div>
<span style="background-color: white; color: #134f5c; font-family: Monospaced; font-size: 14px; line-height: 20px;">hãy tưởng tượng, khi mở một trò chơi ra bạn sẽ có thể gặp một phần giới thiệu trước, sau đó là menu, mỗi một lựa chọn trong menu lại đưa ra một màn hình khác nhau, như màn chơi, phần hướng dẫn, phần tóm tắt...</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; color: #134f5c; font-family: Monospaced; font-size: 14px; line-height: 20px;">bài này sẽ tạo ra một class hiển thị các phần như vậy, và menu của chúng ta chỉ có 3 mục: play game, help, about, với một nút exit ở dưới trái màn hình.</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; color: #134f5c; font-family: Monospaced; font-size: 14px; line-height: 20px;">file Midlet của chúng ta sẽ chỉ có thêm một dòng so với ban đầu:</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><blockquote class="tr_bq" style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">
//Midlet.java<br />import javax.microedition.midlet.*;<br />import javax.microedition.lcdui.*;<br /><br /><br />public class Midlet extends MIDlet {<br />public void startApp() {<br />Display.getDisplay(this).setCurrent(new game(this));<br />}<br /><br />public void pauseApp() {}<br /><br />public void destroyApp(boolean unconditional) {}<br />}</blockquote>
<span style="background-color: white; color: #134f5c; font-family: Monospaced; font-size: 14px; line-height: 20px;">tạo một class mới đặt tên là game, có nội dung như sau:</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><blockquote class="tr_bq" style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">
//game.java<br /><br />import javax.microedition.lcdui.*;<br />public class game extends Canvas {<br /><br />String[] smenu={"play game","help","about"};<br />int w,h,fh,mindex=0,mode=0;<br />Midlet m;<br />Font f=Font.getDefaultFont();<br /><br />public game(Midlet m){<br />this.m=m;<br />setFullScreenMode(true);<br />w=getWidth();<br />h=getHeight();<br />fh=f.getHeight();}<br /><br />public void paint(Graphics g){<br />g.setColor(0);<br />g.fillRect(0, 0, w, h);<br />g.setColor(0xf0f0f0);<br />switch(mode){<br />case 0: //vẽ menu<br />//vẽ thanh index<br />g.fillRect(0, (h-fh*3)/2+mindex*fh, w, fh);<br />//vẽ các menu<br />for(int i=0;i<smenu.length;i++){<br />if(i==mindex){g.setColor(0);}else{g.setColor(0xf0f0f0);}<br />g.drawString(smenu[i],w/2 ,( h-fh*3)/2+i*fh, Graphics.HCENTER|Graphics.TOP);<br />}<br />break;<br />case 1: //vẽ game play<br />g.drawString(smenu[0], w/2, h/2, Graphics.BASELINE|Graphics.HCENTER);<br />break;<br />case 2: //vẽ help<br />g.drawString(smenu[1], w/2, h/2, Graphics.BASELINE|Graphics.HCENTER);<br />break;<br />case 3: //vẽ about<br />g.drawString(smenu[2], w/2, h/2, Graphics.BASELINE|Graphics.HCENTER);<br />break;}<br />//vẽ nút lệnh<br />g.setColor(0xf0f0f0);<br />g.drawString("exit", 0, h, Graphics.LEFT|Graphics.BOTTOM);<br />g.drawString("back", w, h, Graphics.RIGHT|Graphics.BOTTOM);<br />repaint();}<br /><br />public void keyPressed(int k){<br /><br />//cho di chuyển vị trí thanh menu<br />if(k==-1)mindex--;<br />if(k==-2)mindex++;<br />if(mindex<0) mindex=smenu.length-1;<br />if(mindex==smenu.length) mindex=0;<br /><br />//thay đổi mode khi lựa chọn menu<br />if(k==-5)mode=mindex+1;<br /><br />//các lệnh cho menu góc màn hình<br />if(k==-7)mode=0;<br />if(k==-6)m.notifyDestroyed();}<br />}</blockquote>
<div class="separator" style="background-color: white; clear: both; font-family: Monospaced; font-size: 14px; line-height: 20px; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7b1elz4U4z5aqcdTFeWpkN0X19jTfmbDeQKpTfvWravs3jqaly8HzSdFXX3Akoj8FsP5vENWmUg4p9TUOCt2o5p2dO2Z2-1sP3wHtInUAcb4Huw9SflPvI2moMQI7mmbvsBfs8zcHye13/s1600/Capture.PNG" imageanchor="1" style="color: #993322; margin-left: 1em; margin-right: 1em; text-decoration: none;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7b1elz4U4z5aqcdTFeWpkN0X19jTfmbDeQKpTfvWravs3jqaly8HzSdFXX3Akoj8FsP5vENWmUg4p9TUOCt2o5p2dO2Z2-1sP3wHtInUAcb4Huw9SflPvI2moMQI7mmbvsBfs8zcHye13/s320/Capture.PNG" style="-webkit-box-shadow: rgba(0, 0, 0, 0.498039) 1px 1px 5px; border: none; box-shadow: rgba(0, 0, 0, 0.498039) 1px 1px 5px; padding: 8px; position: relative;" width="235" /></a></div>
</div>
</div>
nguyendangtuan95@gmail.comhttp://www.blogger.com/profile/11769458566723493488noreply@blogger.com0tag:blogger.com,1999:blog-5575885810563018688.post-43839000736173888742013-08-14T08:56:00.003-07:002013-08-14T08:56:52.315-07:00công cụ sử dụng trong bài viết<div dir="ltr" style="text-align: left;" trbidi="on">
Sau đây là chia sẻ của tôi về những hiểu biết về n.n java đã tích góp đc. trong thời gian qua post lên đây để có dịp se đọc lại và cho các bạn tham khảo<br />
<span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">. đối với người dùng windows thì netbean hay java wireless toolkit là những phần mềm hỗ trợ lập trình J2ME tốt nhất. ngoài ra các bạn còn cần phải tải gói java hỗ trợ là jdk.</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">. để tiện lợi, tôi sẽ sử dụng netbean để tiến hành hướng dẫn trong những bài viết này, giao diện và các phần bổ trợ gần như đầy đủ.</span><br />
<div class="separator" style="background-color: white; clear: both; font-family: Monospaced; font-size: 14px; line-height: 20px; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWHM038Sl0HCHZynM9VcFfuW0p9PlcjpNbg_vxUXFVN71MyznNFX9vCLmFSxVhK3LUmXQQE0hIY4SrT6hVh7qvSMSHXuYpv-I_plKpUw1UC7CpdmpOi-L5paOx21e80GcoNoP-fvQidMZd/s1600/Capture.PNG" imageanchor="1" style="color: #993322; margin-left: 1em; margin-right: 1em; text-decoration: none;"><img border="0" height="218" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWHM038Sl0HCHZynM9VcFfuW0p9PlcjpNbg_vxUXFVN71MyznNFX9vCLmFSxVhK3LUmXQQE0hIY4SrT6hVh7qvSMSHXuYpv-I_plKpUw1UC7CpdmpOi-L5paOx21e80GcoNoP-fvQidMZd/s320/Capture.PNG" style="-webkit-box-shadow: rgba(0, 0, 0, 0.498039) 1px 1px 5px; border: none; box-shadow: rgba(0, 0, 0, 0.498039) 1px 1px 5px; padding: 8px; position: relative;" width="320" /></a></div>
<a href="http://netbeans.org/downloads/" style="background-color: white; color: #993322; font-family: Monospaced; font-size: 14px; line-height: 20px; text-decoration: none;" target="_blank">netbean download</a><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;"> vào trang download và chn download gói all (240Mb)</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><a href="http://adf.ly/Euz98" style="background-color: white; color: #993322; font-family: Monospaced; font-size: 14px; line-height: 20px; text-decoration: none;" target="_blank">jdk gói java</a><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;"> bổ trợ cung cấp thư viện và môi trường chạy giả lập</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">. Bạn cài gói JDK trước sau đó cài netBean sau, quá trình khởi động đầu tiên NetBean sẽ kiểm tra phần cứng và cấu hình hơi lâu một chút.</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">. để tạo một Project mới bạn bấm vào File -> new Project -> (cataloge) Java ME -> (Project) Mobile Application. sau đó nhấn Next</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">- tiếp theo đặt tên cho Project, bỏ chọn create Hello Midlet, bấm finish</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">- ở khung bên trái dưới tên project, chọn source package, click phải vào và chọn new -> Midlet, bấm finish, đây là main class của chúng ta.</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">- để tạo thêm những class phụ chúng ta cũng bấm phải vào source package và chọn new -> class, đặt tên và nhấn finish.</span><br style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;" /><span style="background-color: white; font-family: Monospaced; font-size: 14px; line-height: 20px;">- để mở một file source chỉ cần nhấp đúp vào tên của nó bên khung bên trái.</span></div>
nguyendangtuan95@gmail.comhttp://www.blogger.com/profile/11769458566723493488noreply@blogger.com0tag:blogger.com,1999:blog-5575885810563018688.post-33946550620461201632013-08-14T08:52:00.002-07:002013-08-14T08:52:23.641-07:00Đôi khi tôi cảm thấy trống rỗng<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="background-color: #f5f4f4; color: #6f5e4e; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19.4375px; margin-bottom: 1em; padding: 0px;">
không còn như ngày xưa nữa, khi tôi không có chút vướng bận gì. bây giờ thì đã khác, có những thứ tôi muốn làm nhưng lại không làm được. tôi thấy ở đó gần ngay trước mặt mình nhưng lại không làm sao tiến gần lại được. nhiều khi cơ hội không bao giờ đến lần thứ 2, tôi không có ý định gì hết, tôi cũng không biết những ý định của người khác. khi họ tiến tới gần tôi và nói vài thứ, tôi tin vài thứ. có thể ngoài những gì biểu hiện ra bên ngoài còn có những thứ ờ bên trong nữa mà tôi không biết được. dù sao thì tôi cũng có những thứ làm mình cảm thấy dễ chịu, từ bây giờ đến khi kết thúc.</div>
<div style="background-color: #f5f4f4; color: #6f5e4e; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19.4375px; margin-bottom: 1em; padding: 0px;">
vài ngày trước tôi còn như đang ở một nơi ấm áp dù bên ngoài trời đang mưa, tôi cũng quan tâm xem cái cảm giác của mình là có thật hay không. tôi biết, nó không thật sự là như vậy, tôi cũng không biết nữa. hôm nay tôi lại cảm thấy muốn nói ra điều gì đó, nhưng như thường lệ, chẳng bao giờ tôi nói ra gì cả, những gì mà tôi muốn nói, thật sự là muốn hỏi xem nó có thật sự là như vậy không thôi, thật sự là một câu trả lời.</div>
<div style="background-color: #f5f4f4; color: #6f5e4e; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19.4375px; margin-bottom: 1em; padding: 0px;">
khó quá bây giờ thì người biết tất cả mọi thứ không còn ở bên tôi nữa rồi, và mọi thứ làm tôi cứ tự hỏi mãi, liệu một ngày nào đó tôi sẽ thật sự biết được nó chứ. ngày mai, không phải là kết thúc…</div>
</div>
nguyendangtuan95@gmail.comhttp://www.blogger.com/profile/11769458566723493488noreply@blogger.com0tag:blogger.com,1999:blog-5575885810563018688.post-12539176098789817842013-08-14T08:34:00.004-07:002013-08-14T08:34:57.777-07:00[phim] proposal<div dir="ltr" style="text-align: left;" trbidi="on">
<a href="http://thepiratebay.se/torrent/5122939/The.Proposal.2009.DVDrip.English.FULL" rel="nofollow">Tải phim</a><br />
<div style="background-color: #f5f4f4; color: #6f5e4e; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19.4375px; margin-bottom: 1em; padding: 0px;">
<img alt="" class="alignnone" height="320" src="http://aneeshchaganty.files.wordpress.com/2011/02/the-proposal-movie.jpg" style="border: 0px; margin: 0px; padding: 0px;" title="proposal" width="570" /></div>
<div style="background-color: #f5f4f4; color: #6f5e4e; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19.4375px; margin-bottom: 1em; padding: 0px;">
“<em style="margin: 0px; padding: 0px;">chuyện này thật là điên rồ, tôi không muốn lừa dối mọi người nữa, thật sự đây không phải là tình yêu thật sự…”</em></div>
<div style="background-color: #f5f4f4; color: #6f5e4e; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19.4375px; margin-bottom: 1em; padding: 0px;">
đứng bên bờ vực bị đuổi về canada, sếp nữ này phải làm sao đây. điều cô ta có thề làm là lấy một chàng trai để có thể ở lại đây, và cô gái đã thực hiện một hợp đồng với cấp dưới của mình rằng: nếu lấy cô thì cô sẽ chiếu cố cho những bài viết của anh. tất nhiên chàng trai không hề chịu nhận lời một cách dễ dàng như vậy, chàng trai bắt cô phải quì gối giữa đường để cầu hôn anh và sau đó là một chuyến du lịch trở về nhà anh để nói với những người trong gia đính.</div>
<div style="background-color: #f5f4f4; color: #6f5e4e; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19.4375px; margin-bottom: 1em; padding: 0px;">
“<em style="margin: 0px; padding: 0px;">có lẽ đối với em thì đây chỉ là một hợp đồng, nhưng đối vói anh nó thật sự là điều mà anh muốn thực hiện, chỉ tại em quá cứng nhắc và có điều gì đó giống như anh sợ rằng em sẽ</em> từ chối anh…”</div>
<div style="background-color: #f5f4f4; color: #6f5e4e; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19.4375px; margin-bottom: 1em; padding: 0px;">
không ai ngờ tới việc thay đổi ý kiến của cô gái khi cô tiếp xúc với những người trong gia đình, đó thật sự là một gia đình với những người tốt và cô không có quyền lừa dối họ, không có quyền cướp đi người con người cháu yêu quí của họ, chỉ vì cô phải chấp nhận sự thật của bản thân mình là cô đã yêu thật sự….</div>
<div style="background-color: #f5f4f4; color: #6f5e4e; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19.4375px; margin-bottom: 1em; padding: 0px;">
phim vui không thể nói, tất cả mọi người đều cảm thấy dễ chịu, tất nhiên đó chỉ là những chuyện trên phim ảnh, với phim ảnh, ta có thề làm mọi chuyện…</div>
</div>
nguyendangtuan95@gmail.comhttp://www.blogger.com/profile/11769458566723493488noreply@blogger.com0tag:blogger.com,1999:blog-5575885810563018688.post-31122704651269455272011-07-13T06:48:00.001-07:002011-07-13T06:48:51.965-07:00lệnh. cs 1.1<div class="MsoNormal"><span style="color: darkorange; font-family: Verdana; font-size: 10.0pt;">trước khi vào mạng Lan hãy tự lập 1 phòng riêng rồi đánh lệnh<br />
+tex tab 0.5-----màu trắng cực kì dễ bắn<br />
+gl_po tab 99999<br />
+gl_sp tab 99999 ----2 lệnh này cực kì quan trọng nó sẽ hiện lên những vết máu,mìn,gạch giúp cho việc **c tường<br />
+ex_tab 2 lần 0----quan sát đươc hướng đi của mìn<br />
+gun tab<br />
+cl_bo tab 0.8 ---- độ rung hợp lí cho việc bắn súng máy<br />
+ br tab 99999 ---- màu sáng hơn<br />
+ sp tab 101 <br />
+fp tab 101 ----- 2 lệnh này giúp giảm trọng lượng nhảy cao hơn và nhất là bunny cực kì nhẹ nhàng<br />
+ gl_al tab 1--- lệnh này để biến mất mấy song sắt hàng rào<br />
xong rồi chỉ việc đánh slist rồi connect sever cần chơi<br />
lưu ý là tớ toàn bắn Opengl nên khi để 3D hay software ko xin được 1 số lệnh<br />
p/s:counter strike bản 1.1 có cài hay riêng nên ai tâm huyết hãng vào và viết những lệnh tâm đắc của mình ko châm chọc </span><span style="color: black; font-family: Verdana; font-size: 10.0pt;"><o:p></o:p></span></div><div class="MsoNormal"><br />
</div><div class="MsoNormal"><span style="color: #455867; font-family: Verdana; font-size: 10.0pt;">Các mã họ Sv_(Server Options)---- Sv_aim 0: Mã này dùng cho các loại súng nhắm như scount, awp, sg550...khi bạn bật nhắm thì nó tâm crosshair sẽ tự động dí theo đối phương nếu đối phương nằm trong tầm ngắm của bạn...tất nhiên là máy con có thể dùng được mã này.... <br />
---- Sv_accelerate 5: tốc độ bơi dưới nước khi bạn chơi các map có ao hồ sông suối thì tốc độ bơi sẽ nhanh hơn bình thường rất nhiều..... <br />
---- Sv_airacecelerate 10: mã này giúp cho bạn có thể di chuyển 1 cách khá linh hoạt và mau lẹ.... <br />
---- Sv_airmove: số tuỳ chọn...mã này điều chỉnh kiểu và tốc độ bay trên không của bạn..... <br />
---- Sv_cheat 1: Bật chế độ cheat code (Ăn gian).... <br />
---- Sv_restart 1: Khởi động lại server.... <br />
---- Sv_stepsize 999999: mã này là mã leo tường...khi bạn chỉnh rất nhiều số 9 thì bạn sẽ trèo qua tất cả những bức tường cao chót vót...dĩ nhiên là chỉ vượt qua được những bức tường cho phép..... <br />
---- Sv_skycolor_r 9: màu đỏ...các mã này khi bạn ra ngoài trời thì thân thể bạn sẽ đổi màu..... <br />
---- Sv_skycolor_r 99: như trên (màu khác) <br />
---- Sv_skycolor_r 999: như trên (màu khác) <br />
---- Sv_skycolor_bl 9: Màu xanh dương. <br />
---- Sv_skycolor_bl 99: Như trên <br />
---- Sv_skycolor_bl 999: như trên <br />
---- Sv_skycolor_gre 9: Màu xanh lá cây. <br />
---- Sv_skycolor_gre 99: như trên <br />
---- Sv_skycolor_gre 999: như trên <br />
Cũng nói thêm là các mã trên sẽ hiện ra màu khác nếu bạn chỉnh theo số cho phù hợp...tuỳ theo cách chỉnh màu 1 cách khéo léo của bạn mà bạn được những màu ưng ý và khá đẹp mắt..... <br />
---- Sv_fiction [999999999999]: mã đi nhanh.....giúp bạn đi rất nhanh....nhưng chỉ có tác dụng trong 4 giây mà thôi sau đó nó sẽ trở lại như bình thường....muốn đi nhanh lại thì bạn phải chỉnh lại mã đó.... <br />
---- sv_restartround 0: Khởi động lại server...làm lại số kill/death của tất cả ai chơi trong mạng do bạn tạo sẵn...nếu bạn thay số là 2 thì sau 2 giây nó sẽ làm lại số kill và death..... <br />
---- sv_spectatormaxspeed: tốc độ bạn dạo quanh map............ <br />
---- sv_stopspeed: Chỉnh mã này bạn sẽ dừng lại nhanh chóng không bị lỡ đà.... <br />
---- sv_maxspeed: Tốc độ đi tối đa mà bạn đạt được....... <br />
---- sv_waterraccelerate: Tốc độ bơi dưới nước....bạn chỉnh mã này thì bạn sẽ di chuyển khá nhanh trong nước.....kết hợp với phím ";"để bơi.... <br />
---- sv_sendvelocity 0: Nếu màn hình hay máy của bạn yếu và giật khi chơi thì bạn có thể tham khảo thêm mã này...... <br />
---- sv_password: Đặt mật khẩu cho server của bạn....bạn có thể thay đổi mật khẩu theo tuỳ ý mà bạn thích...... <br />
---- sv_timeout 60/0: Mã này để mặc định ban đầu là 60,nhưng khi chỉnh về số 0 thì tất cả các máy đang chơi trong server của bạn đều bị văng ra ngoài hết...nói cách khác là bạn kick 1 lần tất cả những người đang chơi trong mạng của bạn..... <br />
---- sv_lan 1: Kết nối mạng Lan(mạng cục bộ...các máy con có thể nối mạng với nhau)...... <br />
---- sv_gravity (-999 đến 9999): mã bay...chỉnh mã này để điều chỉnh độ cao mà bạn nhảy....số càng cao thì bay càng thấp và ngược lại/.....số mặc định là 800.... <br />
---- sv_clienttrace 1: là mã chính xác cho toàn mạng....khi bạn chỉnh nhiều số 9 thì bạn bắn không trúng địch thủ nhưng vẫn trúng...có tác dụng trong toàn mạng, nghĩa là cả máy chủ lẫn máy khách đều có tác dụng này.....nhưng tôi khuyên là đừng nên dùng vì nó làm sai lệch trình độ của mỗi người đi...và lưu lại trong máy đã chỉnh mã này......không xoá được...cho nên khi chỉnh bạn cũng phải cân nhắc 1 chút..... <br />
---- sv_failuretime 0.5: Thời gian hành động........... <br />
---- sv_waterfriction 1: Tốc độ bơi dưới nước...nó có tác dụng tương tự các mã trên tôi đã nói...... <br />
---- sv_challengetime 15: thêm thời gian hành động............ <br />
---- sv_zmax 4096/00: mã này là mã nhìn xuyên tường...khi vào màn bạn phải nhanh tay chỉnh ngay mã này,.....và phải dùng màn hình 3D thì mới có tác dụng............ <br />
---- sv_skyname: đặt tên cho sky....theo tuỳ ý bạn đặt như thế nào.... <br />
---- sv_maxvelocity 2000: Mã đi nhanh, điều chỉnh tốc độ đi nhanh hơn bình thường....... <br />
---- sv_minrate 0: Tốc độ đi tối thiểu cho phép........ <br />
---- sv_maxrate 0: Tốc độ đi tối đa mà bạn có thể đi được...........<br />
<br />
<br />
<br />
<br />
Các mã họ Mp_ ---- mp_startmoney 800: Mã tiền....là số tiền ban đầu mà bạn sẽ có khi vừa vào màn...........số tiền mà bạn chỉnh chỉ cho phép trong khoảng từ 800$ đến 16000$ mà thôi................... <br />
---- mp_logdetail 0: mã này chỉnh khi từ xa có ai bắn về phía bạn nếu thấy có 1 chấm đỏ ở nòng súng lúc bắn thì đó là kẻ thù và ngược lại nếu không có thì là bạn......(friend) <br />
---- mp_fadetoblack 0: mã này khi chết mới có tác dụng..nghĩa là nếu bạn hay 1 ai trong server bị die thì màn hình của bạn sẽ tự động đen thui lại không cho bạn xem những diễn biến đang xảy ra...số 1 là bật còn 0 là tắt....... <br />
---- mp_buytime 1.5: thời gian tối đa cho phép bạn mua hàng....ví dụ bạn chỉnh là 3 thì bạn có quyền mua hàng trong 3 phút.....ở đây mặc định là 1,5 phút............... <br />
---- mp_winlimit 0: số round đấu tối đa cho phép, ví dụ bạn ghi là 20 thì sau 20 round mà bên nào đạt tới trước thì tự động nó sẽ ngưng cuộc chơi lại..... <br />
---- mp_limitteams 2: số người chơi tối đa ở mỗi bên............. <br />
---- mp_autokick 1: tự động kick những tên bắn bồ hay những người đang ở trạng thái "tĩnh" nghĩa là thoát ra chưa khỏi server.....<br />
---- mp_autoteambalance 1: kick khi có sự chênh lệch về số người chơi ở 2 bên...nếu bên 4 bên 2 thì nó tự động kick cho đều là 3=3.... <br />
---- mp_chasecam 0: Mã này khi bạn chết thì bạn sẽ nhìn được đồng đội mà thôi khi chỉnh số 1..hay 2..... <br />
---- mp_c4timer: Thời gian bom nổ trong các màn de_ số dao động từ 45 đến 90 giây đồng hồ..... <br />
---- mp_freezetime 6: mã này khi chỉnh số 0 thì bạn có thể đi ngay khi vừa vào màn chứ không phải đợi lâu nữa...ở chế độ bình thường bạn phải chờ 6 giây mới được bắt đầu đi.......... <br />
---- mp_roundtime: thời gian cho phép của mỗi round...bạn chỉnh số 3 thì mỗi vòng chỉ có 3 phút thôi............. <br />
---- mp_friendlyfire 0: mã bắn đồng đội.....số 0 là tắt và 1 là bật........ <br />
---- mp_timelimit 0: Thời gian tối đa của mỗi vòng......... <br />
---- mp_maxrounds 0: số round lớn nhất mà bạn chỉnh.....ví dụ khi chỉnh số 30 thì sau 30 round thì nó tự động chuyển sang map khác........ <br />
---- mp_footsteps 1: tốc độ di chuyển nhanh........ <br />
---- mp_flashlight 0/1: bật tắt chế độ sử dụng đèn pin......... <br />
---- mp_hostagepenalty 1/0: bật tắt chế độ trừ tiền khi bạn bắn chết con tin.......... ---- mp_logmessages 0/1: Không cho nói chuyện khi chết giữa các thành viên........ <br />
---- mp_forcechasecam 0/1/2: Mã này khi chết thì bạn chỉ xem được đồng đội của mình mà thôi....... <br />
---- mp_chattime 10: thời gian cho phép bạn chat với nhau <br />
---- mp_weaponstay 0: mã dùng cho súng nhặt được, nó sẽ tự lên đạn cho bạn..... <br />
<br />
Các mã họ Cl_(Client Options) ---- cl_observercrosshair 1: tắt mở chế độ croshair <br />
---- cl_hidefrags 1: xem chỉ số kill death của tất cả các player.... <br />
---- cl_gg: tắt mở chế độ game gaube <br />
---- cl_himodels 0/1: tắt mở chế độ xem higher models <br />
---- cl_yawspeed 210: di chuyển nhanh <br />
---- cl_upspeed 320: trèo thang nhanh <br />
---- cl_movespeedkey 0.3: cho phím linh hoạt <br />
---- cl_anglespeedkey 0.67: cho phím linh hoạt <br />
---- cl_gratestimation 1: nghe rõ tiếng bước chân <br />
---- cl_rol [tab]: 3 mã nghiêng <br />
---- cl_client(tab)999: mã chính xác <br />
---- cl_sidespeed x: thiết lập tốc độ đi nhanh <br />
---- cl_forwardspeed x: thiết lập tốc độ di chuyển tới <br />
---- cl_backwardspeed x: thiết lập tốc độ di chuyển lui <br />
<br />
Các lệnh mua hàng nhanh và các lệnh dùng phím Bind ---- bind E "setinfo lefthand 1": đây là đổi súng sang tay trái <br />
---- bind R "setinfo lefthand 0": tay phải. <br />
<br />
---- alias m1 "r_drawviewmodel 1;bind enter m2" <br />
---- alias m2 "r_drawviewmodel 0;bind enter m1" <br />
<br />
là cái mà các bạn có thể dùng 1 phím enter cho co việc che đầu súng đó.<br />
<br />
bind ins n1 <br />
---- alias n1 "r_luminance 1;bind ins n2" <br />
---- alias n2 "r_luminance 0;bind ins n1" <br />
<br />
bind home l1 <br />
---- alias l1 "setinfo lefthand 1;bind home l2" <br />
---- alias l2 "setinfo lefthand 0;bind home l1" <br />
<br />
bind pgup j1 <br />
---- alias j1 "r_lightstyle 1;bind pgup j2" <br />
---- alias j2 "r_lightstyle 0;bind pgup j1" <br />
<br />
---- bind i "crosshair 0": tắt mở chế độ dùng crosshair <br />
<br />
Các mã khác <br />
---- lefthand (default 1): đổi tay <br />
---- name "tên": mã đổi tên <br />
---- exit: thoát <br />
---- quit: thoát <br />
---- users: xem số người chơi <br />
---- adjust_crosshair: đổi màu nòng nhắm <br />
---- con_color 256 256 256: đổi màu hud <br />
---- timeleft: thời gian thoát khỏi map <br />
---- ping: xem số ping <br />
---- impulse 101: mã tiền (đã chỉnh trước sv_cheat 1) <br />
---- impulse 99: Trên góc phải màn hình của bạn sẽ có một cái Logo của Sierra, mã này hơi khó chỉnh, nhập khoảng 6, 7 lần <br />
---- impulse 195: kick tất cả các máy con <br />
---- impulse 102: mã quăng xương <br />
---- d(ta);3: kick máy chủ <br />
---- volume 1: chỉnh âm lượng âm thanh của loa bạn<br />
<br />
Mã sáng: -lightgamma 2.5 <br />
-ambret-1.001 <br />
-gamma 99 <br />
-bright(tab)99 <br />
<br />
---- restart: khởi động lại server <br />
---- map +Tên map: mã đổi tầng <br />
---- changlelevel: như trên <br />
---- crosshair: dùng nòng nhắm hay không <br />
---- god: bật chế độ god <br />
<br />
---- kick+Tên: kick ai đó ra khỏi server của bạn <br />
---- hostname: đặt tên cho server <br />
---- hostkill: thoát khỏi server <br />
---- killserver: như trên <br />
---- retry: thoát ra rồi quay trở lại <br />
---- skin +tên skin: thay đổi hình dạng người chơi <br />
---- give_weapon: mã mua súng nhanh......các bạn đánh các lệnh dưới đây nếu muốn mua cây nào thì đánh tên của cây đó ra.... <br />
gives Steyr Aug weapon_aug <br />
gives SIG p288 weapon_p288 <br />
gives Scout weapon_scout <br />
gives Para weapon_m249 <br />
gives MP5 weapon_mp5navy <br />
gives MAC-10 weapon_mac 10 <br />
gives M3 Super Shotgun weapon_m3 <br />
gives H&K Sniper Rifle weapon_g3sg1 <br />
gives Glock 18 pistol weapon_glock18 <br />
gives Fn P90 weapon_p90 <br />
gives Dual Berretas weapon_elite <br />
gives Desert Eagle weapon_deagle <br />
gives Commando weapon_sg552 <br />
gives Colt M4a1 Carbine weapon_m4a1 <br />
gives Benelli xm1014 weapon_xm1014 <br />
gives AK-47 weapon_ak47 <br />
gives Arctic Sniper Rifle spaceweapon_awp <br />
gives Flashbang weapon_flashbang <br />
gives HE Grenade weapon_hegrenade <br />
gives Smoke grenade weapon_smokegrenade <br />
gives Bomb Defuser weapon_defuser <br />
gives Arctic weapon_awp <br />
gives SIG 550 weapon_sig550 <br />
gives Ump.45 weapon_ump45 <br />
gives Usp.45 weapon_usp <br />
gives Kevlar Vest weapon_kevlar <br />
gives Nightvision goggles weapon_nightvision <br />
---- skill 1: mã cấp độ 1 người chơi <br />
---- hud_centerid 0/1: bật tắt xem ip <br />
---- notarget 00: là mã khi bạn bắn thì sẽ không có chấm đỏ và thân thể bạn sẽ không sáng lên <br />
---- sidedown: giảm màn hình <br />
---- sideup: tăng màn hình <br />
---- bind: phím tự chọn <br />
---- ghost 0/1: chế dộ xem khi chết <br />
---- max_shell: vỏ bề ngoài tối đa trong các màn <br />
---- max_smokepuffs: hơi thở tối đa trong các map có tuyết<br />
---- fastspiters: 0=mù đều; 1=bình thường; 2=mù hơi khó nhìn dùng cho bom mù <br />
---- net_adress: xem địa chỉ ip <br />
---- togglebrower: dừng chơi và tìm 1 server khác<br />
---- status: xem hostname, version, map, ip, players <br />
---- time: thời gian chơi từ đầu đến giờ <br />
---- timerefresh: quay 360 độ <br />
---- add: thêm vào ai đó <br />
---- +graph: mã nhịp tim, điện tâm đồ <br />
---- -graph: tắt mã nhịp tim <br />
---- zoom_sensitivity_ratio 1.2: mã chỉnh độ nhạy khi nhắm <br />
---- password: chống retry va reconnect <br />
---- escape: thoát khỏi server <br />
---- echo: tạo tiếng vang <o:p></o:p></span></div><div class="MsoNormal">Code cho máy ch<span style="font-family: Arial;">ủ</span><span style="mso-bidi-font-family: "\.VnTime";"> :</span><br />
/sv_cheats 1 - b<span style="font-family: Arial;">ậ</span><span style="mso-bidi-font-family: "\.VnTime";">t cheat</span><br />
/restart - restart game<br />
/impulse 101 - 16k $ ( ph<span style="font-family: Arial;">ả</span><span style="mso-bidi-font-family: "\.VnTime";">i b</span><span style="font-family: Arial;">ậ</span><span style="mso-bidi-font-family: "\.VnTime";">t cheat tr</span><span style="font-family: Arial;">ướ</span><span style="mso-bidi-font-family: "\.VnTime";">c )</span><br />
/mp_freezetime 0 - b<span style="font-family: Arial;">ỏ</span> th<span style="font-family: Arial;">ờ</span><span style="mso-bidi-font-family: "\.VnTime";">i gian </span><span style="font-family: Arial;">đ</span><span style="mso-bidi-font-family: "\.VnTime";">óng b</span><span style="font-family: Arial;">ă</span><span style="mso-bidi-font-family: "\.VnTime";">ng tr</span><span style="font-family: Arial;">ướ</span><span style="mso-bidi-font-family: "\.VnTime";">c m</span><span style="font-family: Arial;">ỗ</span><span style="mso-bidi-font-family: "\.VnTime";">i ván</span><br />
/mp_friendlyfire ( 0 - 1 ) - 0 l<span style="font-family: Arial;">à</span><span style="mso-bidi-font-family: "\.VnTime";"> không cho </span>gi<span style="font-family: Arial;">ế</span><span style="mso-bidi-font-family: "\.VnTime";">t b</span><span style="font-family: Arial;">ồ</span><span style="mso-bidi-font-family: "\.VnTime";"> , 1 l</span><span style="font-family: Arial;">à</span><span style="mso-bidi-font-family: "\.VnTime";"> ng</span><span style="font-family: Arial;">ượ</span><span style="mso-bidi-font-family: "\.VnTime";">c l</span><span style="font-family: Arial;">ạ</span><span style="mso-bidi-font-family: "\.VnTime";">i</span><br />
/sv_gravity (-999 <span style="font-family: Arial;">đế</span><span style="mso-bidi-font-family: "\.VnTime";">n 999999) - ch</span><span style="font-family: Arial;">ỉ</span><span style="mso-bidi-font-family: "\.VnTime";">nh </span><span style="font-family: Arial;">độ</span><span style="mso-bidi-font-family: "\.VnTime";"> nh</span><span style="font-family: Arial;">ả</span><span style="mso-bidi-font-family: "\.VnTime";">y</span> cao<br />
/changelevel (tên map) - <span style="font-family: Arial;">đổ</span><span style="mso-bidi-font-family: "\.VnTime";">i map</span><br />
/mp_buytime (s<span style="font-family: Arial;">ố</span><span style="mso-bidi-font-family: "\.VnTime";"> phút) - ch</span><span style="font-family: Arial;">ỉ</span><span style="mso-bidi-font-family: "\.VnTime";">nh th</span><span style="font-family: Arial;">ờ</span><span style="mso-bidi-font-family: "\.VnTime";">i</span> gian mua <span style="font-family: Arial;">đồ</span><span style="mso-bidi-font-family: "\.VnTime";"> c</span><span style="font-family: Arial;">ủ</span><span style="mso-bidi-font-family: "\.VnTime";">a m</span><span style="font-family: Arial;">ỗ</span><span style="mso-bidi-font-family: "\.VnTime";">i ván không nh</span><span style="font-family: Arial;">ớ</span><span style="mso-bidi-font-family: "\.VnTime";"> l</span><span style="font-family: Arial;">à</span><span style="mso-bidi-font-family: "\.VnTime";"> giây hay phút n</span><span style="font-family: Arial;">ữ</span><span style="mso-bidi-font-family: "\.VnTime";">a</span><br />
/mp_roundtime [3 <span style="font-family: Arial;">đế</span><span style="mso-bidi-font-family: "\.VnTime";">n</span> 15] - th<span style="font-family: Arial;">ờ</span><span style="mso-bidi-font-family: "\.VnTime";">i gian m</span><span style="font-family: Arial;">ỗ</span><span style="mso-bidi-font-family: "\.VnTime";">i ván</span><br />
/sv_clienttrace 9999 - <span style="font-family: Arial;">đạ</span><span style="mso-bidi-font-family: "\.VnTime";">n t</span><span style="font-family: Arial;">ự</span><span style="mso-bidi-font-family: "\.VnTime";"> dí</span><br />
<br />
D<span style="font-family: Arial;">à</span><span style="mso-bidi-font-family: "\.VnTime";">nh cho client ( máy</span> con )<br />
/gl_zmax [0-9999] – nh×n xuyªn t<span style="font-family: Arial;">ườ</span><span style="mso-bidi-font-family: "\.VnTime";">ng ( m</span><span style="font-family: Arial;">ặ</span><span style="mso-bidi-font-family: "\.VnTime";">c </span><span style="font-family: Arial;">đị</span><span style="mso-bidi-font-family: "\.VnTime";">nh l</span><span style="font-family: Arial;">à</span><span style="mso-bidi-font-family: "\.VnTime";"> 3600</span> )<br />
/+reload - t<span style="font-family: Arial;">ự</span><span style="mso-bidi-font-family: "\.VnTime";"> </span><span style="font-family: Arial;">độ</span><span style="mso-bidi-font-family: "\.VnTime";">ng thay </span><span style="font-family: Arial;">đạ</span><span style="mso-bidi-font-family: "\.VnTime";">n</span><br />
/timeleft - xem th<span style="font-family: Arial;">ờ</span><span style="mso-bidi-font-family: "\.VnTime";">i gian còn l</span><span style="font-family: Arial;">ạ</span><span style="mso-bidi-font-family: "\.VnTime";">i c</span><span style="font-family: Arial;">ủ</span><span style="mso-bidi-font-family: "\.VnTime";">a</span> map<br />
/crosshair [1-5] - ch<span style="font-family: Arial;">ố</span><span style="mso-bidi-font-family: "\.VnTime";">ng m</span><span style="font-family: Arial;">ở</span><span style="mso-bidi-font-family: "\.VnTime";"> nßng l</span><span style="font-family: Arial;">ớ</span><span style="mso-bidi-font-family: "\.VnTime";">n khi b</span><span style="font-family: Arial;">ắ</span><span style="mso-bidi-font-family: "\.VnTime";">n</span><br />
/mp_footsteps [0 hay 1] - b<span style="font-family: Arial;">ậ</span><span style="mso-bidi-font-family: "\.VnTime";">t t</span><span style="font-family: Arial;">ắ</span><span style="mso-bidi-font-family: "\.VnTime";">t tiêng chân</span><br />
/adjust crosshair - ch<span style="font-family: Arial;">ỉ</span><span style="mso-bidi-font-family: "\.VnTime";">nh m</span><span style="font-family: Arial;">à</span><span style="mso-bidi-font-family: "\.VnTime";">u n</span>òng<br />
/lambert -1.01 - th<span style="font-family: Arial;">ấ</span><span style="mso-bidi-font-family: "\.VnTime";">y ng</span><span style="font-family: Arial;">ườ</span><span style="mso-bidi-font-family: "\.VnTime";">i phát sáng ( trong bóng t</span><span style="font-family: Arial;">ố</span><span style="mso-bidi-font-family: "\.VnTime";">i )</span><br />
/sv_aim Auto - nòng t<span style="font-family: Arial;">ự</span><span style="mso-bidi-font-family: "\.VnTime";"> nh</span><span style="font-family: Arial;">ắ</span><span style="mso-bidi-font-family: "\.VnTime";">m theo m</span><span style="font-family: Arial;">ụ</span><span style="mso-bidi-font-family: "\.VnTime";">c</span> tiêu ( dùng v<span style="font-family: Arial;">ớ</span><span style="mso-bidi-font-family: "\.VnTime";">i súng súng ng</span><span style="font-family: Arial;">ắ</span><span style="mso-bidi-font-family: "\.VnTime";">m )</span><br />
/cl_forwardspeed 999 - <span style="font-family: Arial;">đ</span><span style="mso-bidi-font-family: "\.VnTime";">i t</span><span style="font-family: Arial;">ớ</span><span style="mso-bidi-font-family: "\.VnTime";">i tr</span><span style="font-family: Arial;">ướ</span><span style="mso-bidi-font-family: "\.VnTime";">c nhanh</span> h<span style="font-family: Arial;">ơ</span><span style="mso-bidi-font-family: "\.VnTime";">n<br />
</span>/cl_backspeed 999 - <span style="font-family: Arial;">đ</span><span style="mso-bidi-font-family: "\.VnTime";">i v</span><span style="font-family: Arial;">ề</span><span style="mso-bidi-font-family: "\.VnTime";"> sau nhanh h</span><span style="font-family: Arial;">ơ</span><span style="mso-bidi-font-family: "\.VnTime";">n</span><br />
/cl_sidespeed 999 - <span style="font-family: Arial;">đ</span><span style="mso-bidi-font-family: "\.VnTime";">i qua l</span><span style="font-family: Arial;">ạ</span><span style="mso-bidi-font-family: "\.VnTime";">i</span> nhanh h<span style="font-family: Arial;">ơ</span>n<br />
/impulse 102 - kinh d<span style="font-family: Arial;">ị</span></div><div class="MsoNormal"><br />
</div><div class="MsoNormal"><b><span style="color: #222222; font-family: Verdana; font-size: 9.0pt;">sv_chea(bấm TAB)1 (enter)</span></b><span style="color: #222222; font-family: Verdana; font-size: 9.0pt;"> -> lệnh cho phép hóa tiền (hóa lệnh này thì phải restart lại trò chơi để hiệu lực)<br />
<b>re(bấm TAB) (enter)</b> --> khởi động lại trò chơi)<br />
<b>cl_si(bấm TAB)9999 (enter)</b> --> lệnh cho phép đi chéo<br />
<b>impulse(bấm TAB)101</b> --> lệnh xin tiền (sau khi đã hóa lệnh cho phép hóa tiền)<br />
<b>Bind mouse2 "+jump;impulse 101"</b> --> hóa lệnh này thì khi bấm mouse2 thì sẽ nhảy và xin luôn tiền.<br />
<b>addbot(khoảng trống, phím Space)1.100</b> --> 1.100 hóa bot cướp, 2.200 hóa bot cảnh sát (lệnh này chỉ dùng với phiên bản cho phép hóa bot hình như phiên bản hafl life 1.1 thôi thì phải)<br />
<b>adj(bấm TAB) (enter)</b> --> đổi màu tâm<br />
<b>mp_autoteam(bấm TAB) 0 </b>--> hóa chống đầy team (cho phép chênh lệch số người giữa bên cảnh và cướp vd: cướp 8 người mà cảnh chỉ có 4 )<br />
<b>sv_gravi(Bấm TAB)200 (enter)</b> --> bạn có thể đặt 100 hoặc một số nào đó 800 là mặc định ) -> hóa bay<br />
Ngoài ra khi đã hóa tiền bạn có thể hóa lệnh mua tất cả nhưng thứ bạn cần như sau :<br />
<b>Bind / "buy;menuselect 1;menuselect 3;buy menuselect 7;buy;menuselect 4;menuselect 6;buy;menuselect 6"</b> --> bạn copy y nguyên cả khoảng trống (hóa xong lệnh này thì khi bấm / bạn sẽ mua luôn súng 1.3 mua luôn đạn, mua cả súng 4.6 và cả đạn. Bạn có thể phát triển thêm theo cấu trúc đó là được<o:p></o:p></span></div><div class="MsoNormal"><span style="color: #222222; font-family: Verdana; font-size: 9.0pt;">r</span><b><span style="color: blue; font-family: Verdana; font-size: 10.0pt;">_drawe [tab] 5 : Đóng băng cơ thế, giúp thấy rõ được địch thủ hơn. Nhuưng các Beta mới klhông dùng được. <br />
<br />
cl_rol [tab] [số tuỳ ý] : Số càng cao thì ngiêng càng nhiều. Mã này thì được nhiều người chơi. Nhưng tui khuyến cáo đừng nên chính, để mặc định là 2 hoặc chỉnh ít thôi. Lợi đụng mã này nhiều quá có thể tổn hại đến mắt và não. <br />
<br />
cl_hi [tab] 0(default 1) : Thấy rõ chỉ số Kill/Death của đối thủ. Tò mò thôi ý mà. <br />
<br />
sens [tab] [số tuỳ chọn](defualt 6.9) : độ nhạy của chuột. Cái này tui khuyên để mặc định thôi. <br />
<br />
ligh [tab] [số tuỳ chọn](default 2) : Độ sáng của nền, số càng nhỏ thì càng sáng. Cái này thì nên cho là 4 là tốt nhất để kết hợp với các mã đươi đây. <br />
<br />
lambert -1.001 : Cơ thể sáng lên. Kết hợp với light thì càng tối sẽ càng nhìn rõ được đối thủ(dùng cho nhưng tên nào khoái tắt đèn) <br />
<br />
gamm [tab] [số tuỳ chọn](default Unknown) : Cái này thì số càng cao thì càng sáng. <br />
<br />
bright [tab] [số tuỳ chọn](default Unknown) : Cài này số càng cao thì càng sáng. Nhưng tới 5 là hết cỡ. <br />
<br />
Tiếp theo là tui xin post tiếp các cheat code mà dùng để ăn gian, gọi theo kiểu các tay Gamer là chơi bẩn, nhưng quý vị đừng hiểu lầm, cái này là "lâu lâu ngứa nghề dụ con nít một chút cho dzui ý mừ", dùng để nghiên cứu và ứng dụng thêm thôi nhé quý vị, những mã này sẽ cho ta thấy hết tất cả những kiều thú vị trong Counter-Strike : <br />
<br />
gl_zma [tab] 0 [default 4620] : Nhìn xuyên tường, những bạn phải vào Config, Video, Video Modes chỉnh Direct 3D mới dùng được mã này. Máy bạn phải đủ mạnh. Dùng trong các Beta cũ, chơi mạng. <br />
<br />
sv_che [tab] 1 [default 0] : Bật chế độ cheat code. <br />
<br />
impulse 101 : Mã tiền, 16.000 $ (wá xưa) <br />
<br />
impulse 99 : Trên góc phải màn hình của bạn sẽ có một cái Logo của Sierra, mã này hơi khó chỉnh, nhập khoảng 6,7 lần xem có hiện ra hay không, nếu không thì nhập lại, khi nào hiện ra thì thôi(không lâu đâu), "hì hì, lâu lâu cũng phải cần trang trí một chút chứ nhỉ ?" <br />
<br />
impulse 195 : kick tất cả những người đang chơi trên mạng của bạn(mã dành cho máy chủ). Hì hì, chơi mã này coi chừng bị kick ra khỏi quán đó nha. <br />
<br />
bind [phím tuỳ chọn] "fov [số tuỳ chọn]" (default 90) : Nhìn xa, gọi nôm na là nhắm. Nhập mã vào rồi thì gõ vào phím bạn chọn (bind) thì vũ khí bạn đang mạng sẽ tự động nhắm. Số càng ít thì nhắm càng gần, nhưng ở đây tui khuyên là để số khoảng 50. Để số nhỏ quá như là 2 hoặc 3 thì nhắm đúng là gần thật nhưng bù lại sẽ rất khó điều khiển con chuột, rất khó di chuyển. <br />
<br />
mp_starmo [tab] (default 800) : Điều chỉnh số tiền khi vừa vào màn. Bạn muốn chỉnh bao nhiêu cũng được, nhưng phải lớn hơn hoặc bằng 800. Cái mã này dành cho beta 1.4 trở lên. <br />
<br />
sv_restart [tab] 1 : Bạn là máy chủ ? Bạn đang chơi mà lại thấy chán quá, muốn restart lại tất cả chỉ số kill/death của bạn để khỏi bị mạng tiếng là bắn dở(dzí dzụ thui nha). Hãy nhập lệnh này, nó sẽ restart lại tất cả những chỉ số kill/death, tất cả, nói chung là từ đầu trận đến giờ, chỉ trong một giây. Nhanh hơn lệnh restart nhiều chứ bạn nhỉ ? Mà lại không lằm phiền người khác phải chờ nữa. <br />
<br />
mp_buyti [tab] [số tuỳ chọn](default 1.5) : Điều chỉnh mức giờ mua "hàng", bạn muốn chỉnh 999 cũng được, tức là bạn muốn mua cho đến khi qua màn cũng hổng ai cấm. Mặc định là 90 giây, tức là 1.5 phút. Lưu ý : Mã dùng cho Beta 1.4 trở lên. <br />
<br />
mp_autotea [tab] 0 (default 1) : bạn là người chơi giỏi ? Bạn muốn chứng tỏ mình với tất cả mọi người "ta đây bắn hay nhất xóm" ? hay nhập mã này, nó giúp cho không còn sự cân bằng giữa hai đội Terror và Counter với nhau nữa. Tức là không có vụ tự động đổi người nhất bảng bên đây qua bên kia khi (ví dụ) bên đây 2 người, bên kia 4 người. Như vậy "ta dây chấp chúng bay 4 người lun đó, ta chỉ cần một mạng là bắn các người tơi bời gùi". <br />
<br />
***Tiếp tục, mới các bạn đón xem tiếp các Cheat Code mới và cũ do tui dày công học lỏm và nghiên kíu được : <br />
<br />
mp_c4tim [tab] [số tuỳ chọn] : Cái mã này thì có lẽ ít ai cần, nhưng thôi tui cũng đưa ra cho mọi người xem chơi, mã này có tác dụng điều chỉnh thời gian nổ cho trái bomb C4 trong các màn de_... . Nhỏ nhất là 15, lớn nhất là 90. Sau đó là bùm ! <br />
<br />
mp_fre [tab] [số tuỳ chọn](default 0) : Một vài phiên bản cũ thì default là 6. Cái này là mã để chỉnh thời gian đóng băng khi vừa mở màn, nó giúp ta khoá chân mấy tên cao thủ mua đồ wá nhanh lại. Không làm gì được cả. Hè hè. Mặc định 6 giây. <br />
<br />
mp_roun [tab] [số tuỳ chọn] (default 5) : Thời gian của từng màn. mặc định 5 phút. Nếu bạn chơi Counter-Strike đơn mà với những tên bot bờm quá xá thì đây là mã thích hợp cho bạn . <br />
<br />
mp_fr [tab] [số tuỳ chọn](default 1) : Mã làm tổn thương đồng đội khi bắn, thường thì nhưng tay Gamer chỉnh là 0, tức là disable mã này. Nhưng thui kệ lâu lâu ta chơi mã này một cái cho nó... có cảm giác thực tế một chút chứ nhỉ <br />
<br />
sv_ste [tab] [số tuỳ chọn] (default 20) : Mã chèo tường, theo như các tay Gamer gọi. Khi chỉnh số lên 999999 thì bạn sẽ trèo qua luôn cả những bức tường kiên cố nhất. Mã này áp dụng cho Counter trong màn mansion là hết ý. Mới vừa mua cây súng nhắm xong là trèo lên bức tường canh me liền. <br />
<br />
setinfo lefthand 0 (default 1): trong khi chơi CS bạn có để ý là mình cầm súng tay nào không ? Chính là tay trái đấy, mã này sẽ làm bạn đổi không khí một chút, nó sẽ chuyển tay bạn cầm súng thay vì là tay trái nó sẽ chuyển qua tay phải, thú vị chứ nhỉ ? <br />
<br />
ad [tab] : khì khì, mã này dùng để đổi màu cái crosshair (cái nòng nhắm ấy) của bạn, nó đổi cũng được khá nhiều màu : đỏ, hồng, xanh dương, vàng... làm mình nhắm kĩ hơn đấy các bạn ạ, nhưng chú ý mã này dùng cho các phiên bản mới thôi. <br />
<br />
bind [phím tuỳ chọn] "sv_fiction [càng nhìu số 9 càng tốt]" : Khì khì, mã này hay lắm đây, nó giúp tăng tốc đến mức tối ưu tất cả mọi hoạt động trong map. Nhanh còn hơn là đi xe Wave nữa đấy. Những mã này chỉ tác dụng trong khoảng 3 giây thôi </span></b></div>nguyendangtuan95@gmail.comhttp://www.blogger.com/profile/11769458566723493488noreply@blogger.com8tag:blogger.com,1999:blog-5575885810563018688.post-91090980891267323872011-07-13T06:36:00.000-07:002011-07-13T06:36:04.991-07:00cách làm một số loại Ma tran<div class="MsoNormal"><span style="font-family: Verdana; font-size: 10pt;"><span class="Apple-style-span" style="color: red;"><b>Mình đưa một số loại ma trận cho các bạn học làm ha</b></span><o:p></o:p></span></div><div class="MsoNormal"><span style="color: black; font-family: Verdana; font-size: 10.0pt;">B1: Ấn mode chọn SD, sau đó ấn 9M+ đến 42 lần,ấn tiếp 2 và sau đó ấn nút lên nhấn 303030...3 đến hết được thì thôi.<br />
B2:Ấn = = tiếp ấn 0 1 và ấn nút qua trái đến khi tới sát số 3( cách làm như ma trận bình thường), ấn tiếp shift <st1:state w:st="on">del</st1:state> để hiện dấu nhấy(chèn) sau đó nhấn <st1:place w:st="on"><st1:state w:st="on">del</st1:state></st1:place> để xóa hết 303030...3 đó đi. Khi xóa hết, màng hình lúc này trắng ko còn các số 3030 nữa. Bây giờ bạn ấn thêm một lần <st1:place w:st="on"><st1:state w:st="on">del</st1:state></st1:place> nữa, bây giờ màng hình hiện lên các kí tự khác nhau như: mpmp.v..v...Mặc kệ bạn ko cần để ý tới, bạn ấn shift <st1:place w:st="on"><st1:state w:st="on">del</st1:state></st1:place> để tắt dấu nhấy di và nhập đoạn mã shift nCr .nCr. nCr. ( để ra P.C.C.) đến khi thấy chữ log xornm thì bạn vào giữa chỗ trống của 2 kí tự đó và chèn số 0 vào.<br />
B3: Lúc này, bạn chỉ việc lui về ban đầu đến hết được thì thôi, ấn shift <st1:state w:st="on">del</st1:state> để hiện dấu nhấy và ấn <st1:state w:st="on">del</st1:state> <st1:place w:st="on"><st1:state w:st="on">del</st1:state></st1:place> 9. <st1:place w:st="on"><st2:givenname w:st="on">Xong</st2:givenname> <st2:middlename w:st="on">phần</st2:middlename> <st2:sn w:st="on">I.</st2:sn></st1:place><br />
B4: Bạn ấn nút ON hoặc nút AC để tắt ma trận đi, tiếp bạn ấn nút lên và ấn 5 rùi ấn = = và sau đó ấn 0 1. Lúc này bạn ấn <st1:state w:st="on">del</st1:state> <st1:place w:st="on"><st1:state w:st="on">del</st1:state></st1:place>, màng hình hiện lên : : : P.C.C.P..bạn ấn nút qua trái tới đầu 2 dấu : ( bước này quan trọng, nếu bạn thấy có ba dấu hai chấm thì lui 3 lần, còn hai dấu chấm thì lui 2 lần. Chú ý : phải tới chỗ dấu hai chấm đầu tiên rồi mới lui và ko nên lui quá, nếu lui quá thì bạn sẽ làm lại từ đầu đấy) và Ấn shift nCr. nCr.nCr. cứ như thế đến hết được thì thôi.<br />
B5: Sau khi ấn như trên thì bạn ấn nút tới sẽ thấy log xornm thì chèn số 0 vào, bạn ấn lui về đến hết được và bạn ấn nút shift del và del del 9, màng hình lúc này hiện lên cho bạn chọn, bạn ấn 0 1 rùi ấn shift del để tắt dấu nháy , chèn bất kì kí tự nào bạn muốn( vd: 1,2,3,4...Ans hay sin v...v....) cứ mỗi kí tự là mỗi kiểu khác nhau và cuối cùng bạn ấn shift del del del 9. Xong bây giờ bạn có chạy bất kì kiểu kí tự nào bạn muốn.<br style="mso-special-character: line-break;" /> <!--[if !supportLineBreakNewLine]--><br style="mso-special-character: line-break;" /> <!--[endif]--><o:p></o:p></span></div><div class="MsoNormal">Bai khac</div><div class="MsoNormal"><span style="color: black; font-family: Verdana; font-size: 10.0pt;">Còn cách này nữa nè ( làm máy hiện ra hình con heo ) . <br />
- Mode <span style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0cm;">3</span>,<span style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0cm;">1</span> ,<span style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0cm;">9</span> rồi <span style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0cm;">M+</span> tới 40 rồi dừng lai(</span><span style="color: black;">nÕu Ên qu¸ 40 lÇn th× cø tiÕp tôc Ên ®Õn hÕt råi Ên</span><span style="border: solid windowtext 1.0pt; color: black; font-family: Verdana; font-size: 10.0pt; mso-border-alt: solid windowtext .5pt; padding: 0cm;">AC </span><span style="color: black; font-family: Verdana; font-size: 10.0pt;"><span style="mso-spacerun: yes;"> </span>sau đó bấm mũi tên đi lên cho hiện ra chữ Freq40= sau đó bấm 3030303030... kết thúc là số 3 sau đó là bằng bằng ( = = 2 lan ) an <span style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0cm;">0</span>,<span style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0cm;">1</span> và bấm dấu mũi tên sang trái bấm cho đến sát số 3 sau đó bấm <span style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0cm;">Shift</span> <span style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0cm;">DEL</span> bấm<span style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0cm;"> del </span>cho hết số dẫy số 3,0 nhớ để ý nhé .Sau khi bấm hết số 3 bạn bấm tiếp 1 lần<span style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0cm;"> DEL</span> và sau đó bạn bấm nhanh <span style="mso-spacerun: yes;"> </span><span style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0cm;">DEL9</span> <span style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0cm;">DEL</span> <span style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0cm;">9</span> <span style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0cm;">DEL</span> <span style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0cm;">9</span> <span style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0cm;">DEL</span> <span style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0cm;">9</span> (4</span><span style="color: black; font-family: Verdana;"> l</span><span style="color: black;">Çn</span><span style="color: black; font-family: Verdana; font-size: 10.0pt;">) và<span style="mso-spacerun: yes;"> </span>sau đó bạn bấm 3 lần 123456789 sau khi bấm xong 3 lần 123456789 thì bạn dời mũi tên qua mé tay phải đến khi nào bạn gặp cái dấu vuông nh</span><span style="color: black; font-size: 12.0pt;"> </span><span style="color: black; font-family: Verdana; font-size: 10.0pt;">sau(mpmpmp<!--[if gte vml 1]><v:shapetype
id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t"
path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"> <v:stroke joinstyle="miter"/> <v:formulas> <v:f eqn="if lineDrawn pixelLineWidth 0"/> <v:f eqn="sum @0 1 0"/> <v:f eqn="sum 0 0 @1"/> <v:f eqn="prod @2 1 2"/> <v:f eqn="prod @3 21600 pixelWidth"/> <v:f eqn="prod @3 21600 pixelHeight"/> <v:f eqn="sum @0 0 1"/> <v:f eqn="prod @6 1 2"/> <v:f eqn="prod @7 21600 pixelWidth"/> <v:f eqn="sum @8 21600 0"/> <v:f eqn="prod @7 21600 pixelHeight"/> <v:f eqn="sum @10 21600 0"/> </v:formulas> <v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/> <o:lock v:ext="edit" aspectratio="t"/> </v:shapetype><v:shape id="_x0000_i1025" type="#_x0000_t75" style='width:7.5pt;
height:6.75pt'> <v:imagedata src="file:///C:\DOCUME~1\Admin\LOCALS~1\Temp\msohtml1\01\clip_image001.png"
o:title=""/> </v:shape><![endif]--><!--[if !vml]--><img height="9" src="file:///C:/DOCUME~1/Admin/LOCALS~1/Temp/msohtml1/01/clip_image002.jpg" v:shapes="_x0000_i1025" width="10" /><!--[endif]-->mpmp) thì bạn </span><span style="color: black; font-size: 12.0pt;">®a con trá vµo c¸i dÊu ph©n sè vµ</span><span style="color: black; font-family: Verdana; font-size: 12.0pt;">bấm</span><span style="color: black; font-family: Verdana; font-size: 10.0pt;"> Alpha C rồi dấu chấm sat số 0 rồi <span style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0cm;">nCr</span> rồi lại chấm và <span style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0cm;">Shift</span> <span style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0cm;">nCr</span> bấm vậy 5 lần(C.<b style="mso-bidi-font-weight: normal;">C</b>.<b style="mso-bidi-font-weight: normal;">P</b>) sau đó bấm đẩy mũi tên qua mé tay phải cho đến khi cái dấu _ nhấp nháy của bạn nó nằm giữa chứ log_xorn rồi bạn bấm <span style="mso-spacerun: yes;"> </span>Shift DEL 9 ( bấm nhanh chút nhé ) là màn hình sẽ chạy 1 đoạn đen đen sau đó bạn đè số <span style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0cm;">3</span> với s</span><span style="color: black; font-size: 12.0pt;">è</span><span style="color: black; font-family: Verdana; font-size: 10.0pt;"> <span style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0cm;">8</span> rồi bấm <span style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0cm;">AC</span> ( thường thì 1 cái là ra hình con heo còn nếu chưa ra bấm vài cái ) còn con rồng thì đề <span style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0cm;">3</span> với <span style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0cm;">9</span> rồi <span style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0cm;">AC</span>. <o:p></o:p></span></div><div class="MsoNormal">Bai khac </div><div class="MsoNormal"><span style="color: #666666; font-family: Arial; font-size: 13.5pt;">Đặt pass cho máy(</span><span style="color: #666666; font-size: 13.5pt; mso-bidi-font-family: Arial;">c¸i nµy khã lµm l¾m ®Êy)</span><span style="color: #666666; font-family: Wingdings; font-size: 24.0pt; mso-ascii-font-family: "\.VnTime"; mso-bidi-font-family: Arial; mso-char-type: symbol; mso-hansi-font-family: "\.VnTime"; mso-symbol-font-family: Wingdings;"><span style="mso-char-type: symbol; mso-symbol-font-family: Wingdings;">J</span></span><span style="color: #666666; font-family: Wingdings; font-size: 24.0pt; mso-ascii-font-family: "\.VnTime"; mso-bidi-font-family: Arial; mso-char-type: symbol; mso-hansi-font-family: "\.VnTime"; mso-symbol-font-family: Wingdings;"><span style="mso-char-type: symbol; mso-symbol-font-family: Wingdings;">K</span></span><span style="color: #666666; font-family: Wingdings; font-size: 24.0pt; mso-ascii-font-family: "\.VnTime"; mso-bidi-font-family: Arial; mso-char-type: symbol; mso-hansi-font-family: "\.VnTime"; mso-symbol-font-family: Wingdings;"><span style="mso-char-type: symbol; mso-symbol-font-family: Wingdings;">L</span></span><span style="color: #666666; font-family: Arial; font-size: 13.5pt;"><br />
-Mode REG LIN Shift ; 9 M+(26 lan) 9M+ mui ten len <br />
-30303030.....0303 = = 01 <- (lui tien sat lai so:3) <br />
-Shift DEL (va DEL den khi trang man hinh) <br />
-Shift DEL (va go Password can lam cua ban vao) <br />
-Chu y:4<<password<<8 <br />
- --> (bảy cai) va chi duoc "tiến" tìm các kí tự khác "mp" thì Del hết đi <br />
-Khi màn hình xuất hiện trắng thì gõ lai password lần 2 va tiếp tụ tìm các kí tự khác "mp" Del hết đi. <br />
-Đến khi màn hình chỉ còn "mp" thi ấn Del 7 cái. <br />
-Tiep tuc ấn:Alpha M Alpha M 123..89123..89 <br />
-Khi màn hình đứng va hiện NotNotNot....thi ấn tiếp <br />
-Shift Alpha MODE <- ^ -> CALC fdx 1/x Const ( Phần này tôi chỉ viết cho 570Ms ,còn may 500Ms thì làm tương tự chi cần thay các kí tự khác theo thứ tự các phím như máy 570Ms)và ấn mũi tên đi xuống ,Ab/c Căn bận 2 X bình ^ log ln (-) độ hyp......và theo thứ tự từ trên xuống. <br />
-Đến khi màn hình hiện [25________________OK(t) thì ấn On <br />
-Khi này xem màn hình đã xuất hiện số nhớ M chưa(gần như khóa máy bình thường đó) vậy là được.Nếu không thì phải làm lại từ đầu. <br />
-Tiếp tục vào MODE Disp chọn d/c <br />
-vào MODE EQN --> chọn 2(Degree?) <br />
-tiếp tục ấn === và ấn ON <br />
-Khi mở máy thì ấn tổ hợp 3 phím "Shift 7 On" và làm thao tác kiểm tra phím.Đến khi kiểm tra xong thấy có kí tự nhấp nháy thì gõ password vào và ấn = thì máy được mở. <br />
-Chú Ý: nếu mà quên mất password thì phải tháo pin ra để vài giây và nhấn On vài cái. H</span><span style="color: #666666; font-size: 13.5pt; mso-bidi-font-family: Arial;">Õt</span><span style="color: #666666; font-family: Arial; font-size: 13.5pt;"><br />
<br />
KHOA MAY<br />
1/ mode 3 1 <br />
2/ 1 M+ --> DataFull AC 2 <br />
3/ 303030303...30303 = = 0 1 <br />
Thấy hiện 1 error là đúng (error nào cũng được), không thì làm lại bước 1 <br />
4/ < nếu thấy con trỏ chưa sau số 3 thì <<<< đến khi nó đứng ngày sau số 3 thì nhấn Shift DEL, DEL hết đến khi: <br />
[ <br />
<br />
5/ DEL 1 cái nữa, shift DEL <br />
6/ > tìm tất cả các kí tự khác mp thì DEL hết <br />
7/ Sau khi del hết thì . <br />
. <br />
>....>....>....>....>.. đến khi nhấn ..>.. không thấy nó qua phải nữa, tức là: <br />
....mpmp...mpmpmp <br />
8/ <st1:city w:st="on">Tuy</st1:city> <st1:state w:st="on">DEL</st1:state> những kí tự khác mp nhưng cố gắng số lần <st1:place w:st="on"><st1:state w:st="on">DEL</st1:state></st1:place> là lẻ (13,15,23,25,29..) thì % làm đúng sẽ cao hơn <br />
rồi Alpha M Alpha M: <br />
....mpmpmp....mpmpMM <br />
rồi ấn 9999999... đến khi nó hiện bên góc trái trên của màn hình, nếu thấy chữ M hiện lên thì đúng, bạn có thể tiếp tục, không thì làm lại bước 1 <br />
8/ chọn mode Disp d/c <br />
<br />
9/ chọn EQN bất kì <br />
10/ Alpha M= <br />
11/Ấn = liên tục <br />
Xong ! <br />
<b style="mso-bidi-font-weight: normal;">#chu ý</b><o:p></o:p></span></div><div class="MsoNormal"><span style="font-family: Arial; font-size: 13.5pt;">(</span><span style="font-size: 13.5pt; mso-bidi-font-family: Arial;">®Ó më m¸y th¸o pin ra Ên <span style="border: solid windowtext 1.0pt; mso-border-alt: solid windowtext .5pt; padding: 0cm;">ON</span> vµi lÇn råi l¾p pin l¹i)</span><span style="color: #666666; font-family: Arial; font-size: 13.5pt;"><br />
Với máy 25.4 ,25.1 thì có cách khác nhanh hơn<o:p></o:p></span></div><span style="color: #666666; font-family: Arial; font-size: 13.5pt; mso-ansi-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-font-family: "Times New Roman"; mso-fareast-language: EN-US;">Mode ..>..RED..>..LIN <br />
S(shift) ;(Y) 9 M+ (26 lần) <br />
9 M+ <br />
AC <br />
Độ 0 Độ 0 ....(kịch) = AC ^ <br />
9 = = 0 1 <br />
MODE EQN 2 MODE DISP D/C <br />
ANS ======= <br />
<br />
Mode REG Lin <br />
1 M+ đến khi ra Data Full AC 2 <br />
gõ độ.độ.độ.độ...&# 273;ến khi ko gõ dc nữa (dấu độ và dấu chấm thập phân), nhấn = Syntax error AC <br />
nhấn ^ 9 = = 0 1, nếu thấy máy hiện <br />
1 _ <br />
-1.6 x10^1.1 (số khác cũng dc!) <br />
Mode Disp d/c <br />
Mode EQN > 2 (degree) Ans = ^ on.<br style="mso-special-character: line-break;" /> <!--[if !supportLineBreakNewLine]--><br style="mso-special-character: line-break;" /> <!--[endif]--></span>nguyendangtuan95@gmail.comhttp://www.blogger.com/profile/11769458566723493488noreply@blogger.com0