Click here to Skip to main content
15,890,186 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to get the fullpath from argument of my application (VS C++ 2005)? Pin
W. Kleinschmit24-Feb-09 14:45
W. Kleinschmit24-Feb-09 14:45 
AnswerRe: How to get the fullpath from argument of my application (VS C++ 2005)? Pin
ky_rerun24-Feb-09 14:47
ky_rerun24-Feb-09 14:47 
AnswerRe: How to get the fullpath from argument of my application (VS C++ 2005)? Pin
«_Superman_»24-Feb-09 17:51
professional«_Superman_»24-Feb-09 17:51 
QuestionAll pipes intances are busy Pin
Arif Liminto24-Feb-09 14:04
professionalArif Liminto24-Feb-09 14:04 
QuestionCan someone check this in VC++ 2008 Pin
cmk24-Feb-09 13:39
cmk24-Feb-09 13:39 
AnswerRe: Can someone check this in VC++ 2008 Pin
Stuart Dootson25-Feb-09 8:14
professionalStuart Dootson25-Feb-09 8:14 
GeneralRe: Can someone check this in VC++ 2008 Pin
cmk25-Feb-09 9:29
cmk25-Feb-09 9:29 
QuestionMy Javascript gone as far as it can, I need some C++ starting points Pin
skieeterno24-Feb-09 12:12
skieeterno24-Feb-09 12:12 
Hi all,

I have written a Javascript code that moves a dot around the screen randomly, and it does output my result at the end of the code, however I feel I have gone as far as I can with this code and would like a different way to create the program. First thought was using C++,

Here is the code:

<code> "http://www.w3.org/TR/html4/strict.dtd"&gt;
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">

<style type="text/css">
body {
overflow:hidden;
}
#container div,#timer {
width:250px;
line-height:30px;
padding-left:10px;
border:3px double #999;
margin:4px 0;
}
.hide {
display:none;
}
#dot {
width20px;
font-size:36px;
color:#f00;
position:absolute;
}
#coords {
padding:10px;
border:3px double #999;
margin-top:10px;
font-family:courier,monospace;
font-size:12px;
text-align:justify;
}
</style>

<script type="text/javascript">

/****** these values may be edited *****/

var iterations=2000;
var height=999;
var width=999;
var temp1=500;
var temp2=500;

/***************************************/

var speed=10;

var c=0;
var ur=0;
var ul=0;
var dr=0;
var dl=0;
var s=0;
var xc=0;
var yc=0;

if(window.addEventListener){
window.addEventListener('load',randomtest,false);
}
else {
if(window.attachEvent){
window.attachEvent('onload',randomtest);
}
}
function randomtest(){

secs=Math.floor((iterations-c)*speed/1000);

x=Math.floor(Math.random()*width);
y=Math.floor(Math.random()*height);

document.getElementById('coords').innerHTML+=x+':'+y+', ';

document.getElementById('dot').style.left=x+'px';
document.getElementById('dot').style.top=y+'px';

if((x&gt;=temp2)&&(y&gt;=temp1)) {
ur++;
temp1=x;
temp2=y;
}
else {
if((x&lt;=temp2)&&(y&gt;=temp1)) {
ul++;
temp1=x;
temp2=y;
}
else {
if((x&gt;=temp2)&&(y&lt;=temp1)) {
dr++;
temp1=x;
temp2=y;
}
else {
if((x&lt;=temp2)&&(y&lt;=temp1)) {
dl++;
temp1=x;
temp2=y;
}
}
}
}
c++;
xc=xc+x;
yc=yc+y;
if(c&gt;iterations) {
clearTimeout(rnd);

document.getElementById('timer').className='hide';
document.getElementById('dot').className='hide';
document.body.style.overflow='visible';

document.getElementById('upright').firstChild.nodeValue='up right total='+ur;
document.getElementById('upleft').firstChild.nodeValue='up left total='+ul;
document.getElementById('downright').firstChild.nodeValue='down right total='+dr;
document.getElementById('downleft').firstChild.nodeValue='down left total='+dl;

document.getElementById('container').className='';
document.getElementById('coords').className='';

alert('average coords areShucks | :-\ n\nx='+Math.round(xc/c)+'\ny='+Math.round(yc/c));

return;
}

document.getElementById('timer').firstChild.nodeValue='time remaining : '+secs+' seconds.';
rnd=setTimeout('randomtest()',speed);
}
</script>

</meta></meta></meta></head>
<body>

<div id="timer">&nbsp;</div>

<div id="container" class="hide">
<div id="upright">&nbsp;</div>
<div id="upleft">&nbsp;</div>
<div id="downright">&nbsp;</div>
<div id="downleft">&nbsp;</div>
</div>

<div id="dot">&bull;</div>
<div id="coords" class="hide"></div>

</body>
</html>
</code>

Can anyone help out with some C++ code to get me started? I would be forever greatful.

Skie
QuestionAccess array data Pin
necy3624-Feb-09 9:56
necy3624-Feb-09 9:56 
AnswerRe: Access array data Pin
Larry J. Siddens24-Feb-09 10:08
Larry J. Siddens24-Feb-09 10:08 
GeneralRe: Access array data Pin
necy3625-Feb-09 3:34
necy3625-Feb-09 3:34 
GeneralRe: Access array data Pin
Larry J. Siddens27-Feb-09 12:24
Larry J. Siddens27-Feb-09 12:24 
GeneralRe: Access array data Pin
necy362-Mar-09 2:52
necy362-Mar-09 2:52 
QuestionRe: Access array data Pin
CPallini24-Feb-09 11:33
mveCPallini24-Feb-09 11:33 
AnswerRe: Access array data Pin
«_Superman_»24-Feb-09 17:56
professional«_Superman_»24-Feb-09 17:56 
GeneralRe: Access array data Pin
necy3625-Feb-09 5:27
necy3625-Feb-09 5:27 
GeneralRe: Access array data Pin
Larry J. Siddens25-Feb-09 9:17
Larry J. Siddens25-Feb-09 9:17 
GeneralRe: Access array data Pin
«_Superman_»25-Feb-09 17:45
professional«_Superman_»25-Feb-09 17:45 
Question2005 sql server returns 'Invalid character value for cast specification' Pin
chenggong24-Feb-09 9:02
chenggong24-Feb-09 9:02 
AnswerRe: 2005 sql server returns 'Invalid character value for cast specification' Pin
Mukkie24-Feb-09 21:04
Mukkie24-Feb-09 21:04 
GeneralRe: 2005 sql server returns 'Invalid character value for cast specification' Pin
chenggong26-Feb-09 9:38
chenggong26-Feb-09 9:38 
QuestionWorking with .INI files - parsing Pin
john john mackey24-Feb-09 8:24
john john mackey24-Feb-09 8:24 
AnswerRe: Working with .INI files - parsing Pin
Stuart Dootson24-Feb-09 8:38
professionalStuart Dootson24-Feb-09 8:38 
GeneralRe: Working with .INI files - parsing Pin
john john mackey25-Feb-09 6:20
john john mackey25-Feb-09 6:20 
AnswerRe: Working with .INI files - parsing Pin
David Crow24-Feb-09 9:11
David Crow24-Feb-09 9:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.